* [PATCH v2] xfs: reject a hole in a remote xattr value
@ 2026-11-25 14:59 Kyuwon Cho
2026-11-25 15:01 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Kyuwon Cho @ 2026-11-25 14:59 UTC (permalink / raw)
To: Carlos Maiolino
Cc: Christoph Hellwig, Darrick J. Wong, Aldo Ariel Panzardo,
linux-xfs, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] xfs: reject a hole in a remote xattr value
2026-11-25 14:59 [PATCH v2] xfs: reject a hole in a remote xattr value Kyuwon Cho
@ 2026-11-25 15:01 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2026-11-25 15:01 UTC (permalink / raw)
To: Kyuwon Cho
Cc: Carlos Maiolino, Darrick J. Wong, Aldo Ariel Panzardo, linux-xfs,
linux-kernel
The local variable makes this much nicer, thanks!
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-25 15:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 14:59 [PATCH v2] xfs: reject a hole in a remote xattr value Kyuwon Cho
2026-11-25 15:01 ` Christoph Hellwig
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®