]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: always check magic values in on-disk byte order
authorBrian Foster <bfoster@redhat.com>
Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)
committerEric Sandeen <sandeen@redhat.com>
Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)
Source kernel commit: e34d3e74eb8f6eb020312cec747ff55ee1d1ca18

Most verifiers that check on-disk magic values convert the CPU
endian magic value constant to disk endian to facilitate compile
time optimization of the byte swap and reduce the need for runtime
byte swaps in buffer verifiers. Several buffer verifiers do not
follow this pattern. Update those verifiers for consistency.

Also fix up a random typo in the inode readahead verifier name.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_alloc.c
libxfs/xfs_attr_leaf.c
libxfs/xfs_da_btree.c
libxfs/xfs_inode_buf.c
libxfs/xfs_sb.c

index 2639e2f69fff936318d2a303dee4f2e8ad2567d8..189986ba6473475c80215c7f9ba0e8e646729660 100644 (file)
@@ -566,7 +566,7 @@ xfs_agfl_verify(
 
        if (!uuid_equal(&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid))
                return __this_address;
-       if (be32_to_cpu(agfl->agfl_magicnum) != XFS_AGFL_MAGIC)
+       if (agfl->agfl_magicnum != cpu_to_be32(XFS_AGFL_MAGIC))
                return __this_address;
        /*
         * during growfs operations, the perag is not fully initialised,
index 5683d294effd0331f01c488f61690954991c4d33..f13f5b14898a1029ccc88073d14d21e33bd79894 100644 (file)
@@ -246,7 +246,7 @@ xfs_attr3_leaf_verify(
        if (xfs_sb_version_hascrc(&mp->m_sb)) {
                struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
 
-               if (ichdr.magic != XFS_ATTR3_LEAF_MAGIC)
+               if (hdr3->info.hdr.magic != cpu_to_be16(XFS_ATTR3_LEAF_MAGIC))
                        return __this_address;
 
                if (!uuid_equal(&hdr3->info.uuid, &mp->m_sb.sb_meta_uuid))
@@ -256,7 +256,7 @@ xfs_attr3_leaf_verify(
                if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->info.lsn)))
                        return __this_address;
        } else {
-               if (ichdr.magic != XFS_ATTR_LEAF_MAGIC)
+               if (leaf->hdr.info.magic != cpu_to_be16(XFS_ATTR_LEAF_MAGIC))
                        return __this_address;
        }
        /*
index 4fceab8844cd421580e0bdb370eccb79834fb967..afc3c6839f1c48a92582e426bd174c17911e2476 100644 (file)
@@ -127,7 +127,7 @@ xfs_da3_node_verify(
        if (xfs_sb_version_hascrc(&mp->m_sb)) {
                struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
 
-               if (ichdr.magic != XFS_DA3_NODE_MAGIC)
+               if (hdr3->info.hdr.magic != cpu_to_be16(XFS_DA3_NODE_MAGIC))
                        return __this_address;
 
                if (!uuid_equal(&hdr3->info.uuid, &mp->m_sb.sb_meta_uuid))
@@ -137,7 +137,7 @@ xfs_da3_node_verify(
                if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->info.lsn)))
                        return __this_address;
        } else {
-               if (ichdr.magic != XFS_DA_NODE_MAGIC)
+               if (hdr->hdr.info.magic != cpu_to_be16(XFS_DA_NODE_MAGIC))
                        return __this_address;
        }
        if (ichdr.level == 0)
index 0aade2b57efc589c03610211437d751f14bbe5c7..89c92838a0f7017a3c2e3582a2b1f0e6688ed960 100644 (file)
@@ -147,7 +147,7 @@ const struct xfs_buf_ops xfs_inode_buf_ops = {
 };
 
 const struct xfs_buf_ops xfs_inode_buf_ra_ops = {
-       .name = "xxfs_inode_ra",
+       .name = "xfs_inode_ra",
        .verify_read = xfs_inode_buf_readahead_verify,
        .verify_write = xfs_inode_buf_write_verify,
 };
index cee77a67f7490a6ae96ae502808af1dba5ac4833..9094d7bf62780f3ab8dd063e8478ba268b8100c5 100644 (file)
@@ -222,10 +222,11 @@ xfs_validate_sb_common(
        struct xfs_buf          *bp,
        struct xfs_sb           *sbp)
 {
+       struct xfs_dsb          *dsb = XFS_BUF_TO_SBP(bp);
        uint32_t                agcount = 0;
        uint32_t                rem;
 
-       if (sbp->sb_magicnum != XFS_SB_MAGIC) {
+       if (dsb->sb_magicnum != cpu_to_be32(XFS_SB_MAGIC)) {
                xfs_warn(mp, "bad magic number");
                return -EWRONGFS;
        }