summaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs/xfs_inode_buf.c
diff options
context:
space:
mode:
authorDarrick J. Wong2018-01-08 19:51:04 +0100
committerDarrick J. Wong2018-01-08 19:54:46 +0100
commit50aa90ef03007beca2c9108993f5b4f2bb4f0a66 (patch)
treefdf2091a028ec23c36b2e8f5c74393199e637448 /fs/xfs/libxfs/xfs_inode_buf.c
parentxfs: refactor verifier callers to print address of failing check (diff)
downloadkernel-qcow2-linux-50aa90ef03007beca2c9108993f5b4f2bb4f0a66.tar.gz
kernel-qcow2-linux-50aa90ef03007beca2c9108993f5b4f2bb4f0a66.tar.xz
kernel-qcow2-linux-50aa90ef03007beca2c9108993f5b4f2bb4f0a66.zip
xfs: verify dinode header first
Move the v3 inode integrity information (crc, owner, metauuid) before we look at anything else in the inode so that we don't waste time on a torn write or a totally garbled block. This makes xfs_dinode_verify more consistent with the other verifiers. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/libxfs/xfs_inode_buf.c')
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index a43a3702af93..a1ba112567b0 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -393,6 +393,19 @@ xfs_dinode_verify(
if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC))
return __this_address;
+ /* Verify v3 integrity information first */
+ if (dip->di_version >= 3) {
+ if (!xfs_sb_version_hascrc(&mp->m_sb))
+ return __this_address;
+ if (!xfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize,
+ XFS_DINODE_CRC_OFF))
+ return __this_address;
+ if (be64_to_cpu(dip->di_ino) != ino)
+ return __this_address;
+ if (!uuid_equal(&dip->di_uuid, &mp->m_sb.sb_meta_uuid))
+ return __this_address;
+ }
+
/* don't allow invalid i_size */
if (be64_to_cpu(dip->di_size) & (1ULL << 63))
return __this_address;
@@ -409,16 +422,6 @@ xfs_dinode_verify(
if (dip->di_version < 3)
return NULL;
- if (!xfs_sb_version_hascrc(&mp->m_sb))
- return __this_address;
- if (!xfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize,
- XFS_DINODE_CRC_OFF))
- return __this_address;
- if (be64_to_cpu(dip->di_ino) != ino)
- return __this_address;
- if (!uuid_equal(&dip->di_uuid, &mp->m_sb.sb_meta_uuid))
- return __this_address;
-
flags = be16_to_cpu(dip->di_flags);
flags2 = be64_to_cpu(dip->di_flags2);