mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-13 10:02:38 +00:00
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
2e4da012d5
commit
9dee5da745
@ -473,7 +473,6 @@ validate_sblock(struct fs *fs, int flags)
|
||||
FCHK(fs->fs_fpg, <, 3 * fs->fs_frag, %jd);
|
||||
FCHK(fs->fs_ncg, <, 1, %jd);
|
||||
FCHK(fs->fs_ipg, <, fs->fs_inopb, %jd);
|
||||
FCHK(fs->fs_ipg % fs->fs_inopb, !=, 0, %jd);
|
||||
FCHK(fs->fs_ipg * fs->fs_ncg, >, (((int64_t)(1)) << 32) - INOPB(fs),
|
||||
%jd);
|
||||
FCHK(fs->fs_cstotal.cs_nifree, <, 0, %jd);
|
||||
@ -505,6 +504,7 @@ validate_sblock(struct fs *fs, int flags)
|
||||
*/
|
||||
if (error)
|
||||
return (error);
|
||||
FCHK(fs->fs_ipg % fs->fs_inopb, !=, 0, %jd);
|
||||
FCHK(fs->fs_sblkno, !=, roundup(
|
||||
howmany(fs->fs_sblockloc + SBLOCKSIZE, fs->fs_fsize),
|
||||
fs->fs_frag), %jd);
|
||||
|
Loading…
Reference in New Issue
Block a user