Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Oct 2003 09:01:03 -0800 (PST)
From:      Chris Vance <cvance@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 40680 for review
Message-ID:  <200310281701.h9SH13l4017500@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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]



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200310281701.h9SH13l4017500>