From a2d1957bbcc87b499526df8d99ec7e1ddd2193c0 Mon Sep 17 00:00:00 2001 From: Kirk McKusick Date: Sat, 29 Apr 2023 11:52:27 -0700 Subject: [PATCH] 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 --- sys/ufs/ffs/ffs_subr.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index ba1d8c5c13c..5b4ad96f463 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -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);