git: 0fc13be84735 - stable/13 - Additional validity checking in newfs(8).
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 19 May 2023 23:54:23 UTC
The branch stable/13 has been updated by mckusick:
URL: https://cgit.FreeBSD.org/src/commit/?id=0fc13be8473505e98e9103467fe363db627051e1
commit 0fc13be8473505e98e9103467fe363db627051e1
Author: Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2023-04-29 19:49:50 +0000
Commit: Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2023-05-19 22:43:37 +0000
Additional validity checking in newfs(8).
(cherry picked from commit 62dc21b10731bdba26dafeb51640c2048a3344a0)
---
sbin/newfs/mkfs.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index 3d19fc88fd79..fa00445baea8 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -332,6 +332,7 @@ restart:
* can put into each cylinder group. If this is too big, we reduce
* the density until it fits.
*/
+retry:
maxinum = (((int64_t)(1)) << 32) - INOPB(&sblock);
minfragsperinode = 1 + fssize / maxinum;
if (density == 0) {
@@ -663,6 +664,21 @@ restart:
pp->p_frag = sblock.fs_frag;
pp->p_cpg = sblock.fs_fpg;
}
+ /*
+ * This should NOT happen. If it does complain loudly and
+ * take evasive action.
+ */
+ if ((int32_t)CGSIZE(&sblock) > sblock.fs_bsize) {
+ printf("INTERNAL ERROR: ipg %d, fpg %d, contigsumsize %d, ",
+ sblock.fs_ipg, sblock.fs_fpg, sblock.fs_contigsumsize);
+ printf("old_cpg %d, size_cg %jd, CGSIZE %jd\n",
+ sblock.fs_old_cpg, sizeof(struct cg), CGSIZE(&sblock));
+ printf("Please file a FreeBSD bug report and include this "
+ "output\n");
+ maxblkspercg = fragstoblks(&sblock, sblock.fs_fpg) - 1;
+ density = 0;
+ goto retry;
+ }
}
/*