Subject: Re: kern/3003
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Jeff Ito <ijk@speakeasy.net>
List: netbsd-bugs
Date: 03/21/2006 12:30:02
The following reply was made to PR kern/3003; it has been noted by GNATS.

From: Jeff Ito <ijk@speakeasy.net>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/3003
Date: Tue, 21 Mar 2006 07:25:38 -0500

 I am uncertain about any locking that may need to take place here. 
 
 But the patch in the PR causes an "unlocking unlocked vnode" panic.
 
 I've adapted this change from FreeBSD code and added the second
 condition to make sure it catches both above and below (and replace)
 union scenarios.
 
 Index: union_vfsops.c
 ===================================================================
 RCS file: /export/cvs/netbsd/src/sys/fs/union/union_vfsops.c,v
 retrieving revision 1.33
 diff -u -r1.33 union_vfsops.c
 --- union_vfsops.c      20 Mar 2006 19:54:15 -0000      1.33
 +++ union_vfsops.c      21 Mar 2006 12:20:53 -0000
 @@ -172,6 +172,12 @@
 
         upperrootvp = ndp->ni_vp;
 
 +       if ((upperrootvp == VTOUNION(lowerrootvp)->un_uppervp) ||
 +           (upperrootvp == VTOUNION(lowerrootvp)->un_lowervp)) {
 +               error = EDEADLK;
 +               goto bad;
 +       }
 +
         if (upperrootvp->v_type != VDIR) {
                 error = EINVAL;
                 goto bad;