aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorBill O'Donnell <billodo@redhat.com>2018-07-26 10:10:34 -0700
committerDarrick J. Wong <darrick.wong@oracle.com>2018-07-31 13:18:09 -0700
commit8756a5af18191a471e670cc577aea60b652fea4c (patch)
tree8af4e4655ce8932c8fddd44154aa2c9f5deda828 /fs/xfs
parentxfs: refactor superblock verifiers (diff)
downloadlinux-dev-8756a5af18191a471e670cc577aea60b652fea4c.tar.xz
linux-dev-8756a5af18191a471e670cc577aea60b652fea4c.zip
libxfs: add more bounds checking to sb sanity checks
Current sb verifier doesn't check bounds on sb_fdblocks and sb_ifree. Add sanity checks for these parameters. Signed-off-by: Bill O'Donnell <billodo@redhat.com> [darrick: port to refactored sb validation predicates] Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/libxfs/xfs_sb.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index f3835e923893..3d29f4a5242f 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -150,6 +150,18 @@ xfs_validate_sb_write(
struct xfs_mount *mp,
struct xfs_sb *sbp)
{
+ /*
+ * Carry out additional sb summary counter sanity checks when we write
+ * the superblock. We skip this in the read validator because there
+ * could be newer superblocks in the log and if the values are garbage
+ * we'll recalculate them at the end of log mount.
+ */
+ if (sbp->sb_fdblocks > sbp->sb_dblocks ||
+ sbp->sb_ifree > sbp->sb_icount) {
+ xfs_warn(mp, "SB summary counter sanity check failed");
+ return -EFSCORRUPTED;
+ }
+
if (XFS_SB_VERSION_NUM(sbp) != XFS_SB_VERSION_5)
return 0;