Skip to content

Commit 59e43f5

Browse files
Dave Chinnercmaiolino
authored andcommitted
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: fb4f2b4 ("xfs: add sparse inode chunk alignment superblock field") Signed-off-by: Dave Chinner <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent 792ef27 commit 59e43f5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

fs/xfs/libxfs/xfs_sb.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,20 @@ xfs_validate_sb_common(
398398
sbp->sb_inoalignmt, align);
399399
return -EINVAL;
400400
}
401+
402+
if (!sbp->sb_spino_align ||
403+
sbp->sb_spino_align > sbp->sb_inoalignmt ||
404+
(sbp->sb_inoalignmt % sbp->sb_spino_align) != 0) {
405+
xfs_warn(mp,
406+
"Sparse inode alignment (%u) is invalid.",
407+
sbp->sb_spino_align);
408+
return -EINVAL;
409+
}
410+
} else if (sbp->sb_spino_align) {
411+
xfs_warn(mp,
412+
"Sparse inode alignment (%u) should be zero.",
413+
sbp->sb_spino_align);
414+
return -EINVAL;
401415
}
402416
} else if (sbp->sb_qflags & (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD |
403417
XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD)) {

0 commit comments

Comments
 (0)