Updates to UFS/FFS superblock integrity checks when reading a superblock.
Further updates based on ways Peter Holm found to corrupt UFS superblocks in ways that could cause kernel hangs or crashes. No legitimate superblocks should fail as a result of these changes. Reported by: Peter Holm Tested by: Peter Holm Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
db79bf75ac
commit
dcdba3460d
@ -407,7 +407,7 @@ validate_sblock(struct fs *fs, int flags)
|
||||
FCHK(powerof2(fs->fs_fsize), ==, 0, %jd);
|
||||
FCHK(fs->fs_sbsize, >, SBLOCKSIZE, %jd);
|
||||
FCHK(fs->fs_sbsize, <, (signed)sizeof(struct fs), %jd);
|
||||
FCHK(fs->fs_sbsize % fs->fs_fsize, !=, 0, %jd);
|
||||
FCHK(fs->fs_sbsize % dbtob(1), !=, 0, %jd);
|
||||
FCHK(fs->fs_fpg, <, 3 * fs->fs_frag, %jd);
|
||||
FCHK(fs->fs_ncg, <, 1, %jd);
|
||||
FCHK(fs->fs_fsbtodb, !=, ILOG2(fs->fs_fsize / sectorsize), %jd);
|
||||
@ -503,7 +503,7 @@ validate_sblock(struct fs *fs, int flags)
|
||||
*/
|
||||
if (error)
|
||||
return (error);
|
||||
FCHK(fs->fs_sbsize % fs->fs_fsize, !=, 0, %jd);
|
||||
FCHK(fs->fs_sbsize % dbtob(1), !=, 0, %jd);
|
||||
FCHK(fs->fs_ipg % fs->fs_inopb, !=, 0, %jd);
|
||||
FCHK(fs->fs_sblkno, !=, roundup(
|
||||
howmany(fs->fs_sblockloc + SBLOCKSIZE, fs->fs_fsize),
|
||||
|
Loading…
Reference in New Issue
Block a user