From owner-freebsd-bugs@FreeBSD.ORG Tue Feb 8 10:40:36 2005 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E50C616A4CE for ; Tue, 8 Feb 2005 10:40:36 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id A406343D3F for ; Tue, 8 Feb 2005 10:40:36 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.1/8.13.1) with ESMTP id j18AeaR3061374 for ; Tue, 8 Feb 2005 10:40:36 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.1/8.13.1/Submit) id j18Aea36061373; Tue, 8 Feb 2005 10:40:36 GMT (envelope-from gnats) Date: Tue, 8 Feb 2005 10:40:36 GMT Message-Id: <200502081040.j18Aea36061373@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Bruce Evans Subject: Re: kern/77181: newfs -g largevalue, mkdir, panic X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Bruce Evans List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Feb 2005 10:40:37 -0000 The following reply was made to PR kern/77181; it has been noted by GNATS. From: Bruce Evans To: Peter Much Cc: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org Subject: Re: kern/77181: newfs -g largevalue, mkdir, panic Date: Tue, 8 Feb 2005 21:31:40 +1100 (EST) On Sun, 6 Feb 2005, Peter Much wrote: > >Description: > > create 5G filesystem on gvinum drive (single drive, no mirror, no stripe). > newfs -g 104857600 -U > mount it, and mkdir some directories. > panic, integer divide fault. There is another PR or two about this. I have the following note about fixing it someday: %%% Index: ffs_alloc.c =================================================================== RCS file: /home/ncvs/src/sys/ufs/ffs/ffs_alloc.c,v retrieving revision 1.121 diff -u -2 -r1.121 ffs_alloc.c --- ffs_alloc.c 16 Jun 2004 09:47:25 -0000 1.121 +++ ffs_alloc.c 28 Oct 2004 15:12:47 -0000 @@ -964,4 +991,11 @@ minbfree = 1; cgsize = fs->fs_fsize * fs->fs_fpg; + /* + * XXX the following multiplication can overflow, since newfs can + * be abused to set fs_avgfilesize and fs_avgfpdir to preposterous + * values. For the particular preposterous values of (64M, 64), + * the multiplication overflows to 0 and then dirsize = 0 sometimes + * causes division by 0. + */ dirsize = fs->fs_avgfilesize * fs->fs_avgfpdir; curdirsize = avgndir ? (cgsize - avgbfree * fs->fs_bsize) / avgndir : 0; %%% This should be fixed primarily in newfs. newfs should refuse to create file systems that cannot work. It already limits many parameters. Something (fsck or the kernel or both) should check for and fix such parameters, since they may occur in old file systems. > >Fix: > > Now I dont use the -g option. Actually I just found it and > thought, lets try it out - have not yet researched what it > functionally does. And I know that my value is way large and > is not in good match with the blocksize. Another fix is to not use the -g option (or -h option) :-). I've never used them. These options came with the new `dirpref' algorithm on 2001/04/10 (to help control that algorithm), so I guess there has not been much use of them. See the cvs log message for newfs.c 1.35 for vastly many more details than are in the man page. > (And now I put kerneldebugger back into my config - btw, > there seems no longer anywhere the nice explanations for such > options as was in the former LINT file - where one could > easily pick what could be eventually needed.) Try the NOTES file. Bruce