From: Dave Chinner <dgc@kernel.org>
To: Kyuwon Cho <kyuwon.cho@skku.edu>
Cc: Carlos Maiolino <cem@kernel.org>,
"Darrick J. Wong" <djwong@kernel.org>,
linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs: validate intended file sizes in recovered exchange intents
Date: Fri, 4 Dec 2026 08:18:58 +1100 [thread overview]
Message-ID: <axHcwriGOgyQNNxO@dread> (raw)
In-Reply-To: <179611520882.292090.10012268204235409105@skku.edu>
On Fri, Dec 04, 2026 at 01:40:21AM +0900, Kyuwon Cho wrote:
> Recovery validates that the intended file sizes in an XMI log item are
> nonnegative, but it does not check them against the exchange offsets. A
> corrupted item can therefore describe an exchange starting inside both
> files while setting both intended sizes to zero.
>
> Recovery applies those sizes after exchanging the mappings, leaving
> mapped blocks beyond EOF. A later size change encounters the resulting
> folio and warns:
>
> WARNING: fs/iomap/buffered-io.c:1710 at iomap_zero_range
> RIP: iomap_zero_range (fs/iomap/buffered-io.c:1710)
> Call Trace:
> xfs_zero_range (fs/xfs/xfs_iomap.c:2393)
> xfs_vn_setattr_size (fs/xfs/xfs_iops.c:1011)
> xfs_vn_setattr (fs/xfs/xfs_iops.c:1171)
> notify_change (fs/attr.c:556)
> do_truncate (fs/open.c:68)
>
> When an intent sets file sizes, reject it unless each exchange start
> offset is at or before the corresponding intended EOF block.
>
> Fixes: b71ae66863e4 ("xfs: actually recover intended file sizes in xfs_xmi_item_recover_intent")
> Signed-off-by: Kyuwon Cho <kyuwon.cho@skku.edu>
> ---
> The issue was found by an LLM-guided test generator that we are
> developing as a research prototype. The reproducer creates and logs an
> exchange intent on a fresh XFS image, shuts the filesystem down after
> the log write, changes both intended sizes in the XMI item to zero and
> repairs the log checksums, then mounts the image to replay the item.
> Recovery leaves mappings beyond EOF, and a later truncate warns in
> iomap_zero_range(). With the patch recovery rejects the malformed
> intent and the warning does not occur.
Please have your test generator write a new fstest for this issue
and submit it. Just submitting a fix is only half the job, because
we still have no way to verify that the regression is fixed.
IMO, any sort of 'llm-guided test generator' should be outputting
fstests format tests and getting ti merged upstream for every issue
that they find. This allows the failure and the fix to be verified
by both upstream (devs) and downstream (distros) with minimal extra
effort. It should be trivial to get an LLM to automatically create a
fstests test for the issue...
> Found and tested on mainline fe6ff8d5d675 (v7.4-rc5); the patch is
> against the XFS for-next tree at 1ebd141a13ae.
>
> fs/xfs/xfs_exchmaps_item.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/xfs/xfs_exchmaps_item.c b/fs/xfs/xfs_exchmaps_item.c
> index 23381cb264c4..5b39085d5371 100644
> --- a/fs/xfs/xfs_exchmaps_item.c
> +++ b/fs/xfs/xfs_exchmaps_item.c
> @@ -352,6 +352,10 @@ xfs_xmi_validate(
> return false;
> if ((int64_t)xlf->xmi_isize2 < 0)
> return false;
> + if (xlf->xmi_startoff1 > XFS_B_TO_FSBT(mp, xlf->xmi_isize1))
> + return false;
> + if (xlf->xmi_startoff2 > XFS_B_TO_FSBT(mp, xlf->xmi_isize2))
> + return false;
> }
Fix looks fine, though.
Reviewed-by: Dave Chinner <dchinner@redhat.com>
-Dave.
--
Dave Chinner
dgc@kernel.org
prev parent reply other threads:[~2026-12-03 21:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 16:40 [PATCH] xfs: validate intended file sizes in recovered exchange intents Kyuwon Cho
2026-12-03 21:18 ` Dave Chinner [this message]
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=axHcwriGOgyQNNxO@dread \
--to=dgc@kernel.org \
--cc=cem@kernel.org \
--cc=djwong@kernel.org \
--cc=kyuwon.cho@skku.edu \
--cc=linux-xfs@vger.kernel.org \
/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