summaryrefslogtreecommitdiff
path: root/sbin/newfs
diff options
context:
space:
mode:
authorGrigoriy Orlov <gluk@cvs.openbsd.org>2001-04-13 02:39:07 +0000
committerGrigoriy Orlov <gluk@cvs.openbsd.org>2001-04-13 02:39:07 +0000
commit9bff9fb87213262bc5d1afd9333ad540d9e99c54 (patch)
tree5797ca5b1e346d54d4606ff7293258862d4b223b /sbin/newfs
parent5af2b89b71f9bb495e071539ea9548813c712c7c (diff)
Fix overflow in superblock. From FreeBSD.
FreeBSD's log: > The ffs superblock includes a 128-byte region for use by temporary > in-core pointers to summary information. An array in this region > (fs_csp) could overflow on filesystems with a very large number of > cylinder groups (~16000 on i386 with 8k blocks). When this happens, > other fields in the superblock get corrupted, and fsck refuses to > check the filesystem. > > Solve this problem by replacing the fs_csp array in 'struct fs' > with a single pointer, and add padding to keep the length of the > 128-byte region fixed. Update the kernel and userland utilities > to use just this single pointer. > > With this change, the kernel no longer makes use of the superblock > fields 'fs_csshift' and 'fs_csmask'. Add a comment to newfs/mkfs.c > to indicate that these fields must be calculated for compatibility > with older kernels. art@ ok.
Diffstat (limited to 'sbin/newfs')
-rw-r--r--sbin/newfs/mkfs.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index 2368e523f98..aacecf48349 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkfs.c,v 1.16 2001/04/04 22:06:38 gluk Exp $ */
+/* $OpenBSD: mkfs.c,v 1.17 2001/04/13 02:39:06 gluk Exp $ */
/* $NetBSD: mkfs.c,v 1.25 1995/06/18 21:35:38 cgd Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)mkfs.c 8.3 (Berkeley) 2/3/94";
#else
-static char rcsid[] = "$OpenBSD: mkfs.c,v 1.16 2001/04/04 22:06:38 gluk Exp $";
+static char rcsid[] = "$OpenBSD: mkfs.c,v 1.17 2001/04/13 02:39:06 gluk Exp $";
#endif
#endif /* not lint */
@@ -576,6 +576,12 @@ next:
sblock.fs_csaddr = cgdmin(&sblock, 0);
sblock.fs_cssize =
fragroundup(&sblock, sblock.fs_ncg * sizeof(struct csum));
+
+ /*
+ * The superblock fields 'fs_csmask' and 'fs_csshift' are no
+ * longer used. However, we still initialise them so that the
+ * filesystem remains compatible with old kernels.
+ */
i = sblock.fs_bsize / sizeof(struct csum);
sblock.fs_csmask = ~(i - 1);
for (sblock.fs_csshift = 0; i > 1; i >>= 1)