From owner-p4-projects Sat May 18 14:54:14 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A007237B404; Sat, 18 May 2002 14:54:05 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 123E937B409 for ; Sat, 18 May 2002 14:54:03 -0700 (PDT) Received: (from perforce@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g4ILs2046258 for perforce@freebsd.org; Sat, 18 May 2002 14:54:02 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sat, 18 May 2002 14:54:02 -0700 (PDT) Message-Id: <200205182154.g4ILs2046258@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson Subject: PERFORCE change 11490 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=11490 Change 11490 by rwatson@rwatson_curry on 2002/05/18 14:53:42 Re-structure __mac_set_proc() so that it does process locking, and grabs Giant a little later. This actually appears to simplify things a bit, interestingly. Affected files ... ... //depot/projects/trustedbsd/mac/sys/kern/kern_mac.c#145 edit Differences ... ==== //depot/projects/trustedbsd/mac/sys/kern/kern_mac.c#145 (text+ko) ==== @@ -1641,7 +1641,6 @@ /* * MPSAFE - * XXX Proc Locking */ int __mac_set_proc(struct thread *td, struct __mac_set_proc_args *uap) @@ -1650,35 +1649,34 @@ struct mac newlabel; int error; - mtx_lock(&Giant); - oldcred = td->td_proc->p_ucred; - newcred = crdup(td->td_proc->p_ucred); - if (newcred == NULL) { - error = ENOMEM; - goto out; - } - + newcred = crget(); error = copyin(SCARG(uap, mac_p), &newlabel, sizeof(newlabel)); - if (error) { + if (error) { crfree(newcred); - goto out; + return (error); } + mtx_lock(&Giant); + PROC_LOCK(td->td_proc); + oldcred = td->td_proc->p_ucred; + error = mac_cred_check_relabel_subject(oldcred, &newlabel); if (error) { + PROC_UNLOCK(td->td_proc); crfree(newcred); - goto out; + mtx_unlock(&Giant); + return (error); } setsugid(td->td_proc); mac_relabel_subject(newcred, &newlabel); td->td_proc->p_ucred = newcred; + + PROC_UNLOCK(td->td_proc); crfree(oldcred); - -out: mtx_unlock(&Giant); - return (error); + return (0); } /* To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message