aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_sb.c
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2014-02-07 15:26:11 +1100
committerDave Chinner <david@fromorbit.com>2014-02-07 15:26:11 +1100
commit392c6de98af1fd7e2fc9c7bf5e52be16286f7b42 (patch)
tree9f6bb940138ca26ee8d4cfa5ca6577edabacbc67 /fs/xfs/xfs_sb.c
parentxfs: convert xfs_log_commit_cil() to void (diff)
downloadlinux-dev-392c6de98af1fd7e2fc9c7bf5e52be16286f7b42.tar.xz
linux-dev-392c6de98af1fd7e2fc9c7bf5e52be16286f7b42.zip
xfs: sanitize sb_inopblock in xfs_mount_validate_sb
xfs_mount_validate_sb doesn't check sb_inopblock for sanity (as does its xfs_repair counterpart, FWIW). If it's out of bounds, we can go off the rails in i.e. xfs_inode_buf_verify(), which uses sb_inopblock as a loop limit when stepping through a metadata buffer. The problem can be demonstrated easily by corrupting sb_inopblock with xfs_db and trying to mount the result: # mkfs.xfs -dfile,name=fsfile,size=1g # xfs_db -x fsfile xfs_db> sb 0 xfs_db> write inopblock 512 inopblock = 512 xfs_db> quit # mount -o loop fsfile mnt and we blow up in xfs_inode_buf_verify(). With this patch, we get a (very noisy) corruption error, and fail the mount as we should. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Jie Liu <jeff.liu@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_sb.c')
-rw-r--r--fs/xfs/xfs_sb.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/xfs/xfs_sb.c b/fs/xfs/xfs_sb.c
index b7c9aea77f8f..511cce9359bb 100644
--- a/fs/xfs/xfs_sb.c
+++ b/fs/xfs/xfs_sb.c
@@ -288,6 +288,7 @@ xfs_mount_validate_sb(
sbp->sb_inodelog < XFS_DINODE_MIN_LOG ||
sbp->sb_inodelog > XFS_DINODE_MAX_LOG ||
sbp->sb_inodesize != (1 << sbp->sb_inodelog) ||
+ sbp->sb_inopblock != howmany(sbp->sb_blocksize,sbp->sb_inodesize) ||
(sbp->sb_blocklog - sbp->sb_inodelog != sbp->sb_inopblog) ||
(sbp->sb_rextsize * sbp->sb_blocksize > XFS_MAX_RTEXTSIZE) ||
(sbp->sb_rextsize * sbp->sb_blocksize < XFS_MIN_RTEXTSIZE) ||