From: Dave Chinner Date: Mon, 25 Nov 2024 21:14:11 +0000 (-0800) Subject: xfs: sb_spino_align is not verified X-Git-Tag: v6.13.0~211 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c0c39ae97031f4c35ee8f4ebec819bb640d2379;p=thirdparty%2Fxfsprogs-dev.git xfs: sb_spino_align is not verified Source kernel commit: 59e43f5479cce106d71c0b91a297c7ad1913176c 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 Reviewed-by: Darrick J. Wong Signed-off-by: Carlos Maiolino Reviewed-by: Christoph Hellwig --- diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index 0603e508..0d98b8a3 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -395,6 +395,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)) {