From: sashiko-bot@kernel.org
To: "Andrey Albershteyn via Linux-f2fs-devel"
<linux-f2fs-devel@lists.sourceforge.net>,
linux-ext4 <linux-ext4@vger.kernel.org>,
"Eric Biggers" <ebiggers@kernel.org>,
"Christoph Hellwig" <hch@lst.de>,
"Carlos Maiolino" <cem@kernel.org>,
fsverity <fsverity@lists.linux.dev>
Cc: david@fromorbit.com, "Christian Brauner" <brauner@kernel.org>,
"Andrey Albershteyn" <aalbersh@kernel.org>,
"Darrick J. Wong" <djwong@kernel.org>,
dsterba@suse.cz, tytso@mit.edu
Subject: Re: [f2fs-dev] [PATCH v20 22/23] xfs: introduce health state for corrupted fsverity metadata
Date: Wed, 02 Dec 2026 17:17:47 +0000 [thread overview]
Message-ID: <sashiko-outbox-246319@kernel.org> (raw)
In-Reply-To: <20261202165653.767961-23-aalbersh@kernel.org>
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 <aalbersh@kernel.org>
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 */
>
> /* 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;
>
> - 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(
>
> last_block_offset =
> XFS_FSB_TO_B(mp, rec.br_startoff + rec.br_blockcount);
> - if (last_block_offset <= xfs_fsverity_metadata_offset(ip))
> + if (last_block_offset <= xfs_fsverity_metadata_offset(ip)) {
> + xfs_inode_mark_sick(XFS_I(inode), XFS_SICK_INO_FSVERITY);
> return -ENODATA;
> + }
>
> desc_size_pos = last_block_offset - sizeof(__be32);
> error = fsverity_pagecache_read(inode, (char *)&d_desc_size,
> @@ -120,10 +124,15 @@ xfs_fsverity_get_descriptor(
> return error;
>
> desc_size = 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;
> + }
>
> if (!buf_size)
> return desc_size;
> @@ -132,12 +141,16 @@ xfs_fsverity_get_descriptor(
> return -ERANGE;
>
> 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;
> + }
>
> desc_pos = 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 == 0 first:
fs/verity/open.c:fsverity_get_descriptor() {
...
size = 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.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202165653.767961-1-aalbersh@kernel.org?part=22
next prev parent reply other threads:[~2026-12-02 17:17 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 16:56 [PATCH v20 00/23] fs-verity support for XFS with post EOF merkle tree Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 01/23] fs: constify inode argument of inode_state_read_once() Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 02/23] fs: strip FS_VERITY_FL from FS_IOC_SETFLAGS Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 03/23] fs,fsverity: add I_VERITY_BUILDING inode state flag Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 04/23] fs,fsverity: reject S_APPEND on fsverity inodes Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 05/23] iomap: use fsverity_is_building() to check for fsverity IO Andrey Albershteyn
2026-12-02 17:09 ` sashiko-bot
2026-12-02 16:56 ` [PATCH v20 06/23] btrfs: use I_VERITY_BUILDING instead of private flags Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 07/23] ext4: " Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 08/23] f2fs: " Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 09/23] xfs: introduce fsverity on-disk changes Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 10/23] xfs: don't allow to enable DAX on fs-verity sealed inode Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 11/23] xfs: disable direct read path for fs-verity files Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 12/23] xfs: don't report dio_mem_align and dio_offset_align for fsverity files Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 13/23] xfs: handle fsverity I/O in write/read path Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 14/23] xfs: use read ioend for fsverity data verification Andrey Albershteyn
2026-12-02 17:15 ` sashiko-bot
2026-12-02 16:56 ` [PATCH v20 15/23] xfs: add XFS_BMAPI_UNWRITTEN to unmap unwritten extents in __xfs_bunmapi() Andrey Albershteyn
2026-12-02 17:09 ` sashiko-bot
2026-12-02 16:56 ` [PATCH v20 16/23] xfs: don't remove written extents past EOF on fsverity inodes Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 17/23] xfs: add fs-verity support Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 18/23] xfs: initialize fs-verity on file open Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 19/23] xfs: add fs-verity ioctls Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 20/23] xfs: advertise fs-verity being available on filesystem Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 21/23] xfs: check and repair the verity inode flag state Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 22/23] xfs: introduce health state for corrupted fsverity metadata Andrey Albershteyn
2026-12-02 17:17 ` sashiko-bot [this message]
2026-12-02 16:56 ` [PATCH v20 23/23] xfs: enable ro-compat fs-verity flag Andrey Albershteyn
2026-12-02 17:17 ` [f2fs-dev] " sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-246319@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=aalbersh@kernel.org \
--cc=brauner@kernel.org \
--cc=cem@kernel.org \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=dsterba@suse.cz \
--cc=ebiggers@kernel.org \
--cc=fsverity@lists.linux.dev \
--cc=hch@lst.de \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox