From owner-p4-projects@FreeBSD.ORG Thu Dec 2 22:07:52 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 026D4106567A; Thu, 2 Dec 2010 22:07:52 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B94491065679 for ; Thu, 2 Dec 2010 22:07:51 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id A61468FC08 for ; Thu, 2 Dec 2010 22:07:51 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id oB2M7pek035438 for ; Thu, 2 Dec 2010 22:07:51 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id oB2M7plN035435 for perforce@freebsd.org; Thu, 2 Dec 2010 22:07:51 GMT (envelope-from jhb@freebsd.org) Date: Thu, 2 Dec 2010 22:07:51 GMT Message-Id: <201012022207.oB2M7plN035435@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 186576 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Dec 2010 22:07:52 -0000 http://p4web.freebsd.org/@@186576?ac=10 Change 186576 by jhb@jhb_jhbbsd on 2010/12/02 22:06:51 Revert the process back to an exec'ing thread's credentials. Affected files ... .. //depot/projects/smpng/sys/kern/kern_exec.c#135 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_exec.c#135 (text+ko) ==== @@ -582,12 +582,23 @@ VREF(binvp); /* + * Force the process to use this thread's credentials to avoid + * a race where another thread changed this process' credentials + * while we were waiting for all other threads to stop. + */ + PROC_LOCK(p); + if (td->td_ucred != p->p_ucred) { + oldcred = p->p_ucred; + p->p_ucred = crhold(td->td_ucred); + crfree(oldcred); + } + + /* * For security and other reasons, signal handlers cannot * be shared after an exec. The new process gets a copy of the old * handlers. In execsigs(), the new process will have its signals * reset. */ - PROC_LOCK(p); oldcred = crcopysafe(p, newcred); if (sigacts_shared(p->p_sigacts)) { oldsigacts = p->p_sigacts; @@ -599,16 +610,6 @@ } else oldsigacts = NULL; - /* - * Ensure that this thread's credentials match the proces - * credentials. - */ - if (td->td_ucred != p->p_ucred) { - oldcred = td->td_ucred; - td->td_ucred = crhold(p->p_ucred); - crfree(oldcred); - } - /* Stop profiling */ stopprofclock(p);