From owner-freebsd-bugs@FreeBSD.ORG Tue Feb 8 10:32:02 2005 Return-Path: Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C286B16A4D5; Tue, 8 Feb 2005 10:32:02 +0000 (GMT) Received: from mailout2.pacific.net.au (mailout2.pacific.net.au [61.8.0.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id DB6F443D5A; Tue, 8 Feb 2005 10:32:01 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.0.87])j18AVjHn010932; Tue, 8 Feb 2005 21:31:45 +1100 Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) j18AVf8w026801; Tue, 8 Feb 2005 21:31:43 +1100 Date: Tue, 8 Feb 2005 21:31:40 +1100 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Peter Much In-Reply-To: <200502062205.j16M5tDW007999@gate.oper.dinoex.org> Message-ID: <20050208210132.X22354@delplex.bde.org> References: <200502062205.j16M5tDW007999@gate.oper.dinoex.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-bugs@FreeBSD.org cc: FreeBSD-gnats-submit@FreeBSD.org Subject: Re: kern/77181: newfs -g largevalue, mkdir, panic X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Feb 2005 10:32:02 -0000 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