NetBSD Problem Report #1145

From gnats  Tue Jun 20 05:05:30 1995
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.pc.cs.cmu.edu (8.6.11/8.6.10) with ESMTP id FAA25829 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Tue, 20 Jun 1995 05:05:24 -0400
Message-Id: <199506111826.UAA01566@rtfm.imf.unit.no>
Date: Sun, 11 Jun 1995 20:26:51 +0200
From: Arne Henrik Juul <arnej@imf.unit.no>
Reply-To: arnej@imf.unit.no
To: gnats-bugs@NetBSD.ORG
Subject: umount & df may panic NetBSD
X-Send-Pr-Version: 3.2

>Number:         1145
>Category:       kern
>Synopsis:       umount & df may panic NetBSD
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    fvdl
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 20 05:20:10 +0000 1995
>Closed-Date:    Wed Feb 26 04:46:28 +0000 2003
>Last-Modified:  Wed Feb 26 04:46:28 +0000 2003
>Originator:     Arne H. Juul
>Release:        1.0A
>Organization:
	University of Trondheim, Norway
>Environment:

System: NetBSD rtfm.imf.unit.no 1.0A NetBSD 1.0A (RTFM) #1: Sun Jun 11 18:53:58 MET DST 1995 root@rtfm.imf.unit.no:/usr/src/sys/arch/i386/compile/RTFM i386

	-current as of 9 Jun 1995

>Description:
	If you run 'df' (or any program that uses getfsstat) while
	an 'umount' is in progress the system may crash. This will
	probably mostly happen when it's a NFS file system, but could
	possibly also happen with local file systems.
>How-To-Repeat:
	: If your /usr/src is NFS-mounted :
	while true; do
		mount /usr/src; ls -la /usr/src/lib/Makefile;
		umount /usr/src; sleep 1;
	done &
	while :; do df; done
>Fix:
	The following patch should fix the problem. At least I am no
	longer able to provoke it with the above commands.
--- vfs_syscalls.c	Fri Jun  2 12:06:46 1995
+++ vfs_syscalls.c.min	Sun Jun 11 20:06:40 1995
@@ -547,7 +547,6 @@
 	sfsp = (caddr_t)SCARG(uap, buf);
 	for (count = 0,
 	     mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) {
-		nmp = mp->mnt_list.cqe_next;
 		if (sfsp && count < maxcount &&
 		    ((mp->mnt_flag & MNT_MLOCK) == 0)) {
 			sp = &mp->mnt_stat;
@@ -564,6 +563,7 @@
 				return (error);
 			sfsp += sizeof(*sp);
 		}
+		nmp = mp->mnt_list.cqe_next;
 		count++;
 	}
 	if (sfsp && count > maxcount)
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: cgd 
State-Changed-When: Tue Jun 20 06:56:56 EDT 1995 
State-Changed-Why:  
see below. 
Responsible-Changed-From-To: kern-bug-people->fvdl 
Responsible-Changed-By: lukem 
Responsible-Changed-When: Mon Jun 25 14:01:43 PDT 2001 
Responsible-Changed-Why:  
Frank should be able to handle this 
State-Changed-From-To: analyzed->feedback 
State-Changed-By: soren 
State-Changed-When: Wed Aug 7 14:50:49 PDT 2002 
State-Changed-Why:  
This appears to have been fixed with the Lite2 import. 

From enami: 
I guess rev. 1.113 of vfs_syscalls.c already fixed this.  The problem 
was the pointer to next struct mount is cached into the variable `nmp' 
before doing any operations which may cause context switching 
(VFS_STATFS or copyout). 

Are you able to test this with -current or another recent version? 
Responsible-Changed-From-To: fvdl->cgd 
Responsible-Changed-By: darcy 
Responsible-Changed-When: Sun Feb 16 16:13:30 PST 2003 
Responsible-Changed-Why:  
Can you elaborate on your last comment and pass back to fvdl please. 
State-Changed-From-To: feedback->closed 
State-Changed-By: darcy 
State-Changed-When: Tue Feb 25 20:35:31 PST 2003 
State-Changed-Why:  
Looks like I misunderstood the order of comments.  Yes, it appears to be 
fixed.  I am running the test here and it is working perfectly.  In fact 
it appears to hesitate in the df fome time to time and I assume that that 
when the call is blocked during the umount.  I will leave it running 
overnight and if there is a problem I will reopen this PR but it looks 
like it has been fixed. 


Responsible-Changed-From-To: cgd->fvdl 
Responsible-Changed-By: darcy 
Responsible-Changed-When: Tue Feb 25 20:35:31 PST 2003 
Responsible-Changed-Why:  
I moved it away from him in error in the first place. 
>Unformatted:



 proposed fix insufficieint and erroneous.  thinking about correct
 locking solution.
 	-- cgd

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.