PERFORCE change 19038 for review

Brian Feldman green at freebsd.org
Thu Oct 10 17:57:50 GMT 2002


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

Change 19038 by green at green_laptop_2 on 2002/10/10 10:57:32

	Convert the thread_userret mac event hook to be based upon the
	AST mechanism.  This requires specifically tripping the AST
	(as seen in the mac_test modules) in order for the hook to be
	called, and so removes the overhead from the common userret
	case as requested by bde.

Affected files ...

.. //depot/projects/trustedbsd/mac/sys/kern/subr_trap.c#16 edit
.. //depot/projects/trustedbsd/mac/sys/security/mac_test/mac_test.c#55 edit
.. //depot/projects/trustedbsd/mac/sys/sys/mac.h#177 edit
.. //depot/projects/trustedbsd/mac/sys/sys/proc.h#24 edit

Differences ...

==== //depot/projects/trustedbsd/mac/sys/kern/subr_trap.c#16 (text+ko) ====

@@ -91,10 +91,6 @@
 	mtx_unlock(&Giant);
 #endif
 
-#ifdef MAC
-	mac_thread_userret(td);
-#endif
-
 	/*
 	 * XXX we cheat slightly on the locking here to avoid locking in
 	 * the usual case.  Setting td_priority here is essentially an
@@ -195,6 +191,9 @@
 	flags = ke->ke_flags;
 	sflag = p->p_sflag;
 	p->p_sflag &= ~(PS_ALRMPEND | PS_NEEDSIGCHK | PS_PROFPEND | PS_XCPU);
+#ifdef MAC
+	p->p_sflag &= ~PS_MACPEND;
+#endif /* MAC */
 	ke->ke_flags &= ~(KEF_ASTPENDING | KEF_NEEDRESCHED | KEF_OWEUPC);
 	cnt.v_soft++;
 	prticks = 0;
@@ -248,6 +247,10 @@
 		}
 		PROC_UNLOCK(p);
 	}
+#ifdef MAC
+	if (sflag & PS_MACPEND)
+		mac_thread_userret(td);
+#endif /* MAC */
 	if (flags & KEF_NEEDRESCHED) {
 		mtx_lock_spin(&sched_lock);
 		td->td_priority = kg->kg_user_pri;

==== //depot/projects/trustedbsd/mac/sys/security/mac_test/mac_test.c#55 (text+ko) ====

@@ -825,10 +825,27 @@
 
 }
 
+static int
+sysctl_mac_test_thread_userret(SYSCTL_HANDLER_ARGS)
+{
+
+	mtx_lock_spin(&sched_lock);
+	curthread->td_kse->ke_flags |= KEF_ASTPENDING;
+	curthread->td_proc->p_sflag |= PS_MACPEND;
+	mtx_unlock_spin(&sched_lock);
+	return (sysctl_handle_int(oidp, NULL, curthread->td_proc->p_pid,
+	    req));
+}
+SYSCTL_PROC(_security_mac_test, OID_AUTO, thread_userret,
+    CTLTYPE_INT | CTLFLAG_RD, 0, 0, sysctl_mac_test_thread_userret, "I",
+    "Set the flag for MAC AST pending and return pid");
+
 static void
 mac_test_thread_userret(struct thread *td)
 {
 
+	printf("mac_test_thread_userret(process = %d)\n",
+	    curthread->td_proc->p_pid);
 }
 
 /*

==== //depot/projects/trustedbsd/mac/sys/sys/mac.h#177 (text+ko) ====


==== //depot/projects/trustedbsd/mac/sys/sys/proc.h#24 (text+ko) ====

@@ -645,6 +645,7 @@
 #define	PS_SWAPPING	0x00200	/* Process is being swapped. */
 #define	PS_NEEDSIGCHK	0x02000	/* Process may need signal delivery. */
 #define	PS_SWAPPINGIN	0x04000	/* Swapin in progress. */
+#define	PS_MACPEND	0x08000 /* ast()-based MAC event pending */
 
 /* used only in legacy conversion code */
 #define	SIDL	1		/* Process being created by fork. */
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