NetBSD Problem Report #575

From gnats  Mon Nov 14 19:47:00 1994
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.cs.berkeley.edu (8.6.9/8.6.9) with ESMTP id TAA01323 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Mon, 14 Nov 1994 19:46:59 -0800
Message-Id: <199411142215.QAA13473@ss1.introl.com>
Date: Mon, 14 Nov 1994 16:15:33 -0600 (CST)
From: Tim Chase <tim@introl.com>
Reply-To: tim@introl.com
To: gnats-bugs@NetBSD.ORG
Subject: fsck doesn't handle bogus cg_iusedoff
X-Send-Pr-Version: 3.2

>Number:         575
>Category:       bin
>Synopsis:       fsck doesn't handle bogus cg_iusedoff
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 14 19:50:03 +0000 1994
>Closed-Date:    Tue Apr 14 07:10:19 +0000 1998
>Last-Modified:  Tue Apr 14 07:10:49 +0000 1998
>Originator:     Tim Chase
>Release:        1.0
>Organization:
Tim Chase		           Introl Corp. Milwaukee, WI USA
Email: tim@introl.com		   Phone: +1 (414) 327-7171
>Environment:
	<machine, os, target, libraries (multiple lines)>
System: NetBSD weasel 1.0 NetBSD 1.0 (TSC) #0: Sun Oct 23 12:24:20 CDT 1994 tim@weasel:/usr/src/sys/arch/i386/compile/TSC i386
Architecture: i386-netbsd

>Description:
	If the cg_iusedoff field of a CG is bogus (too large or negative)
	and the CG's magic number is valid, fsck will core dump in the pass5.

	The problem pops up in the following code in pass5.c RCS ID 1.6:

		if (bcmp(cg_inosused(newcg),
			 cg_inosused(cg), mapsize) != 0 &&
		    dofix(&idesc[1], "BLK(S) MISSING IN BIT MAPS")) {
			bcopy(cg_inosused(newcg), cg_inosused(cg),
			      (size_t)mapsize);
			cgdirty();
		}

	The cg_inosused(cg) can be to large for the bcopy.

>How-To-Repeat:
	Poke a large number like 1000000 into the cg_iusedoff field of
	an inode and fsck it.  Fsck will core dump even when the -n
	option is used.
>Fix:
	To fix the particular file system I was working on, I added a sanity check
	to the code that checks the CG's magic number.  Since I'm not sure of the
	legal range of values for this field, I can't say exactly how it should
	be checked.
>Release-Note:
>Audit-Trail:

Responsible-Changed-From-To: gnats-admin->bin-bug-people
Responsible-Changed-By: jtc
Responsible-Changed-When: Fri Feb 17 01:27:14 1995
Responsible-Changed-Why:
Misfiled.

State-Changed-From-To: open->feedback 
State-Changed-By: fair 
State-Changed-When: Mon Apr 13 23:58:52 PDT 1998 
State-Changed-Why:  
Examination of the fsck_ffs code leaves me a bit baffled as to how this 
could happen. The code now checks the CG_MAGIC in all macro references to 
the Cylinder Group, and all the bcopy references are now memmove's. The 
RCSID is now 1.19 - lots of revs since 1.6. This leaves me with a simple 
question: with the PR author's "work around" now standard practice, does 
this problem still happen with NetBSD 1.3.1? 
State-Changed-From-To: feedback->closed 
State-Changed-By: fair 
State-Changed-When: Tue Apr 14 00:10:19 PDT 1998 
State-Changed-Why:  
The user has vanished. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.