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

Check for an uninitialed (zero valued) fs_maxbsize and set it
to its minimum valid size (fs_bsize). Uninitialed fs_maxbsize
were left by older versions of makefs(8) and the superblock
integrity checks fail when they are found.

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

MFC after:    1 week
Sponsored by: The FreeBSD Foundation
This commit is contained in:
Kirk McKusick 2023-04-29 11:52:27 -07:00
parent 04997e19e2
commit a2d1957bbc

View File

@ -514,6 +514,9 @@ validate_sblock(struct fs *fs, int flags)
%jd);
FCHK(fs->fs_sbsize, >, SBLOCKSIZE, %jd);
FCHK(fs->fs_sbsize, <, (signed)sizeof(struct fs), %jd);
/* fix for misconfigured filesystems */
if (fs->fs_maxbsize == 0)
fs->fs_maxbsize = fs->fs_bsize;
FCHK(fs->fs_maxbsize, <, fs->fs_bsize, %jd);
FCHK(powerof2(fs->fs_maxbsize), ==, 0, %jd);
FCHK(fs->fs_maxbsize, >, FS_MAXCONTIG * fs->fs_bsize, %jd);