From owner-p4-projects@FreeBSD.ORG Tue Oct 28 09:01:09 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3412916A4E6; Tue, 28 Oct 2003 09:01:09 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C6AFC16A4DB for ; Tue, 28 Oct 2003 09:01:08 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4C45A4404B for ; Tue, 28 Oct 2003 09:01:04 -0800 (PST) (envelope-from cvance@nailabs.com) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id h9SH14XJ017504 for ; Tue, 28 Oct 2003 09:01:04 -0800 (PST) (envelope-from cvance@nailabs.com) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id h9SH13l4017500 for perforce@freebsd.org; Tue, 28 Oct 2003 09:01:03 -0800 (PST) (envelope-from cvance@nailabs.com) Date: Tue, 28 Oct 2003 09:01:03 -0800 (PST) Message-Id: <200310281701.h9SH13l4017500@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to cvance@nailabs.com using -f From: Chris Vance To: Perforce Change Reviews Subject: PERFORCE change 40680 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Oct 2003 17:01:09 -0000 http://perforce.freebsd.org/chv.cgi?CH=40680 Change 40680 by cvance@cvance_g4 on 2003/10/28 09:00:59 Bug Fix. Mac labels are initialized in crget, but the newly allocated labels will get over-writen by a normal struct copy. Only copy some of the fields from the ucred. This code is a bit odd, but this is how FreeBSD 5.1 does it. Affected files ... .. //depot/projects/trustedbsd/sedarwin/apsl/xnu/bsd/kern/kern_prot.c#5 edit .. //depot/projects/trustedbsd/sedarwin/apsl/xnu/bsd/sys/ucred.h#3 edit Differences ... ==== //depot/projects/trustedbsd/sedarwin/apsl/xnu/bsd/kern/kern_prot.c#5 (text+ko) ==== @@ -702,12 +702,16 @@ if (cr->cr_ref == 1) return (cr); newcr = crget(); +#ifdef MAC + bcopy(&cr->cr_startcopy, &newcr->cr_startcopy, + (unsigned)((caddr_t)&cr->cr_endcopy - + (caddr_t)&cr->cr_startcopy)); + mac_create_cred(cr, newcr); +#else *newcr = *cr; +#endif crfree(cr); newcr->cr_ref = 1; -#ifdef MAC - mac_create_cred(cr, newcr); -#endif return (newcr); } @@ -725,11 +729,15 @@ panic("crdup"); #endif newcr = crget(); - *newcr = *cr; - newcr->cr_ref = 1; #ifdef MAC + bcopy(&cr->cr_startcopy, &newcr->cr_startcopy, + (unsigned)((caddr_t)&cr->cr_endcopy - + (caddr_t)&cr->cr_startcopy)); mac_create_cred(cr, newcr); +#else + *newcr = *cr; #endif + newcr->cr_ref = 1; return (newcr); } ==== //depot/projects/trustedbsd/sedarwin/apsl/xnu/bsd/sys/ucred.h#3 (text+ko) ==== @@ -68,9 +68,11 @@ */ struct ucred { u_long cr_ref; /* reference count */ +#define cr_startcopy cr_uid uid_t cr_uid; /* effective user id */ short cr_ngroups; /* number of groups */ gid_t cr_groups[NGROUPS]; /* groups */ +#define cr_endcopy cr_label struct label cr_label; /* MAC label */ }; #define cr_gid cr_groups[0]