Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Apr 1997 17:43:38 +0100 (BST)
From:      Doug Rabson <dfr@nlsystems.com>
To:        Tor Egge <Tor.Egge@idi.ntnu.no>
Cc:        dg@root.com, ponds!rivers@dg-rtp.dg.com, freebsd-hackers@FreeBSD.ORG
Subject:   Re: kern/3184: vnodes are used after they are freed. (dup alloc?)
Message-ID:  <Pine.BSF.3.95q.970404173819.8538D-100000@herring.nlsystems.com>
In-Reply-To: <199704041627.SAA07632@pat.idt.unit.no>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 4 Apr 1997, Tor Egge wrote:

> > I tried testing your fix this morning and the 0xdeadb stuff just caused
> > vget to fault a couple of minutes into my test (simultaneous rm -rf
> > largetree and cvs co src, both remote).
> 
> A different part of the Lite/2 commit removed an explicit check for
> the 0xdeadb stuff in vget. Perhaps the kludge is still needed there.
> 
> > 
> > This problem really has little to do with nfs_inactive.  What is
> > happening is a race between vgone and vget which would normally be solved
> > by the vnode locks.  Since NFS doesn't have vnode locks, the race
> > happens.
> 
> In my opinion, the problem has to do with marking objects as free and
> reusable while they are still in use. 
> 
> When the vnode is on the freelist, with 0 as v_usecount, and the
> vp->v_interlock is not locked, how should getnewvnode decide that the
> vnode is not reusable ?  VOP_ISLOCKED ? Not currently used in
> getnewvnode nor in vget.

The vnode in question is being recycled from VT_NFS to VT_UFS.
Getnewvnode picks a vnode of the free list and calls vgone to extract it
from the previous owner.  This calls VOP_LOCK(.., LK_DRAIN, ..) which is
intended to block until the vnode is inactive.

For vnodes which are not being recycled but just picked up from the cache,
there is no race but still either vget or its caller will lock the vnode
before using it for anything important.

> 
> > I am most of the way there in implementing the right solution for NFS
> > which is to used shared locks for NFS;  vgone can then use the lock
> > manager to wait for all the shared locks to drain before recycling the
> > vnode.
> 
> Good. 

My test is running...  Lets hope it passes this time :-).

--
Doug Rabson				Mail:  dfr@nlsystems.com
Nonlinear Systems Ltd.			Phone: +44 181 951 1891




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95q.970404173819.8538D-100000>