PERFORCE change 40680 for review

Chris Vance cvance at FreeBSD.org
Tue Oct 28 17:01:03 GMT 2003


http://perforce.freebsd.org/chv.cgi?CH=40680

Change 40680 by cvance at 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]
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list