PERFORCE change 17890 for review

Robert Watson rwatson at freebsd.org
Sat Sep 21 23:00:02 GMT 2002


http://people.freebsd.org/~peter/p4db/chv.cgi?CH=17890

Change 17890 by rwatson at rwatson_tislabs on 2002/09/21 15:59:55

	If load fails, we may get an unload event during the boot
	process.  Check for this case by looking to see if the policy
	generating the unload has MPC_RUNTIME_FLAG_REGISTERED set:
	if not, it was never loaded, so we can quietly suceed and
	all is well.  Restructure the lock handling and add some
	comments around this and related behavior while I'm here.

Affected files ...

.. //depot/projects/trustedbsd/mac/sys/kern/kern_mac.c#275 edit

Differences ...

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

@@ -1025,16 +1025,38 @@
 mac_policy_unregister(struct mac_policy_conf *mpc)
 {
 
+	/*
+	 * If we fail the load, we may get a request to unload.  Check
+	 * to see if we did the run-time registration, and if not,
+	 * silently succeed.
+	 */
+	MAC_POLICY_LIST_LOCK();
+	if ((mpc->mpc_runtime_flags & MPC_RUNTIME_FLAG_REGISTERED) == 0) {
+		MAC_POLICY_LIST_UNLOCK();
+		return (0);
+	}
 #if 0
 	/*
 	 * Don't allow unloading modules with private data.
 	 */
-	if (mpc->mpc_field_off != NULL)
+	if (mpc->mpc_field_off != NULL) {
+		MAC_POLICY_LIST_UNLOCK();
 		return (EBUSY);
+	}
 #endif
-	if ((mpc->mpc_loadtime_flags & MPC_LOADTIME_FLAG_UNLOADOK) == 0)
+	/*
+	 * Only allow the unload to proceed if the module is unloadable
+	 * by its own definition.
+	 */
+	if ((mpc->mpc_loadtime_flags & MPC_LOADTIME_FLAG_UNLOADOK) == 0) {
+		MAC_POLICY_LIST_UNLOCK();
 		return (EBUSY);
-	MAC_POLICY_LIST_LOCK();
+	}
+	/*
+	 * Right now, we EBUSY if the list is in use.  In the future,
+	 * for reliability reasons, we might want to sleep and wakeup
+	 * later to try again.
+	 */
 	if (mac_policy_list_busy > 0) {
 		MAC_POLICY_LIST_UNLOCK();
 		return (EBUSY);
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