Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Aug 2002 07:30:05 -0700 (PDT)
From:      David Schultz <dschultz@uclink.Berkeley.EDU>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/41145: newfs core dump (args : -b 262144 -f 32768)
Message-ID:  <200208261430.g7QEU5dU051593@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/41145; it has been noted by GNATS.

From: David Schultz <dschultz@uclink.Berkeley.EDU>
To: Bruce Evans <bde@zeta.org.au>
Cc: freebsd-gnats-submit@FreeBSD.org, ijliao@csie.nctu.edu.tw
Subject: Re: bin/41145: newfs core dump (args : -b 262144 -f 32768)
Date: Mon, 26 Aug 2002 07:23:53 -0700

 > There is a kernel limit of MAXBSIZE = 65536, so ufs filesystems with
 > a block size larger than 65536 cannot be mounted in FreeBSD.  newfs
 > and fsck_ffs use the same limit, so the cannot create or check such
 > filesystems.  newfs tends to die trying since it doesn't check for the
 > limit being exceeded and uses data structures that depend on it not
 > being exceeded.  fsck_ffs tends to just not recognise such filesystems,
 > since it checks the limit as part of its sanity check/search for the
 > superblock.
 
 There appears to be a deficiency in newfs's bounds checking code.
 The following (untested) patch improves the bounds checking,
 squelches a duplicate `increasing block size' diagnostic, and
 tweaks the docs.
 
 Note that it is still possible to kill newfs if you try hard,
 e.g. by specifying an unreasonable sector size.  But
 realistically, nobody fiddles with the sector size anyway, so
 carefully checking the block and fragment sizes should be
 sufficient to handle silly mistakes.  IMHO, the code would be much
 more maintainable if it quit when it encountered an invalid
 parameter, instead of trying to magically adjust everything.
 
 
 Index: mkfs.c
 ===================================================================
 RCS file: /home/ncvs/src/sbin/newfs/mkfs.c,v
 retrieving revision 1.61
 diff -u -r1.61 mkfs.c
 --- mkfs.c	2002/08/21 18:11:21	1.61
 +++ mkfs.c	2002/08/26 14:10:45
 @@ -193,7 +193,12 @@
  		    sblock.fs_fsize, sectorsize);
  		sblock.fs_fsize = sectorsize;
  	}
 -	if (sblock.fs_bsize < MINBSIZE) {
 +        if (sblock.fs_fsize > MAXBSIZE) {
 +		printf("decreasing fragment size from %d to MAXBSIZE (%d)\n",
 +		    sblock.fs_fsize, MAXBSIZE);
 +		sblock.fs_fsize = MAXBSIZE;
 +        }
 +	if (sblock.fs_bsize < MINBSIZE && sblock.fs_fsize <= MINBSIZE) {
  		printf("increasing block size from %d to minimum (%d)\n",
  		    sblock.fs_bsize, MINBSIZE);
  		sblock.fs_bsize = MINBSIZE;
 @@ -203,6 +208,11 @@
  		    sblock.fs_bsize, sblock.fs_fsize);
  		sblock.fs_bsize = sblock.fs_fsize;
  	}
 +	if (sblock.fs_bsize > MAXBSIZE) {
 +                printf("decreasing block size from %d to MAXBSIZE (%d)\n",
 +                    sblock.fs_bsize, MAXBSIZE);
 +                sblock.fs_bsize = MAXBSIZE;
 +        }
  	if (sblock.fs_fsize * MAXFRAG < sblock.fs_bsize) {
  		printf(
  		"increasing fragment size from %d to block size / %d (%d)\n",
 Index: newfs.8
 ===================================================================
 RCS file: /home/ncvs/src/sbin/newfs/newfs.8,v
 retrieving revision 1.55
 diff -u -r1.55 newfs.8
 --- newfs.8	2002/08/21 18:11:21	1.55
 +++ newfs.8	2002/08/26 14:10:45
 @@ -102,7 +102,7 @@
  The block size of the file system, in bytes.
  It must be a power of 2.
  The
 -default size is 16384 bytes, and the smallest allowable size is 4096 bytes.
 +default size is 16384 bytes, and the allowable range is 4096 to 65536 bytes.
  The optimal block:fragment ratio is 8:1.
  Other ratios are possible, but are not recommended,
  and may produce poor results.
 Index: newfs.c
 ===================================================================
 RCS file: /home/ncvs/src/sbin/newfs/newfs.c,v
 retrieving revision 1.63
 diff -u -r1.63 newfs.c
 --- newfs.c	2002/08/21 18:11:21	1.63
 +++ newfs.c	2002/08/26 14:10:45
 @@ -186,7 +186,8 @@
  				    optarg);
  			break;
  		case 'b':
 -			if ((bsize = atoi(optarg)) < MINBSIZE)
 +			if ((bsize = atoi(optarg)) < MINBSIZE ||
 +			    bsize > MAXBSIZE)
  				errx(1, "%s: bad block size", optarg);
  			break;
  		case 'c':
 @@ -204,7 +205,7 @@
  				    optarg);
  			break;
  		case 'f':
 -			if ((fsize = atoi(optarg)) <= 0)
 +			if ((fsize = atoi(optarg)) <= 0 || fsize > MAXBSIZE)
  				errx(1, "%s: bad fragment size", optarg);
  			break;
  		case 'g':
 

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200208261430.g7QEU5dU051593>