From owner-freebsd-current Sun Feb 10 11:30:32 2002 Delivered-To: freebsd-current@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 9CDDE37B404 for ; Sun, 10 Feb 2002 11:30:07 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id GAA28676; Mon, 11 Feb 2002 06:30:01 +1100 Date: Mon, 11 Feb 2002 06:32:48 +1100 (EST) From: Bruce Evans X-X-Sender: To: Julian Elischer Cc: Subject: Re: final ucred patch In-Reply-To: <3C66133F.43D243E0@elischer.org> Message-ID: <20020211060831.T9036-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > After comments by jhb and bde > > Index: i386/i386/trap.c > =================================================================== > RCS file: /home/ncvs/src/sys/i386/i386/trap.c,v > retrieving revision 1.211 > diff -u -r1.211 trap.c > --- i386/i386/trap.c 10 Jan 2002 11:49:54 -0000 1.211 > +++ i386/i386/trap.c 10 Feb 2002 00:52:58 -0000 > @@ -256,9 +256,19 @@ > sticks = td->td_kse->ke_sticks; > td->td_frame = &frame; > KASSERT(td->td_ucred == NULL, ("already have a ucred")); > - PROC_LOCK(p); > - td->td_ucred = crhold(p->p_ucred); > - PROC_UNLOCK(p); > + if (td->td_ucred != p->p_ucred) { > + if (td->td_ucred) { > + mtx_lock(&Giant); > + crfree(td->td_ucred); > + td->td_ucred = NULL; > + mtx_unlock(&Giant); See below about placement of this unlock. > + } > + if (p->p_ucred) { How can this be NULL? The old code didn't check. > + PROC_LOCK(p); > + td->td_ucred = crhold(p->p_ucred); > + PROC_UNLOCK(p); > + } > + } The inner block is large enough and repeated enough to turn into a function. > > switch (type) { > case T_PRIVINFLT: /* privileged instruction fault */ > @@ -644,10 +654,12 @@ > userret(td, &frame, sticks); > mtx_assert(&Giant, MA_NOTOWNED); > userout: > +#ifdef INVARIANTS > mtx_lock(&Giant); > crfree(td->td_ucred); > - mtx_unlock(&Giant); > td->td_ucred = NULL; > + mtx_unlock(&Giant); > +#endif > out: > return; > } I think moving the unlock is just an obfuscation. td_ucred isn't locked by Giant. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message