git: 4660b60a00c3 - stable/13 - Updates to UFS/FFS superblock integrity checks when reading a superblock.

From: Kirk McKusick <mckusick_at_FreeBSD.org>
Date: Mon, 27 Mar 2023 23:47:19 UTC
The branch stable/13 has been updated by mckusick:

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

commit 4660b60a00c3120ddecd94b3f308d39bcb6d085a
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2023-03-27 23:45:59 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2023-03-27 23:46:40 +0000

    Updates to UFS/FFS superblock integrity checks when reading a superblock.
    
    Have to add a check that the computed cylinder group size does not
    exceed the block size of the filesystem.
    
    Sponsored by: The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D38668
    
    (cherry picked from commit 0eabe33087d8cb69ae800daae322f12a8f16bd10)
---
 sys/ufs/ffs/ffs_subr.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c
index d847373a8cde..2f69965aba7e 100644
--- a/sys/ufs/ffs/ffs_subr.c
+++ b/sys/ufs/ffs/ffs_subr.c
@@ -446,6 +446,7 @@ validate_sblock(struct fs *fs, int isaltsblk)
 	CHK(fs->fs_old_cgoffset, <, 0, %jd);
 	CHK2(fs->fs_old_cgoffset, >, 0, ~fs->fs_old_cgmask, <, 0, %jd);
 	CHK(fs->fs_old_cgoffset * (~fs->fs_old_cgmask), >, fs->fs_fpg, %jd);
+	CHK(CGSIZE(fs), >, fs->fs_bsize, %jd);
 	/*
 	 * If anything has failed up to this point, it is usafe to proceed
 	 * as checks below may divide by zero or make other fatal calculations.