From owner-p4-projects Wed May 1 22:15:44 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D75B737B405; Wed, 1 May 2002 22:15:36 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 1486E37B404 for ; Wed, 1 May 2002 22:15:36 -0700 (PDT) Received: (from perforce@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g425FZm85979 for perforce@freebsd.org; Wed, 1 May 2002 22:15:35 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Wed, 1 May 2002 22:15:35 -0700 (PDT) Message-Id: <200205020515.g425FZm85979@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 10651 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=10651 Change 10651 by rwatson@rwatson_tislabs on 2002/05/01 22:15:19 Make mac_late static. Add a new flag field to policy definition structures, mpc_loadtime_flags, which will allow policies to declare some of their properties using a series of flags. Define a flag MPC_LOADTIME_FLAG_NOTLATE, which will indicate a module refuses to register if it is loaded "late". Check this flag and the late variable during the registration process, reject modules with EBUSY if it's late and they refuse to be. Rename MPC_FLAG_REGISTERED to MPC_RUNTIME_FLAG_REGISTERED, to represent the fact that this flag is maintained by the MAC framework at runtime, and not by the policy itself. Affected files ... ... //depot/projects/trustedbsd/mac/sys/kern/kern_mac.c#135 edit ... //depot/projects/trustedbsd/mac/sys/sys/mac_policy.h#62 edit Differences ... ==== //depot/projects/trustedbsd/mac/sys/kern/kern_mac.c#135 (text+ko) ==== @@ -98,7 +98,7 @@ void *labels[MAC_MAX_POLICIES]; }; -int mac_late = 0; +static int mac_late = 0; static int mac_enforce_fs = 1; SYSCTL_INT(_security_mac, OID_AUTO, enforce_fs, CTLFLAG_RW, @@ -250,11 +250,17 @@ switch (type) { case MOD_LOAD: + if (mpc->mpc_loadtime_flags & MPC_LOADTIME_FLAG_NOTLATE && + mac_late) { + error = EBUSY; + break; + } error = mac_policy_register(mpc); break; case MOD_UNLOAD: /* Don't unregister the module if it was never registered. */ - if ((mpc->mpc_runtime_flags & MPC_FLAG_REGISTERED) != 0) + if ((mpc->mpc_runtime_flags & MPC_RUNTIME_FLAG_REGISTERED) + != 0) error = mac_policy_unregister(mpc); else error = 0; @@ -555,7 +561,7 @@ mpc->mpc_field_off = slot; } else mpc->mpc_field_off = -1; - mpc->mpc_runtime_flags |= MPC_FLAG_REGISTERED; + mpc->mpc_runtime_flags |= MPC_RUNTIME_FLAG_REGISTERED; LIST_INSERT_HEAD(&mac_policy_list, mpc, mpc_list); printf("Security policy: %s (%s)\n", mpc->mpc_fullname, mpc->mpc_name); ==== //depot/projects/trustedbsd/mac/sys/sys/mac_policy.h#62 (text+ko) ==== @@ -299,20 +299,25 @@ char *mpc_fullname; /* policy full name */ struct mac_policy_ops mpc_ops; /* policy operations */ struct mac_policy_op_entry *mpc_entries; /* ops to fill in */ + int mpc_loadtime_flags; /* flags */ int mpc_field_off; /* security field */ int mpc_runtime_flags; /* flags */ LIST_ENTRY(mac_policy_conf) mpc_list; /* global list */ }; +/* Flags for the mpc_loadtime_flags field. */ +#define MPC_LOADTIME_FLAG_NOTLATE 0x00000001 + /* Flags for the mpc_runtime_flags field. */ -#define MPC_FLAG_REGISTERED 0x00000001 +#define MPC_RUNTIME_FLAG_REGISTERED 0x00000001 -#define MAC_POLICY_SET(mpents, mpname, mpfullname, privdata_wanted) \ +#define MAC_POLICY_SET(mpents, mpname, mpfullname, mpflags, privdata_wanted)\ static struct mac_policy_conf mpname##_mac_policy_conf = { \ #mpname, \ mpfullname, \ { NULL /*... */ }, \ mpents, \ + mpflags, \ privdata_wanted, \ 0 \ }; \ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message