Linux XFS filesystem development
 help / color / mirror / Atom feed
* [PATCH] xfs: read rmapbt high key offsets with get_unaligned() in scrub
@ 2026-11-09 13:48 Stian Halseth
  2026-11-09 21:40 ` Dave Chinner
  0 siblings, 1 reply; 4+ messages in thread
From: Stian Halseth @ 2026-11-09 13:48 UTC (permalink / raw)
  To: Carlos Maiolino, linux-xfs
  Cc: Darrick J . Wong, sparclinux, Stian Halseth, Jan Engelhardt,
	stable

An rmapbt node stores each key as a low/high pair of packed 20-byte
struct xfs_rmap_key, so every high key is only 4-byte aligned.
union xfs_btree_key is 8-byte aligned, which lets the compiler read
rm_offset through it with an 8-byte load.  On sparc64 every high key
checked by xchk_rmapbt_check_unwritten_in_keyflags() then takes an
unaligned access trap:

  Kernel unaligned access at TPC[105a54d8] xchk_rmapbt_check_unwritten_in_keyflags+0xb8/0x160 [xfs]

Use get_unaligned() for the high key.

Fixes: 38384569a2a8 ("xfs: detect unwritten bit set in rmapbt node block keys")
Reported-by: Jan Engelhardt <jengelh@inai.de>
Closes: https://github.com/sparclinux/issues/issues/115
Cc: stable@vger.kernel.org # v6.4+
Signed-off-by: Stian Halseth <stian@itx.no>
---
Tested on sparc64 (T4, 7.3.3) by scrubbing the rmapbt of a loop-mounted
image: alignment faults per scrub went from about 4000 to 0.

 fs/xfs/scrub/rmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/scrub/rmap.c b/fs/xfs/scrub/rmap.c
index 68e2847c962bb..d0578800f3e41 100644
--- a/fs/xfs/scrub/rmap.c
+++ b/fs/xfs/scrub/rmap.c
@@ -174,7 +174,7 @@ xchk_rmapbt_check_unwritten_in_keyflags(
 			}
 
 			hkey = xfs_btree_high_key_addr(cur, ptr, keyblock);
-			if (hkey->rmap.rm_offset & badflag) {
+			if (get_unaligned(&hkey->rmap.rm_offset) & badflag) {
 				xchk_btree_set_preen(sc, cur, level);
 				break;
 			}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-10 20:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-09 13:48 [PATCH] xfs: read rmapbt high key offsets with get_unaligned() in scrub Stian Halseth
2026-11-09 21:40 ` Dave Chinner
2026-11-10  8:33   ` Stian Halseth
2026-11-10 20:28     ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox