2002-07-30 02:04:05 +00:00
|
|
|
/*-
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
* Copyright (c) 2002, 2003 Networks Associates Technology, Inc.
|
2002-07-30 02:04:05 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2002-11-04 01:42:39 +00:00
|
|
|
* This software was developed for the FreeBSD Project in part by Network
|
|
|
|
* Associates Laboratories, the Security Research Division of Network
|
|
|
|
* Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"),
|
|
|
|
* as part of the DARPA CHATS research program.
|
2002-07-30 02:04:05 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
2003-06-11 00:56:59 +00:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2002-07-30 02:04:05 +00:00
|
|
|
#include "opt_mac.h"
|
2002-08-01 17:47:56 +00:00
|
|
|
|
2002-07-30 02:04:05 +00:00
|
|
|
#include <sys/param.h>
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/lock.h>
|
2002-09-05 07:02:43 +00:00
|
|
|
#include <sys/malloc.h>
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
#include <sys/mutex.h>
|
|
|
|
#include <sys/mac.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
|
|
|
|
#include <sys/mac_policy.h>
|
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
#include <security/mac/mac_internal.h>
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
2002-11-19 22:12:42 +00:00
|
|
|
static int mac_enforce_kld = 1;
|
|
|
|
SYSCTL_INT(_security_mac, OID_AUTO, enforce_kld, CTLFLAG_RW,
|
|
|
|
&mac_enforce_kld, 0, "Enforce MAC policy on kld operations");
|
|
|
|
TUNABLE_INT("security.mac.enforce_kld", &mac_enforce_kld);
|
|
|
|
|
2002-10-27 15:50:49 +00:00
|
|
|
static int mac_enforce_system = 1;
|
|
|
|
SYSCTL_INT(_security_mac, OID_AUTO, enforce_system, CTLFLAG_RW,
|
|
|
|
&mac_enforce_system, 0, "Enforce MAC policy on system operations");
|
|
|
|
TUNABLE_INT("security.mac.enforce_system", &mac_enforce_system);
|
2002-10-27 07:12:34 +00:00
|
|
|
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
int
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
mac_check_kenv_dump(struct ucred *cred)
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
if (!mac_enforce_system)
|
|
|
|
return (0);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
MAC_CHECK(check_kenv_dump, cred);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Clean up locking for the MAC Framework:
(1) Accept that we're now going to use mutexes, so don't attempt
to avoid treating them as mutexes. This cleans up locking
accessor function names some.
(2) Rename variables to _mtx, _cv, _count, simplifying the naming.
(3) Add a new form of the _busy() primitive that conditionally
makes the list busy: if there are entries on the list, bump
the busy count. If there are no entries, don't bump the busy
count. Return a boolean indicating whether or not the busy
count was bumped.
(4) Break mac_policy_list into two lists: one with the same name
holding dynamic policies, and a new list, mac_static_policy_list,
which holds policies loaded before mac_late and without the
unload flag set. The static list may be accessed without
holding the busy count, since it can't change at run-time.
(5) In general, prefer making the list busy conditionally, meaning
we pay only one mutex lock per entry point if all modules are
on the static list, rather than two (since we don't have to
lower the busy count when we're done with the framework). For
systems running just Biba or MLS, this will halve the mutex
accesses in the network stack, and may offer a substantial
performance benefits.
(6) Lay the groundwork for a dynamic-free kernel option which
eliminates all locking associated with dynamically loaded or
unloaded policies, for pre-configured systems requiring
maximum performance but less run-time flexibility.
These changes have been running for a few weeks on MAC development
branch systems.
Approved by: re (jhb)
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-05-07 17:49:24 +00:00
|
|
|
return (error);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
}
|
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int
|
|
|
|
mac_check_kenv_get(struct ucred *cred, char *name)
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
{
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int error;
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
if (!mac_enforce_system)
|
2002-10-05 16:46:03 +00:00
|
|
|
return (0);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
MAC_CHECK(check_kenv_get, cred, name);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
return (error);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
}
|
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int
|
|
|
|
mac_check_kenv_set(struct ucred *cred, char *name, char *value)
|
2003-04-14 18:11:18 +00:00
|
|
|
{
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int error;
|
2003-04-14 18:11:18 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
if (!mac_enforce_system)
|
|
|
|
return (0);
|
2003-04-14 18:11:18 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
MAC_CHECK(check_kenv_set, cred, name, value);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
return (error);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
}
|
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int
|
|
|
|
mac_check_kenv_unset(struct ucred *cred, char *name)
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
{
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int error;
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
if (!mac_enforce_system)
|
|
|
|
return (0);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
MAC_CHECK(check_kenv_unset, cred, name);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
return (error);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
}
|
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int
|
|
|
|
mac_check_kld_load(struct ucred *cred, struct vnode *vp)
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
{
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int error;
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
ASSERT_VOP_LOCKED(vp, "mac_check_kld_load");
|
2002-10-22 14:29:47 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
if (!mac_enforce_kld)
|
|
|
|
return (0);
|
2002-10-22 14:29:47 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
MAC_CHECK(check_kld_load, cred, vp, &vp->v_label);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
return (error);
|
2002-10-05 16:54:59 +00:00
|
|
|
}
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int
|
|
|
|
mac_check_kld_stat(struct ucred *cred)
|
2002-10-05 16:54:59 +00:00
|
|
|
{
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int error;
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
if (!mac_enforce_kld)
|
|
|
|
return (0);
|
2002-10-05 16:54:59 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
MAC_CHECK(check_kld_stat, cred);
|
2002-10-22 14:29:47 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
return (error);
|
2002-10-22 14:29:47 +00:00
|
|
|
}
|
|
|
|
|
2003-03-26 15:12:03 +00:00
|
|
|
int
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
mac_check_kld_unload(struct ucred *cred)
|
2002-10-05 16:54:59 +00:00
|
|
|
{
|
2003-03-26 15:12:03 +00:00
|
|
|
int error;
|
2002-10-05 16:54:59 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
if (!mac_enforce_kld)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
MAC_CHECK(check_kld_unload, cred);
|
2003-03-26 15:12:03 +00:00
|
|
|
|
|
|
|
return (error);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
}
|
|
|
|
|
2002-10-05 17:38:45 +00:00
|
|
|
int
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
mac_check_sysarch_ioperm(struct ucred *cred)
|
2002-10-05 17:38:45 +00:00
|
|
|
{
|
2003-04-15 19:33:23 +00:00
|
|
|
int error;
|
2002-10-05 17:38:45 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
if (!mac_enforce_system)
|
|
|
|
return (0);
|
2002-10-05 17:38:45 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
MAC_CHECK(check_sysarch_ioperm, cred);
|
2002-10-05 17:44:49 +00:00
|
|
|
return (error);
|
2002-10-05 17:38:45 +00:00
|
|
|
}
|
|
|
|
|
Move MAC label storage for mbufs into m_tags from the m_pkthdr structure,
returning some additional room in the first mbuf in a chain, and
avoiding feature-specific contents in the mbuf header. To do this:
- Modify mbuf_to_label() to extract the tag, returning NULL if not
found.
- Introduce mac_init_mbuf_tag() which does most of the work
mac_init_mbuf() used to do, except on an m_tag rather than an
mbuf.
- Scale back mac_init_mbuf() to perform m_tag allocation and invoke
mac_init_mbuf_tag().
- Replace mac_destroy_mbuf() with mac_destroy_mbuf_tag(), since
m_tag's are now GC'd deep in the m_tag/mbuf code rather than
at a higher level when mbufs are directly free()'d.
- Add mac_copy_mbuf_tag() to support m_copy_pkthdr() and related
notions.
- Generally change all references to mbuf labels so that they use
mbuf_to_label() rather than &mbuf->m_pkthdr.label. This
required no changes in the MAC policies (yay!).
- Tweak mbuf release routines to not call mac_destroy_mbuf(),
tag destruction takes care of it for us now.
- Remove MAC magic from m_copy_pkthdr() and m_move_pkthdr() --
the existing m_tag support does all this for us. Note that
we can no longer just zero the m_tag list on the target mbuf,
rather, we have to delete the chain because m_tag's will
already be hung off freshly allocated mbuf's.
- Tweak m_tag copying routines so that if we're copying a MAC
m_tag, we don't do a binary copy, rather, we initialize the
new storage and do a deep copy of the label.
- Remove use of MAC_FLAG_INITIALIZED in a few bizarre places
having to do with mbuf header copies previously.
- When an mbuf is copied in ip_input(), we no longer need to
explicitly copy the label because it will get handled by the
m_tag code now.
- No longer any weird handling of MAC labels in if_loop.c during
header copies.
- Add MPC_LOADTIME_FLAG_LABELMBUFS flag to Biba, MLS, mac_test.
In mac_test, handle the label==NULL case, since it can be
dynamically loaded.
In order to improve performance with this change, introduce the notion
of "lazy MAC label allocation" -- only allocate m_tag storage for MAC
labels if we're running with a policy that uses MAC labels on mbufs.
Policies declare this intent by setting the MPC_LOADTIME_FLAG_LABELMBUFS
flag in their load-time flags field during declaration. Note: this
opens up the possibility of post-boot policy modules getting back NULL
slot entries even though they have policy invariants of non-NULL slot
entries, as the policy might have been loaded after the mbuf was
allocated, leaving the mbuf without label storage. Policies that cannot
handle this case must be declared as NOTLATE, or must be modified.
- mac_labelmbufs holds the current cumulative status as to whether
any policies require mbuf labeling or not. This is updated whenever
the active policy set changes by the function mac_policy_updateflags().
The function iterates the list and checks whether any have the
flag set. Write access to this variable is protected by the policy
list; read access is currently not protected for performance reasons.
This might change if it causes problems.
- Add MAC_POLICY_LIST_ASSERT_EXCLUSIVE() to permit the flags update
function to assert appropriate locks.
- This makes allocation in mac_init_mbuf() conditional on the flag.
Reviewed by: sam
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-04-14 20:39:06 +00:00
|
|
|
int
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
mac_check_system_acct(struct ucred *cred, struct vnode *vp)
|
Move MAC label storage for mbufs into m_tags from the m_pkthdr structure,
returning some additional room in the first mbuf in a chain, and
avoiding feature-specific contents in the mbuf header. To do this:
- Modify mbuf_to_label() to extract the tag, returning NULL if not
found.
- Introduce mac_init_mbuf_tag() which does most of the work
mac_init_mbuf() used to do, except on an m_tag rather than an
mbuf.
- Scale back mac_init_mbuf() to perform m_tag allocation and invoke
mac_init_mbuf_tag().
- Replace mac_destroy_mbuf() with mac_destroy_mbuf_tag(), since
m_tag's are now GC'd deep in the m_tag/mbuf code rather than
at a higher level when mbufs are directly free()'d.
- Add mac_copy_mbuf_tag() to support m_copy_pkthdr() and related
notions.
- Generally change all references to mbuf labels so that they use
mbuf_to_label() rather than &mbuf->m_pkthdr.label. This
required no changes in the MAC policies (yay!).
- Tweak mbuf release routines to not call mac_destroy_mbuf(),
tag destruction takes care of it for us now.
- Remove MAC magic from m_copy_pkthdr() and m_move_pkthdr() --
the existing m_tag support does all this for us. Note that
we can no longer just zero the m_tag list on the target mbuf,
rather, we have to delete the chain because m_tag's will
already be hung off freshly allocated mbuf's.
- Tweak m_tag copying routines so that if we're copying a MAC
m_tag, we don't do a binary copy, rather, we initialize the
new storage and do a deep copy of the label.
- Remove use of MAC_FLAG_INITIALIZED in a few bizarre places
having to do with mbuf header copies previously.
- When an mbuf is copied in ip_input(), we no longer need to
explicitly copy the label because it will get handled by the
m_tag code now.
- No longer any weird handling of MAC labels in if_loop.c during
header copies.
- Add MPC_LOADTIME_FLAG_LABELMBUFS flag to Biba, MLS, mac_test.
In mac_test, handle the label==NULL case, since it can be
dynamically loaded.
In order to improve performance with this change, introduce the notion
of "lazy MAC label allocation" -- only allocate m_tag storage for MAC
labels if we're running with a policy that uses MAC labels on mbufs.
Policies declare this intent by setting the MPC_LOADTIME_FLAG_LABELMBUFS
flag in their load-time flags field during declaration. Note: this
opens up the possibility of post-boot policy modules getting back NULL
slot entries even though they have policy invariants of non-NULL slot
entries, as the policy might have been loaded after the mbuf was
allocated, leaving the mbuf without label storage. Policies that cannot
handle this case must be declared as NOTLATE, or must be modified.
- mac_labelmbufs holds the current cumulative status as to whether
any policies require mbuf labeling or not. This is updated whenever
the active policy set changes by the function mac_policy_updateflags().
The function iterates the list and checks whether any have the
flag set. Write access to this variable is protected by the policy
list; read access is currently not protected for performance reasons.
This might change if it causes problems.
- Add MAC_POLICY_LIST_ASSERT_EXCLUSIVE() to permit the flags update
function to assert appropriate locks.
- This makes allocation in mac_init_mbuf() conditional on the flag.
Reviewed by: sam
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-04-14 20:39:06 +00:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
if (vp != NULL) {
|
|
|
|
ASSERT_VOP_LOCKED(vp, "mac_check_system_acct");
|
Move MAC label storage for mbufs into m_tags from the m_pkthdr structure,
returning some additional room in the first mbuf in a chain, and
avoiding feature-specific contents in the mbuf header. To do this:
- Modify mbuf_to_label() to extract the tag, returning NULL if not
found.
- Introduce mac_init_mbuf_tag() which does most of the work
mac_init_mbuf() used to do, except on an m_tag rather than an
mbuf.
- Scale back mac_init_mbuf() to perform m_tag allocation and invoke
mac_init_mbuf_tag().
- Replace mac_destroy_mbuf() with mac_destroy_mbuf_tag(), since
m_tag's are now GC'd deep in the m_tag/mbuf code rather than
at a higher level when mbufs are directly free()'d.
- Add mac_copy_mbuf_tag() to support m_copy_pkthdr() and related
notions.
- Generally change all references to mbuf labels so that they use
mbuf_to_label() rather than &mbuf->m_pkthdr.label. This
required no changes in the MAC policies (yay!).
- Tweak mbuf release routines to not call mac_destroy_mbuf(),
tag destruction takes care of it for us now.
- Remove MAC magic from m_copy_pkthdr() and m_move_pkthdr() --
the existing m_tag support does all this for us. Note that
we can no longer just zero the m_tag list on the target mbuf,
rather, we have to delete the chain because m_tag's will
already be hung off freshly allocated mbuf's.
- Tweak m_tag copying routines so that if we're copying a MAC
m_tag, we don't do a binary copy, rather, we initialize the
new storage and do a deep copy of the label.
- Remove use of MAC_FLAG_INITIALIZED in a few bizarre places
having to do with mbuf header copies previously.
- When an mbuf is copied in ip_input(), we no longer need to
explicitly copy the label because it will get handled by the
m_tag code now.
- No longer any weird handling of MAC labels in if_loop.c during
header copies.
- Add MPC_LOADTIME_FLAG_LABELMBUFS flag to Biba, MLS, mac_test.
In mac_test, handle the label==NULL case, since it can be
dynamically loaded.
In order to improve performance with this change, introduce the notion
of "lazy MAC label allocation" -- only allocate m_tag storage for MAC
labels if we're running with a policy that uses MAC labels on mbufs.
Policies declare this intent by setting the MPC_LOADTIME_FLAG_LABELMBUFS
flag in their load-time flags field during declaration. Note: this
opens up the possibility of post-boot policy modules getting back NULL
slot entries even though they have policy invariants of non-NULL slot
entries, as the policy might have been loaded after the mbuf was
allocated, leaving the mbuf without label storage. Policies that cannot
handle this case must be declared as NOTLATE, or must be modified.
- mac_labelmbufs holds the current cumulative status as to whether
any policies require mbuf labeling or not. This is updated whenever
the active policy set changes by the function mac_policy_updateflags().
The function iterates the list and checks whether any have the
flag set. Write access to this variable is protected by the policy
list; read access is currently not protected for performance reasons.
This might change if it causes problems.
- Add MAC_POLICY_LIST_ASSERT_EXCLUSIVE() to permit the flags update
function to assert appropriate locks.
- This makes allocation in mac_init_mbuf() conditional on the flag.
Reviewed by: sam
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-04-14 20:39:06 +00:00
|
|
|
}
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
if (!mac_enforce_system)
|
|
|
|
return (0);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
MAC_CHECK(check_system_acct, cred, vp,
|
|
|
|
vp != NULL ? &vp->v_label : NULL);
|
2002-11-20 15:41:25 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
return (error);
|
2002-11-20 15:41:25 +00:00
|
|
|
}
|
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int
|
|
|
|
mac_check_system_nfsd(struct ucred *cred)
|
2002-10-05 16:54:59 +00:00
|
|
|
{
|
2002-10-05 21:23:47 +00:00
|
|
|
int error;
|
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
if (!mac_enforce_system)
|
|
|
|
return (0);
|
2002-10-05 21:23:47 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
MAC_CHECK(check_system_nfsd, cred);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
2002-10-05 21:23:47 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int
|
|
|
|
mac_check_system_reboot(struct ucred *cred, int howto)
|
2002-10-05 21:23:47 +00:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
if (!mac_enforce_system)
|
|
|
|
return (0);
|
2002-10-05 21:23:47 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
MAC_CHECK(check_system_reboot, cred, howto);
|
2002-10-05 21:23:47 +00:00
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
mac_check_system_settime(struct ucred *cred)
|
2002-10-05 21:23:47 +00:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
if (!mac_enforce_system)
|
|
|
|
return (0);
|
2002-10-05 21:23:47 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
MAC_CHECK(check_system_settime, cred);
|
2002-10-05 21:23:47 +00:00
|
|
|
|
|
|
|
return (error);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
}
|
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int
|
|
|
|
mac_check_system_swapon(struct ucred *cred, struct vnode *vp)
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
{
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int error;
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
ASSERT_VOP_LOCKED(vp, "mac_check_system_swapon");
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
if (!mac_enforce_system)
|
|
|
|
return (0);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
MAC_CHECK(check_system_swapon, cred, vp, &vp->v_label);
|
|
|
|
return (error);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
}
|
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int
|
|
|
|
mac_check_system_swapoff(struct ucred *cred, struct vnode *vp)
|
2002-10-22 14:29:47 +00:00
|
|
|
{
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int error;
|
2002-10-22 14:29:47 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
ASSERT_VOP_LOCKED(vp, "mac_check_system_swapoff");
|
2002-10-22 14:29:47 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
if (!mac_enforce_system)
|
|
|
|
return (0);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
MAC_CHECK(check_system_swapoff, cred, vp, &vp->v_label);
|
|
|
|
return (error);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
}
|
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int
|
|
|
|
mac_check_system_sysctl(struct ucred *cred, int *name, u_int namelen,
|
|
|
|
void *old, size_t *oldlenp, int inkernel, void *new, size_t newlen)
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
{
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
int error;
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
/*
|
|
|
|
* XXXMAC: We're very much like to assert the SYSCTL_LOCK here,
|
|
|
|
* but since it's not exported from kern_sysctl.c, we can't.
|
|
|
|
*/
|
|
|
|
if (!mac_enforce_system)
|
|
|
|
return (0);
|
Begin committing support for Mandatory Access Control and extensible
kernel access control. The MAC framework permits loadable kernel
modules to link to the kernel at compile-time, boot-time, or run-time,
and augment the system security policy. This commit includes the
initial kernel implementation, although the interface with the userland
components of the oeprating system is still under work, and not all
kernel subsystems are supported. Later in this commit sequence,
documentation of which kernel subsystems will not work correctly with
a kernel compiled with MAC support will be added.
kern_mac.c contains the body of the MAC framework. Kernel and
user APIs defined in mac.h are implemented here, providing a front end
to loaded security modules. This code implements a module registration
service, state (label) management, security configuration and policy
composition.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
2002-07-30 21:36:05 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
MAC_CHECK(check_system_sysctl, cred, name, namelen, old, oldlenp,
|
|
|
|
inkernel, new, newlen);
|
2002-10-22 14:29:47 +00:00
|
|
|
|
Remove non-system bits from mac_system.c. Leave:
Enforce_kld, enforce_system access control toggles.
Access control checks for: kenv operation, kld operations,
sysarch_ioperm(), acct(), nfsd(), reboot(), settime(), swapon(),
swapoff(), sysctl().
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
2003-10-22 20:09:12 +00:00
|
|
|
return (error);
|
2002-10-22 14:29:47 +00:00
|
|
|
}
|