From owner-p4-projects Sat Sep 21 16: 0: 5 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6B4FD37B404; Sat, 21 Sep 2002 16:00:03 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F133137B401 for ; Sat, 21 Sep 2002 16:00:02 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id A8E5F43E6A for ; Sat, 21 Sep 2002 16:00:02 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from freefall.freebsd.org (perforce@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id g8LN02Co006702 for ; Sat, 21 Sep 2002 16:00:02 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id g8LN0253006699 for perforce@freebsd.org; Sat, 21 Sep 2002 16:00:02 -0700 (PDT) Date: Sat, 21 Sep 2002 16:00:02 -0700 (PDT) Message-Id: <200209212300.g8LN0253006699@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson Subject: PERFORCE change 17890 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=17890 Change 17890 by rwatson@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@FreeBSD.org with "unsubscribe p4-projects" in the body of the message