[PATCH] xfs: reject a hole in a remote xattr value
From: Kyuwon Cho
Date: Sat Nov 21 2026 - 00:05:27 EST
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@xxxxxxxxx>
---
Christoph, understood: 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. It does the same run-time check as
xfs_attr_rmtval_stale().
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 | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index e6c8dd1a997a..722440f005ca 100644
--- a/fs/xfs/libxfs/xfs_attr_remote.c
+++ b/fs/xfs/libxfs/xfs_attr_remote.c
@@ -427,8 +427,11 @@ xfs_attr_rmtval_get(
xfs_daddr_t dblkno;
int dblkcnt;
- ASSERT((map[i].br_startblock != DELAYSTARTBLOCK) &&
- (map[i].br_startblock != HOLESTARTBLOCK));
+ if (XFS_IS_CORRUPT(mp, map[i].br_startblock == DELAYSTARTBLOCK) ||
+ XFS_IS_CORRUPT(mp, map[i].br_startblock == HOLESTARTBLOCK)) {
+ xfs_bmap_mark_sick(args->dp, XFS_ATTR_FORK);
+ return -EFSCORRUPTED;
+ }
dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock);
dblkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount);
error = xfs_buf_read(mp->m_ddev_targp, dblkno, dblkcnt,
--
2.43.0