NetBSD Problem Report #39264

From simonb@thistledown.com.au  Fri Aug  1 15:50:41 2008
Return-Path: <simonb@thistledown.com.au>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id EDB9763B975
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  1 Aug 2008 15:50:40 +0000 (UTC)
Message-Id: <20080801155039.0AF07AFD04@thoreau.thistledown.com.au>
Date: Sat,  2 Aug 2008 01:50:39 +1000 (EST)
From: Simon Burge <simonb@NetBSD.org>
Reply-To: Simon Burge <simonb@NetBSD.org>
To: gnats-bugs@gnats.NetBSD.org
Subject: newfs can create a filesystem with > 2^31 inodes
X-Send-Pr-Version: 3.95

>Number:         39264
>Category:       bin
>Synopsis:       newfs can create a filesystem with > 2^31 inodes
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 01 15:55:01 +0000 2008
>Last-Modified:  Mon Aug 04 21:35:01 +0000 2008
>Originator:     Simon Burge
>Release:        Anything after Jan 2006?
>Organization:
>Environment:
	Architecture: any
	Machine: any
>Description:
	Newfs can create a filesystem with > 2^31 inodes, despite this
	comment in mkfs.c:

	/* Even UFS2 limits number of inodes to 2^31 (fs_ipg is int32_t) */

>How-To-Repeat:
	Make a large filesystem with small -i value, mount, and type
	"df -i" on a netbsd-4 system and notice negative number of
	inodes (I think -current prints as unsigned, so it's harder to
	tell if you've overflowed).  The same newfs params run against
	an empty file:

test# touch foo
test# newfs -F -O2 -f 4k -b 32k -i 8k -N -s 46837568992 foo
foo: 22869906.7MB (46837568992 sectors) block size 32768, fragment size 4096
	using 33514 cylinder groups of 682.41MB, 21837 blks, 64128 inodes.

	show 33514 * 64128 = 2149185792 inodes, which is 1702144 more than
	2^31.

>Fix:
	Not sure.  We're overflowing with:

		inodes_per_cg = ((inodeblks - 1) / ncg + 1) * INOPB(&sblock);

	I'm not sure of the logic for the -1/+1 here.  Just using

		inodes_per_cg = inodeblks / ncg * INOPB(&sblock);

	gives a total of 2145216000 inodes, 2267648 under 2^31...

>Audit-Trail:
From: David Laight <david@l8s.co.uk>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/39264: newfs can create a filesystem with > 2^31 inodes
Date: Mon, 4 Aug 2008 22:30:28 +0100

 On Fri, Aug 01, 2008 at 03:55:01PM +0000, Simon Burge wrote:
 > >Number:         39264
 > >Synopsis:       newfs can create a filesystem with > 2^31 inodes
 ...
 > 	Newfs can create a filesystem with > 2^31 inodes, despite this
 > 	comment in mkfs.c:
 ...
 > 	Not sure.  We're overflowing with:
 > 		inodes_per_cg = ((inodeblks - 1) / ncg + 1) * INOPB(&sblock);
 >
 > 	I'm not sure of the logic for the -1/+1 here.
 ...
 It is there to round up the division.
 The same as (inodeblks + (ncg - 1)) / ncg would do.
 If you have asked newfs to create a filesystem with a specific number of
 inodes then it is needed in order to get at least the required number.

 	David

 -- 
 David Laight: david@l8s.co.uk

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.