git: 904347a00c1f - main - Additional check for UFS/FFS superblock integrity checks.

From: Kirk McKusick <mckusick_at_FreeBSD.org>
Date: Sat, 16 Jul 2022 17:33:12 UTC
The branch main has been updated by mckusick:

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

commit 904347a00c1f9a29f3b17e6e676805036d2494f1
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2022-07-16 17:31:52 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2022-07-16 17:31:52 +0000

    Additional check for UFS/FFS superblock integrity checks.
    
    Tested by:   Peter Holm
    PR:          265162
---
 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 25657a00894f..21daa44de4d8 100644
--- a/sys/ufs/ffs/ffs_subr.c
+++ b/sys/ufs/ffs/ffs_subr.c
@@ -458,6 +458,7 @@ validate_sblock(struct fs *fs, int isaltsblk)
 	CHK(fs->fs_size, >, fs->fs_ncg * fs->fs_fpg, %jd);
 	CHK(fs->fs_cssize, !=,
 	    fragroundup(fs, fs->fs_ncg * sizeof(struct csum)), %jd);
+	CHK(dtog(fs, fs->fs_csaddr), >, fs->fs_ncg, %jd);
 	cgnum = dtog(fs, fs->fs_csaddr);
 	CHK(fs->fs_csaddr, <, cgdmin(fs, cgnum), %jd);
 	CHK(dtog(fs, fs->fs_csaddr + howmany(fs->fs_cssize, fs->fs_fsize)), >,