git: dcdba3460dd7 - main - Updates to UFS/FFS superblock integrity checks when reading a superblock.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 03 Oct 2022 12:53:34 UTC
The branch main has been updated by mckusick:
URL: https://cgit.FreeBSD.org/src/commit/?id=dcdba3460dd779a0180ec7769ab8cd47c932799e
commit dcdba3460dd779a0180ec7769ab8cd47c932799e
Author: Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2022-10-03 12:52:17 +0000
Commit: Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2022-10-03 12:53:10 +0000
Updates to UFS/FFS superblock integrity checks when reading a superblock.
Further updates based on ways Peter Holm found to corrupt UFS
superblocks in ways that could cause kernel hangs or crashes.
No legitimate superblocks should fail as a result of these changes.
Reported by: Peter Holm
Tested by: Peter Holm
Sponsored by: The FreeBSD Foundation
---
sys/ufs/ffs/ffs_subr.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c
index 4ffe0412ff69..e804dfa3d330 100644
--- a/sys/ufs/ffs/ffs_subr.c
+++ b/sys/ufs/ffs/ffs_subr.c
@@ -407,7 +407,7 @@ validate_sblock(struct fs *fs, int flags)
FCHK(powerof2(fs->fs_fsize), ==, 0, %jd);
FCHK(fs->fs_sbsize, >, SBLOCKSIZE, %jd);
FCHK(fs->fs_sbsize, <, (signed)sizeof(struct fs), %jd);
- FCHK(fs->fs_sbsize % fs->fs_fsize, !=, 0, %jd);
+ FCHK(fs->fs_sbsize % dbtob(1), !=, 0, %jd);
FCHK(fs->fs_fpg, <, 3 * fs->fs_frag, %jd);
FCHK(fs->fs_ncg, <, 1, %jd);
FCHK(fs->fs_fsbtodb, !=, ILOG2(fs->fs_fsize / sectorsize), %jd);
@@ -503,7 +503,7 @@ validate_sblock(struct fs *fs, int flags)
*/
if (error)
return (error);
- FCHK(fs->fs_sbsize % fs->fs_fsize, !=, 0, %jd);
+ FCHK(fs->fs_sbsize % dbtob(1), !=, 0, %jd);
FCHK(fs->fs_ipg % fs->fs_inopb, !=, 0, %jd);
FCHK(fs->fs_sblkno, !=, roundup(
howmany(fs->fs_sblockloc + SBLOCKSIZE, fs->fs_fsize),