2 * Copyright (c) 2002-2003 Networks Associates Technology, Inc.
3 * Copyright (c) 2006 SPARTA, Inc.
4 * Copyright (c) 2007 Robert N. M. Watson
7 * This software was developed for the FreeBSD Project in part by Network
8 * Associates Laboratories, the Security Research Division of Network
9 * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"),
10 * as part of the DARPA CHATS research program.
12 * Portions of this software were developed by Robert Watson for the
15 * This software was enhanced by SPARTA ISSO under SPAWAR contract
16 * N66001-04-C-6019 ("SEFOS").
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
27 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 * MAC Framework entry points relating to overall operation of system,
42 * including global services such as the kernel environment and loadable
45 * System checks often align with existing privilege checks, but provide
46 * additional security context that may be relevant to policies, such as the
47 * specific object being operated on.
50 #include <sys/cdefs.h>
51 __FBSDID("$FreeBSD$");
55 #include <sys/param.h>
56 #include <sys/kernel.h>
58 #include <sys/malloc.h>
59 #include <sys/module.h>
60 #include <sys/mutex.h>
61 #include <sys/systm.h>
62 #include <sys/vnode.h>
63 #include <sys/sysctl.h>
65 #include <security/mac/mac_framework.h>
66 #include <security/mac/mac_internal.h>
67 #include <security/mac/mac_policy.h>
70 mac_kenv_check_dump(struct ucred *cred)
74 MAC_CHECK(kenv_check_dump, cred);
80 mac_kenv_check_get(struct ucred *cred, char *name)
84 MAC_CHECK(kenv_check_get, cred, name);
90 mac_kenv_check_set(struct ucred *cred, char *name, char *value)
94 MAC_CHECK(kenv_check_set, cred, name, value);
100 mac_kenv_check_unset(struct ucred *cred, char *name)
104 MAC_CHECK(kenv_check_unset, cred, name);
110 mac_kld_check_load(struct ucred *cred, struct vnode *vp)
114 ASSERT_VOP_LOCKED(vp, "mac_kld_check_load");
116 MAC_CHECK(kld_check_load, cred, vp, vp->v_label);
122 mac_kld_check_stat(struct ucred *cred)
126 MAC_CHECK(kld_check_stat, cred);
132 mac_system_check_acct(struct ucred *cred, struct vnode *vp)
137 ASSERT_VOP_LOCKED(vp, "mac_system_check_acct");
140 MAC_CHECK(system_check_acct, cred, vp,
141 vp != NULL ? vp->v_label : NULL);
147 mac_system_check_reboot(struct ucred *cred, int howto)
151 MAC_CHECK(system_check_reboot, cred, howto);
157 mac_system_check_swapon(struct ucred *cred, struct vnode *vp)
161 ASSERT_VOP_LOCKED(vp, "mac_system_check_swapon");
163 MAC_CHECK(system_check_swapon, cred, vp, vp->v_label);
168 mac_system_check_swapoff(struct ucred *cred, struct vnode *vp)
172 ASSERT_VOP_LOCKED(vp, "mac_system_check_swapoff");
174 MAC_CHECK(system_check_swapoff, cred, vp, vp->v_label);
179 mac_system_check_sysctl(struct ucred *cred, struct sysctl_oid *oidp,
180 void *arg1, int arg2, struct sysctl_req *req)
185 * XXXMAC: We would very much like to assert the SYSCTL_LOCK here,
186 * but since it's not exported from kern_sysctl.c, we can't.
188 MAC_CHECK(system_check_sysctl, cred, oidp, arg1, arg2, req);