PERFORCE change 229527 for review
Robert Watson
rwatson at FreeBSD.org
Sat Jun 8 22:17:10 UTC 2013
http://p4web.freebsd.org/@@229527?ac=10
Change 229527 by rwatson at rwatson_cinnamon on 2013/06/08 22:17:01
Commit work-in-progress assertions in kern_prot.c, which check
that MAC checks happen before credential changes, and that P_SUGID
is set properly afterwards.
Affected files ...
.. //depot/projects/ctsrd/tesla/src/sys/kern/kern_prot.c#2 edit
Differences ...
==== //depot/projects/ctsrd/tesla/src/sys/kern/kern_prot.c#2 (text+ko) ====
@@ -71,6 +71,10 @@
#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
+#include <tesla.h>
+#include <tesla-macros.h>
+#include <sys/tesla-kernel.h>
+
#ifdef REGRESSION
FEATURE(regression,
"Kernel support for interfaces necessary for regression testing (SECURITY RISK!)");
@@ -2142,8 +2146,19 @@
void
change_euid(struct ucred *newcred, struct uidinfo *euip)
{
+ uid_t euid;
+
+
+ euid = euip->ui_uid;
+ TESLA_SYSCALL(
+ previously(mac_cred_check_setuid(ANY(ptr), euid) == 0) ||
+ previously(mac_cred_check_setreuid(ANY(ptr), ANY(int), euid)
+ == 0) ||
+ previously(mac_cred_check_setresuid(ANY(ptr), ANY(int), euid,
+ ANY(int)) == 0));
+ TESLA_SYSCALL(eventually(called(setsugid)));
- newcred->cr_uid = euip->ui_uid;
+ newcred->cr_uid = euid;
uihold(euip);
uifree(newcred->cr_uidinfo);
newcred->cr_uidinfo = euip;
@@ -2159,6 +2174,14 @@
change_egid(struct ucred *newcred, gid_t egid)
{
+ TESLA_SYSCALL(
+ previously(mac_cred_check_setgid(ANY(ptr), egid) == 0) ||
+ previously(mac_cred_check_setregid(ANY(ptr), ANY(int), egid)
+ == 0) ||
+ previously(mac_cred_check_setresgid(ANY(ptr), ANY(int), egid,
+ ANY(int)) == 0));
+ TESLA_SYSCALL(eventually(called(setsugid)));
+
newcred->cr_groups[0] = egid;
}
@@ -2174,8 +2197,17 @@
change_ruid(struct ucred *newcred, struct uidinfo *ruip)
{
+ uid_t ruid = ruip->ui_uid;
+ TESLA_SYSCALL(
+ previously(mac_cred_check_setuid(ANY(ptr), ruid) == 0) ||
+ previously(mac_cred_check_setreuid(ANY(ptr), ruid, ANY(int))
+ == 0) ||
+ previously(mac_cred_check_setresuid(ANY(ptr), ruid, ANY(int),
+ ANY(int)) == 0));
+ TESLA_SYSCALL(eventually(called(setsugid)));
+
(void)chgproccnt(newcred->cr_ruidinfo, -1, 0);
- newcred->cr_ruid = ruip->ui_uid;
+ newcred->cr_ruid = ruid;
uihold(ruip);
uifree(newcred->cr_ruidinfo);
newcred->cr_ruidinfo = ruip;
@@ -2192,6 +2224,14 @@
change_rgid(struct ucred *newcred, gid_t rgid)
{
+ TESLA_SYSCALL(
+ previously(mac_cred_check_setgid(ANY(ptr), rgid) == 0) ||
+ previously(mac_cred_check_setregid(ANY(ptr), rgid, ANY(int))
+ == 0) ||
+ previously(mac_cred_check_setresgid(ANY(ptr), rgid, ANY(int),
+ ANY(int)) == 0));
+ TESLA_SYSCALL(eventually(called(setsugid)));
+
newcred->cr_rgid = rgid;
}
@@ -2205,6 +2245,14 @@
change_svuid(struct ucred *newcred, uid_t svuid)
{
+ TESLA_SYSCALL(
+ previously(mac_cred_check_setuid(ANY(ptr), ANY(int)) == 0) ||
+ previously(mac_cred_check_setreuid(ANY(ptr), ANY(int),
+ ANY(int)) == 0) ||
+ previously(mac_cred_check_setresuid(ANY(ptr), ANY(int),
+ ANY(int), ANY(int)) == 0));
+ TESLA_SYSCALL(eventually(called(setsugid)));
+
newcred->cr_svuid = svuid;
}
@@ -2218,5 +2266,13 @@
change_svgid(struct ucred *newcred, gid_t svgid)
{
+ TESLA_SYSCALL(
+ previously(mac_cred_check_setgid(ANY(ptr), ANY(int)) == 0) ||
+ previously(mac_cred_check_setregid(ANY(ptr), ANY(int), ANY(int))
+ == 0) ||
+ previously(mac_cred_check_setresgid(ANY(ptr), ANY(int), ANY(int),
+ ANY(int)) == 0));
+ TESLA_SYSCALL(eventually(called(setsugid)));
+
newcred->cr_svgid = svgid;
}
More information about the p4-projects
mailing list