[PATCH 4/5] xfs_metadump: Fix unaligned accesses

Eric Sandeen sandeen at sandeen.net
Fri Oct 9 14:53:00 CDT 2015


This fixes some unaligned accesses spotted by libubsan in
xfs_metadump.

Signed-off-by: Eric Sandeen <sandeen at redhat.com>
---
 db/metadump.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/db/metadump.c b/db/metadump.c
index af96e12..39f893d 100644
--- a/db/metadump.c
+++ b/db/metadump.c
@@ -1872,8 +1872,8 @@ scanfunc_bmap(
 		xfs_agnumber_t	ag;
 		xfs_agblock_t	bno;
 
-		ag = XFS_FSB_TO_AGNO(mp, be64_to_cpu(pp[i]));
-		bno = XFS_FSB_TO_AGBNO(mp, be64_to_cpu(pp[i]));
+		ag = XFS_FSB_TO_AGNO(mp, get_unaligned_be64(&pp[i]));
+		bno = XFS_FSB_TO_AGBNO(mp, get_unaligned_be64(&pp[i]));
 
 		if (bno == 0 || bno > mp->m_sb.sb_agblocks ||
 				ag > mp->m_sb.sb_agcount) {
@@ -1938,8 +1938,8 @@ process_btinode(
 		xfs_agnumber_t	ag;
 		xfs_agblock_t	bno;
 
-		ag = XFS_FSB_TO_AGNO(mp, be64_to_cpu(pp[i]));
-		bno = XFS_FSB_TO_AGBNO(mp, be64_to_cpu(pp[i]));
+		ag = XFS_FSB_TO_AGNO(mp, get_unaligned_be64(&pp[i]));
+		bno = XFS_FSB_TO_AGBNO(mp, get_unaligned_be64(&pp[i]));
 
 		if (bno == 0 || bno > mp->m_sb.sb_agblocks ||
 				ag > mp->m_sb.sb_agcount) {
-- 
2.6.1




More information about the xfs mailing list