1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-29 12:03:03 +00:00

Updates to UFS/FFS superblock integrity checks when reading a superblock.

Verify that the summary information does not extend past the end
of the filesystem.

No legitimate superblocks should fail as a result of these changes.

Reported-by:  Robert Morris
PR:           271351
MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
This commit is contained in:
Kirk McKusick 2023-05-27 12:23:39 -07:00
parent 537cd76643
commit c79a141695

View File

@ -443,7 +443,8 @@ validate_sblock(struct fs *fs, int flags)
FCHK(fs->fs_csaddr, <, 0, %jd);
FCHK(fs->fs_cssize, !=,
fragroundup(fs, fs->fs_ncg * sizeof(struct csum)), %jd);
FCHK(dtog(fs, fs->fs_csaddr), >, fs->fs_ncg, %jd);
FCHK(fs->fs_csaddr + howmany(fs->fs_cssize, fs->fs_fsize), >,
fs->fs_size, %jd);
FCHK(fs->fs_csaddr, <, cgdmin(fs, dtog(fs, fs->fs_csaddr)),
%jd);
FCHK(dtog(fs, fs->fs_csaddr + howmany(fs->fs_cssize,
@ -594,7 +595,8 @@ validate_sblock(struct fs *fs, int flags)
FCHK(fs->fs_csaddr, <, 0, %jd);
FCHK(fs->fs_cssize, !=,
fragroundup(fs, fs->fs_ncg * sizeof(struct csum)), %jd);
FCHK(dtog(fs, fs->fs_csaddr), >, fs->fs_ncg, %jd);
FCHK(fs->fs_csaddr + howmany(fs->fs_cssize, fs->fs_fsize), >,
fs->fs_size, %jd);
FCHK(fs->fs_csaddr, <, cgdmin(fs, dtog(fs, fs->fs_csaddr)), %jd);
FCHK(dtog(fs, fs->fs_csaddr + howmany(fs->fs_cssize, fs->fs_fsize)), >,
dtog(fs, fs->fs_csaddr), %jd);