diff options
author | Dave Chinner <dchinner@redhat.com> | 2024-10-24 05:51:05 +0300 |
---|---|---|
committer | Carlos Maiolino <cem@kernel.org> | 2024-11-05 15:51:59 +0300 |
commit | 59e43f5479cce106d71c0b91a297c7ad1913176c (patch) | |
tree | 5372327feaa3c0910d360942098635737176063a | |
parent | 792ef2745d12cc129887eaef5bc62fe15f6f088a (diff) | |
download | linux-59e43f5479cce106d71c0b91a297c7ad1913176c.tar.xz |
xfs: sb_spino_align is not verified
It's just read in from the superblock and used without doing any
validity checks at all on the value.
Fixes: fb4f2b4e5a82 ("xfs: add sparse inode chunk alignment superblock field")
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
-rw-r--r-- | fs/xfs/libxfs/xfs_sb.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index d95409f3cba6..0d181bc140f0 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -398,6 +398,20 @@ xfs_validate_sb_common( sbp->sb_inoalignmt, align); return -EINVAL; } + + if (!sbp->sb_spino_align || + sbp->sb_spino_align > sbp->sb_inoalignmt || + (sbp->sb_inoalignmt % sbp->sb_spino_align) != 0) { + xfs_warn(mp, + "Sparse inode alignment (%u) is invalid.", + sbp->sb_spino_align); + return -EINVAL; + } + } else if (sbp->sb_spino_align) { + xfs_warn(mp, + "Sparse inode alignment (%u) should be zero.", + sbp->sb_spino_align); + return -EINVAL; } } else if (sbp->sb_qflags & (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD)) { |