Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796231869; b=Z1Zgw0QYM9z/GQRuv/Dp5uINnVQ4fCu6ICY9S5R33fTUw6E3VzaA4bAkISVygV6tZfzj ljbeOu/GpYeDjFpv8g2XWM9l+KZ44hvBLNs/c9+E0b6xBbxKNFHJ1gVhcMElDb166iuOl US2GnkqspRzPj1sdfErKlYYIp3s4aaFGohSCScH7t1o2dRkhcw8nx3eW/88eDP1RA7QiH Acri4e6UNJi2alaFx5W4Dpn0SbzCVzuP/tZRjGVr9aQODz+eMDHL48trQGANsCyE4iKol k7JZpMHLvy4XFjuoNN3/sESkkCMXHAZhcFcU/8NiJF/RLTjroPUk7Ug9JDlKXJwkBEg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796231869; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=ZD73wNX+THwy0pR9cEvqW8vMcXAxI5/N19n7BUb/y6k=; b=iLZMq+QTMptTwnW1qj3Xd59+lYkQVsuIxUsmyET7X5jA1kcZjGL5bHh4dzKYwSLsd3OO 3r9yS45Aqyd4hfMZZH5ZRDNJPwSq/X3/Ebyxon/sHBHm6ojy4y1mkSVgw7y/RzDJ0fad4 cDA/WZ6TZKJm85bTTCXDDdD2YZlEnubPLZ19ENVKEdORQo5pR+9rT6B5zFYHRgrm3SegQ ZFOXlZ61ck2csAtL8LggZmsGKY1B6N4owOWr2X4UnftlspU9iGPZI2l/hDxe1F6Xl0XEu wyLWRTd06hFs5geJ3NEZ8X0mLKv2rIEB8odNJeHrEqx0F8jOc+x5YyEAg9ALXKgralA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XwcYAJrq; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03737606A322; Wed, 2 Dec 2026 17:17:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XwcYAJrq Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23C221F0089B; Wed, 2 Dec 2026 17:17:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796231868; bh=ZD73wNX+THwy0pR9cEvqW8vMcXAxI5/N19n7BUb/y6k=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=XwcYAJrqupQequvKY5fAkqnw+nUB4ClAjyP8RiMqX4C+DGvjyEvKfsRyfRQaMFNrt PTibvifZrrgqjN4GBqdywu75ovxGC/Bf7HAgyMwfLqSNi6V0aQ0Kq0Z0YzJgvDkDwE +KepKbixkiouILiFZ80mI0kBcCYZw8ZAom/8lfDd0hd86P/QD01XVuKOInhu/Ng+Ql uAixR9daDUlk139T5iw3B4e9LjW0B/8VaR6KfT5bz0IaHHw87x6X7HqhgXhoG22n6K DBa5sNLo1D88VAi+fO+21jcQhm0vHKzrg1wGlGW0xNRM5kZ9BUpiVa+izXJgOeD6ka 3Exd8I1QFzVAw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [f2fs-dev] [PATCH v20 22/23] xfs: introduce health state for corrupted fsverity metadata Reply-To: sashiko-reviews@lists.linux.dev To: "Andrey Albershteyn via Linux-f2fs-devel" , linux-ext4 , "Eric Biggers" , "Christoph Hellwig" , "Carlos Maiolino" , fsverity Cc: david@fromorbit.com, "Christian Brauner" , "Andrey Albershteyn" , "Darrick J. Wong" , dsterba@suse.cz, tytso@mit.edu In-Reply-To: <20261202165653.767961-23-aalbersh@kernel.org> References: <20261202165653.767961-1-aalbersh@kernel.org> <20261202165653.767961-23-aalbersh@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 17:17:47 +0000 X-Mailing-List: fsverity@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] xfs: unreachable minimum descriptor size check in xfs_fsverity_get_descriptor() - [Medium] xfs: XFS_SICK_INO_FSVERITY is never cleared by online scrub or repair - [Medium] xfs: race between xfs_fsverity_get_descriptor() and online verity repair -- commit 63bf6ece967dd5f4837d3ecdcb95059db67d9179 Author: Andrey Albershteyn xfs: introduce health state for corrupted fsverity metadata This commit adds XFS_SICK_INO_FSVERITY and XFS_BS_SICK_FSVERITY to track and report corrupted fsverity metadata in the XFS health system. > diff --git a/fs/xfs/libxfs/xfs_health.h b/fs/xfs/libxfs/xfs_health.h > index 1d45cf5789e86..932b447190da7 100644 > --- a/fs/xfs/libxfs/xfs_health.h > +++ b/fs/xfs/libxfs/xfs_health.h > @@ -104,6 +104,7 @@ struct xfs_rtgroup; > /* Don't propagate sick status to ag health summary during inactivation = */ > #define XFS_SICK_INO_FORGET (1 << 12) > #define XFS_SICK_INO_DIRTREE (1 << 13) /* directory tree structure */ > +#define XFS_SICK_INO_FSVERITY (1 << 14) /* fsverity metadata */ > =20 > /* Primary evidence of health problems in a given group. */ > #define XFS_SICK_FS_PRIMARY (XFS_SICK_FS_COUNTERS | \ > @@ -140,7 +141,8 @@ struct xfs_rtgroup; > XFS_SICK_INO_XATTR | \ > XFS_SICK_INO_SYMLINK | \ > XFS_SICK_INO_PARENT | \ > - XFS_SICK_INO_DIRTREE) > + XFS_SICK_INO_DIRTREE | \ > + XFS_SICK_INO_FSVERITY) [Severity: Medium] Does online scrub or repair ever clear XFS_SICK_INO_FSVERITY? When xchk_prepare_iscrub() scrubs an inode with corrupted verity metadata, xchk_inode_setup_verity() -> xfs_fsverity_get_descriptor() sets XFS_SICK_INO_FSVERITY on sc->ip->i_sick. Neither type_to_health_flag[] for XFS_SCRUB_TYPE_INODE nor xchk_inode() includes XFS_SICK_INO_FSVERITY in the health mask. After xrep_inode_zap_verity() repairs the inode and the re-scrub pass calls xfs_inode_mark_healthy(), XFS_SICK_INO_CORE and XFS_SICK_INO_FORGET are cleared while XFS_SICK_INO_FSVERITY remains set. When the repaired inode is later inactivated, xfs_inactive_health() sees XFS_SICK_INO_FSVERITY without XFS_SICK_INO_FORGET and marks the AG sick with XFS_SICK_AG_INODES. > diff --git a/fs/xfs/xfs_fsverity.c b/fs/xfs/xfs_fsverity.c > index 1c1cc5a6462bb..cc1c42df7ba31 100644 > --- a/fs/xfs/xfs_fsverity.c > +++ b/fs/xfs/xfs_fsverity.c > @@ -98,8 +98,10 @@ xfs_fsverity_get_descriptor( > if (error) > return error; > =20 > - if (is_empty) > + if (is_empty) { > + xfs_inode_mark_sick(XFS_I(inode), XFS_SICK_INO_FSVERITY); > return -ENODATA; > + } [Severity: Medium] Can an in-flight xfs_fsverity_get_descriptor() race with online verity repair and mark a repaired inode sick? xfs_fsverity_get_descriptor() drops XFS_ILOCK_EXCL right after checking S_VERITY and calling xfs_bmap_last_extent(), before reading post-EOF folios and calling xfs_inode_mark_sick(): CPU0 CPU1 xfs_fsverity_get_descriptor() xfs_ilock(ip, XFS_ILOCK_EXCL) /* checks S_VERITY, reads rec */ xfs_iunlock(ip, XFS_ILOCK_EXCL) xchk_prepare_iscrub() truncate_inode_pages(...) xchk_ilock(sc, XFS_ILOCK_EXCL) ... xrep_inode_zap_verity() xfs_bunmapi_range(...) inode_set_flags(..., 0, S_VERITY) xchk_teardown_inode() xfs_iunlock(ip, XFS_ILOCK_EXCL) fsverity_pagecache_read(...) /* sees corrupted desc_size */ xfs_inode_mark_sick(ip, XFS_SICK_INO_FSVERITY) <-- marks repaired non-verity inode sick CPU0 can also repopulate post-EOF pagecache folios after truncate_inode_pages(), and the late XFS_SICK_INO_FSVERITY mark will propagate XFS_SICK_AG_INODES when the inode is inactivated. > @@ -110,8 +112,10 @@ xfs_fsverity_get_descriptor( > =20 > last_block_offset =3D > XFS_FSB_TO_B(mp, rec.br_startoff + rec.br_blockcount); > - if (last_block_offset <=3D xfs_fsverity_metadata_offset(ip)) > + if (last_block_offset <=3D xfs_fsverity_metadata_offset(ip)) { > + xfs_inode_mark_sick(XFS_I(inode), XFS_SICK_INO_FSVERITY); > return -ENODATA; > + } > =20 > desc_size_pos =3D last_block_offset - sizeof(__be32); > error =3D fsverity_pagecache_read(inode, (char *)&d_desc_size, > @@ -120,10 +124,15 @@ xfs_fsverity_get_descriptor( > return error; > =20 > desc_size =3D be32_to_cpu(d_desc_size); > - if (XFS_IS_CORRUPT(mp, desc_size > FS_VERITY_MAX_DESCRIPTOR_SIZE)) > + if (XFS_IS_CORRUPT(mp, desc_size > FS_VERITY_MAX_DESCRIPTOR_SIZE)) { > + xfs_inode_mark_sick(XFS_I(inode), XFS_SICK_INO_FSVERITY); > return -ERANGE; > - if (XFS_IS_CORRUPT(mp, desc_size > desc_size_pos)) > + } > + > + if (XFS_IS_CORRUPT(mp, desc_size > desc_size_pos)) { > + xfs_inode_mark_sick(XFS_I(inode), XFS_SICK_INO_FSVERITY); > return -ERANGE; > + } > =20 > if (!buf_size) > return desc_size; > @@ -132,12 +141,16 @@ xfs_fsverity_get_descriptor( > return -ERANGE; > =20 > if (XFS_IS_CORRUPT(mp, > - desc_size < sizeof(struct fsverity_descriptor))) > + desc_size < sizeof(struct fsverity_descriptor))) { > + xfs_inode_mark_sick(XFS_I(inode), XFS_SICK_INO_FSVERITY); > return -ERANGE; > + } > =20 > desc_pos =3D round_down(desc_size_pos - desc_size, blocksize); > - if (desc_pos < xfs_fsverity_metadata_offset(ip)) > + if (desc_pos < xfs_fsverity_metadata_offset(ip)) { > + xfs_inode_mark_sick(XFS_I(inode), XFS_SICK_INO_FSVERITY); > return -ERANGE; > + } [Severity: Medium] Can the desc_size < sizeof(struct fsverity_descriptor) corruption check ever be reached when the on-disk descriptor size is too small? fsverity_get_descriptor() always probes the size with buf_size =3D=3D 0 fir= st: fs/verity/open.c:fsverity_get_descriptor() { ... size =3D inode->i_sb->s_vop->get_verity_descriptor(inode, NULL, 0); if (size < 0) { ... return size; } if (size < sizeof(*desc) || size > FS_VERITY_MAX_DESCRIPTOR_SIZE) { ... return -EMSGSIZE; } } Because xfs_fsverity_get_descriptor() returns desc_size when !buf_size before checking desc_size < sizeof(struct fsverity_descriptor), an undersized on-disk desc_size is returned to fsverity_get_descriptor(), which fails with -EMSGSIZE without calling get_verity_descriptor() a second time. As a result, neither XFS_IS_CORRUPT() nor xfs_inode_mark_sick() runs for undersized descriptors. Moving the minimum size and desc_pos checks above if (!buf_size) would ensure they run on the initial probe. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202165653.7679= 61-1-aalbersh@kernel.org?part=3D22