git: a2d1957bbcc8 - main - Updates to UFS/FFS superblock integrity checks when reading a superblock.

From: Kirk McKusick <mckusick_at_FreeBSD.org>
Date: Sun, 30 Apr 2023 00:01:40 UTC
The branch main has been updated by mckusick:

URL: https://cgit.FreeBSD.org/src/commit/?id=a2d1957bbcc87b499526df8d99ec7e1ddd2193c0

commit a2d1957bbcc87b499526df8d99ec7e1ddd2193c0
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2023-04-29 18:52:27 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2023-04-30 00:01:18 +0000

    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 ba1d8c5c13c9..5b4ad96f4638 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);