[PATCH] xfs_db: fix unaligned accesses

Eric Sandeen
2016-05-06T20:43:59Z

Fix 2 unaligned accesses in xfs_db which caused bus errors on
sparc64. Similar treatment was already done in xfs_repair and
xfs_metadump but somehow xfs_db got missed.

Thanks to Anatoly for reminding me that unaligned access is
a thing. ;)

Resolves-oss-bugzilla: #1140
Reported-by: Anatoly Pugachev <matorola@gmail.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/db/check.c b/db/check.c
index c626a5c..0871ed7 100644
--- a/db/check.c
+++ b/db/check.c
@@ -2202,7 +2202,7 @@ process_btinode(
pp = XFS_BMDR_PTR_ADDR(dib, 1, xfs_bmdr_maxrecs(
XFS_DFORK_SIZE(dip, mp, whichfork), 0));
for (i = 0; i < be16_to_cpu(dib->bb_numrecs); i++)
- scan_lbtree(be64_to_cpu(pp[i]),
+ scan_lbtree(get_unaligned_be64(&pp[i]),
be16_to_cpu(dib->bb_level),
scanfunc_bmap, type, id, totd, toti,
nex, blkmapp, 1,
diff --git a/db/frag.c b/db/frag.c
index 3beb416..36bb689 100644
--- a/db/frag.c
+++ b/db/frag.c
@@ -258,8 +258,8 @@ process_btinode(
pp = XFS_BMDR_PTR_ADDR(dib, 1,
xfs_bmdr_maxrecs(XFS_DFORK_SIZE(dip, mp, whichfork), 0));
for (i = 0; i < be16_to_cpu(dib->bb_numrecs); i++)
- scan_lbtree(be64_to_cpu(pp[i]), be16_to_cpu(dib->bb_level),
- scanfunc_bmap, extmapp,
+ scan_lbtree(get_unaligned_be64(&pp[i]),
+ be16_to_cpu(dib->bb_level), scanfunc_bmap, extmapp,
whichfork == XFS_DATA_FORK ? TYP_BMAPBTD : TYP_BMAPBTA);
}

_______________________________________________
xfs mailing list
xfs@oss.sgi.com