xfs
[Top] [All Lists]

[PATCH 4/5] xfs_metadump: Fix unaligned accesses

To: xfs@xxxxxxxxxxx
Subject: [PATCH 4/5] xfs_metadump: Fix unaligned accesses
From: Eric Sandeen <sandeen@xxxxxxxxxxx>
Date: Fri, 9 Oct 2015 14:53:00 -0500
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <56181A17.9080503@xxxxxxxxxxx>
References: <56181A17.9080503@xxxxxxxxxxx>
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.3.0
This fixes some unaligned accesses spotted by libubsan in
xfs_metadump.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---
 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


<Prev in Thread] Current Thread [Next in Thread>