NetBSD Problem Report #1512

From gnats  Tue Sep 26 00:37:27 1995
Received: from bloom-beacon.MIT.EDU (brnstndkramden.acf.nyu.edu@BLOOM-BEACON.MIT.EDU [18.181.0.26]) by sun-lamp.pc.cs.cmu.edu (8.6.11/8.6.10) with ESMTP id AAA07725 for <gnats-bugs@gnats.netbsd.org>; Tue, 26 Sep 1995 00:37:26 -0400
Message-Id: <199509260401.AAA01138@pattern.arlington.ma.us>
Date: Tue, 26 Sep 1995 00:01:21 -0400
From: John Kohl <jtk@kolvir.arlington.ma.us>
Reply-To: jtk@kolvir.arlington.ma.us
To: gnats-bugs@gnats.netbsd.org
Subject: vnode device driver fails to lock properly, causing union failures
X-Send-Pr-Version: 3.95

>Number:         1512
>Category:       kern
>Synopsis:       vnode device driver fails to lock properly, causing union failures
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 26 00:50:01 +0000 1995
>Closed-Date:    Mon Oct 09 17:14:39 +0000 1995
>Last-Modified:  Mon Oct 09 17:15:35 +0000 1995
>Originator:     John Kohl
>Release:        NetBSD-current as of about 1995/09/22
>Organization:
NetBSD Kernel Hackers `R` Us
>Environment:

System: NetBSD pattern 1.0A NetBSD 1.0A (PATTERN) #131: Mon Sep 25 23:51:33 EDT 1995 jtk@pattern:/u1/NetBSD-current/src/sys/arch/i386/compile/PATTERN i386


>Description:
	The union filesystem requires its callers to properly
lock/unlock before calling VOP_* which use locked arguments.  the vnode
driver code doesn't do that.
>How-To-Repeat:
	On a DIAGNOSTIC kernel, mount a union FS over /usr/src, go to
/usr/src/distrib/i386/floppies/inst and make inst-10A.fs.
Then try to unmount the union FS and watch it panic with a locking error
(the locking process will no longer exist).

>Fix:
This seems to do the trick.  I found another locking violation inside
vnd.c at the same time.

===================================================================
RCS file: RCS/vnd.c,v
retrieving revision 1.1
diff -c -r1.1 vnd.c
*** vnd.c	1995/09/26 03:49:05	1.1
--- sys/dev/vnd.c	1995/09/26 03:51:02
***************
*** 228,234 ****
--- 228,236 ----
  		int off, s, nra;

  		nra = 0;
+ 		VOP_LOCK(vnd->sc_vp);
  		error = VOP_BMAP(vnd->sc_vp, bn / bsize, &vp, &nbn, &nra);
+ 		VOP_UNLOCK(vnd->sc_vp);
  		if (error == 0 && (long)nbn == -1)
  			error = EIO;
  #ifdef DEBUG
***************
*** 508,514 ****
--- 510,518 ----
  	auio.uio_rw = UIO_READ;
  	auio.uio_segflg = UIO_SYSSPACE;
  	auio.uio_resid = aiov.iov_len;
+ 	VOP_LOCK(vnd->sc_vp);
  	error = VOP_READ(vnd->sc_vp, &auio, 0, vnd->sc_cred);
+ 	VOP_UNLOCK(vnd->sc_vp);

  	free(tmpbuf, M_TEMP);
  	return (error);

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: thorpej 
State-Changed-When: Tue Sep 26 16:55:59 PDT 1995 
State-Changed-Why:  
Looked at vnd and ccd.  I believe that this is the correct fix, and, indeed 
the ccd has this problem in a place or two as well.  Once I've stress-tested 
both, I'll commit the suggested fix to vnd.c and changes in the same spirit 
to ccd.c. 
State-Changed-From-To: analyzed->closed 
State-Changed-By: mycroft 
State-Changed-When: Mon Oct 9 13:14:39 EDT 1995 
State-Changed-Why:  
Fixed. 
>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.