Subject: VXLOCK race?
To: None <tech-kern@NetBSD.ORG>
From: Robert Black <r.black@ic.ac.uk>
List: tech-kern
Date: 05/09/1996 17:28:11
Hello,

I have been browsing through kern/vfs_subr.c trying to figure out what various
things do. One thing which is worrying me is the following:

At the start of vgone()...

        if (vp->v_flag & VXLOCK) {
                vp->v_flag |= VXWANT;
                tsleep((caddr_t)vp, PINOD, "vgone", 0);
                return;
        }
        /*
         * Clean out the filesystem specific data.
         */
        vclean(vp, DOCLOSE);


and in vclean()...

        /*
         * Prevent the vnode from being recycled or
         * brought into use while we clean it out.
         */
        if (vp->v_flag & VXLOCK)
                panic("vclean: deadlock");
        vp->v_flag |= VXLOCK;
        /*
         * Clean out any buffers associated with the vnode.
         */


as far as I can see this is all at spl0 - I'm probably missing something
important but this looks horribly like a potential race condition to me. Could
someone please explain to me why it isn't, or if it is, why it isn't important.
As far as I can see this could lead to junk being written via dangling
pointers.

Cheers

Rob Black

--