From: Christoph Hellwig <hch@infradead.org>
To: Xiang Mei <xmei5@asu.edu>
Cc: Carlos Maiolino <cem@kernel.org>,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
bestswngs@gmail.com
Subject: Re: [PATCH] xfs: reject log continuation for a header-only item in recovery
Date: Mon, 13 Jul 2026 02:11:57 -0700 [thread overview]
Message-ID: <alSr3bJ8yow3ID9K@infradead.org> (raw)
In-Reply-To: <20260712220854.3131445-1-xmei5@asu.edu>
On Sun, Jul 12, 2026 at 03:08:54PM -0700, Xiang Mei wrote:
> On an XLOG_WAS_CONT_TRANS op, xlog_recover_add_to_cont_trans() extends the
> tail item's last region via item->ri_buf[item->ri_cnt-1] without checking
> that the item has one. A header-only item, created by
> xlog_recover_add_to_trans() when a transaction's first op is a bare
> sizeof(struct xfs_trans_header) op carrying XFS_TRANS_HEADER_MAGIC, sits on
> r_itemq with ri_cnt == 0 and ri_buf == NULL. A crafted log whose ops are
> XLOG_START_TRANS, that header op, then XLOG_WAS_CONT_TRANS thus
> dereferences ((struct kvec *)NULL)[-1] and faults during mount(2) log
> recovery of an untrusted XFS image.
>
> A valid XLOG_WAS_CONT_TRANS only follows a region written with
> XLOG_CONTINUE_TRANS, so ri_cnt >= 1 always holds for a real log. Reject the
> ri_cnt == 0 case as corruption with -EFSCORRUPTED, which the caller already
> propagates to abort recovery.
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
Can you share your code to generate these malformed logs? Because it
would be really useful to test these conditions regularly in xfstests..
next prev parent reply other threads:[~2026-07-13 9:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-12 22:08 Xiang Mei
2026-07-13 9:11 ` Christoph Hellwig [this message]
2026-07-15 1:02 ` Xiang Mei
2026-07-13 22:57 ` Darrick J. Wong
2026-07-15 0:36 ` Xiang Mei
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=alSr3bJ8yow3ID9K@infradead.org \
--to=hch@infradead.org \
--cc=bestswngs@gmail.com \
--cc=cem@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=xmei5@asu.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
all inboxes | Powered by JetHome®