From: Kyuwon Cho <kyuwoncho18@gmail.com>
To: Carlos Maiolino <cem@kernel.org>
Cc: Christoph Hellwig <hch@infradead.org>,
"Darrick J. Wong" <djwong@kernel.org>,
Aldo Ariel Panzardo <qwe.aldo@gmail.com>,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] xfs: reject a hole in a remote xattr value
Date: Wed, 25 Nov 2026 23:59:28 +0900 [thread overview]
Message-ID: <179559978502.2875040.12926533524466805036@gmail.com> (raw)
xfs_attr_rmtval_get() maps the blocks of a remote xattr value from the
on-disk value length and only asserts that a mapping is not a hole. The
leaf verifier caps the length at XFS_XATTR_SIZE_MAX but does not check
it against the blocks the value owns, so a larger length makes the read
reach a hole. Without CONFIG_XFS_DEBUG the hole becomes a disk address
past the end of the device:
xfs_buf_map_verify: daddr 0x258000001a7f0 out of range, EOFS 0x96000
WARNING: fs/xfs/xfs_buf.c:423 at xfs_find_get_buf+0x160f/0x2350
Call Trace:
xfs_buf_read_map (fs/xfs/xfs_buf.c:648)
xfs_attr_rmtval_get (fs/xfs/libxfs/xfs_attr_remote.c:434)
xfs_attr3_leaf_getvalue (fs/xfs/libxfs/xfs_attr_leaf.c:2718)
Check for a hole or a delalloc extent at run time and return
-EFSCORRUPTED, as xfs_attr_rmtval_stale() does.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
---
v2:
- Read the start block into a local so that the checks fit in 80
columns, and post the patch as its own thread (Christoph).
v1: https://lore.kernel.org/linux-xfs/179523678723.1642977.7101755246592074809@gmail.com/
Report: https://lore.kernel.org/linux-xfs/179505710272.3511680.12978324583605871086@gmail.com/
An image with crafted metadata and recomputed CRCs is outside the XFS
threat model, so this is a hardening fix for such an image, not a
security fix.
The issue was found by an LLM-guided test generator that we are
developing as a research prototype. The patch was written with LLM
assistance; we reviewed and tested it. It applies to the xfs for-next
branch. With it, the reproducer from the report no longer triggers the
warning, and XFS reports the corruption instead.
fs/xfs/libxfs/xfs_attr_remote.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index e6c8dd1a997a..7cd3f2de1a80 100644
--- a/fs/xfs/libxfs/xfs_attr_remote.c
+++ b/fs/xfs/libxfs/xfs_attr_remote.c
@@ -424,12 +424,16 @@ xfs_attr_rmtval_get(
ASSERT(nmap >= 1);
for (i = 0; (i < nmap) && (valuelen > 0); i++) {
+ xfs_fsblock_t fsbno = map[i].br_startblock;
xfs_daddr_t dblkno;
int dblkcnt;
- ASSERT((map[i].br_startblock != DELAYSTARTBLOCK) &&
- (map[i].br_startblock != HOLESTARTBLOCK));
- dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock);
+ if (XFS_IS_CORRUPT(mp, fsbno == DELAYSTARTBLOCK) ||
+ XFS_IS_CORRUPT(mp, fsbno == HOLESTARTBLOCK)) {
+ xfs_bmap_mark_sick(args->dp, XFS_ATTR_FORK);
+ return -EFSCORRUPTED;
+ }
+ dblkno = XFS_FSB_TO_DADDR(mp, fsbno);
dblkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount);
error = xfs_buf_read(mp->m_ddev_targp, dblkno, dblkcnt,
0, &bp, &xfs_attr3_rmt_buf_ops);
--
2.43.0
next reply other threads:[~2026-11-25 14:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 14:59 Kyuwon Cho [this message]
2026-11-25 15:01 ` Christoph Hellwig
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=179559978502.2875040.12926533524466805036@gmail.com \
--to=kyuwoncho18@gmail.com \
--cc=cem@kernel.org \
--cc=djwong@kernel.org \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=qwe.aldo@gmail.com \
/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®