2 * Copyright (c) 2002-2003 Networks Associates Technology, Inc.
3 * Copyright (c) 2007 Robert N. M. Watson
6 * This software was developed for the FreeBSD Project in part by Network
7 * Associates Laboratories, the Security Research Division of Network
8 * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"),
9 * as part of the DARPA CHATS research program.
11 * Portions of this software were developed by Robert Watson for the
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * MAC Framework entry points relating to overall operation of system,
38 * including global services such as the kernel environment and loadable
41 * System checks often align with existing privilege checks, but provide
42 * additional security context that may be relevant to policies, such as the
43 * specific object being operated on.
46 #include <sys/cdefs.h>
47 __FBSDID("$FreeBSD$");
51 #include <sys/param.h>
52 #include <sys/kernel.h>
54 #include <sys/malloc.h>
55 #include <sys/module.h>
56 #include <sys/mutex.h>
57 #include <sys/systm.h>
58 #include <sys/vnode.h>
59 #include <sys/sysctl.h>
61 #include <security/mac/mac_framework.h>
62 #include <security/mac/mac_internal.h>
63 #include <security/mac/mac_policy.h>
66 mac_check_kenv_dump(struct ucred *cred)
70 MAC_CHECK(check_kenv_dump, cred);
76 mac_check_kenv_get(struct ucred *cred, char *name)
80 MAC_CHECK(check_kenv_get, cred, name);
86 mac_check_kenv_set(struct ucred *cred, char *name, char *value)
90 MAC_CHECK(check_kenv_set, cred, name, value);
96 mac_check_kenv_unset(struct ucred *cred, char *name)
100 MAC_CHECK(check_kenv_unset, cred, name);
106 mac_check_kld_load(struct ucred *cred, struct vnode *vp)
110 ASSERT_VOP_LOCKED(vp, "mac_check_kld_load");
112 MAC_CHECK(check_kld_load, cred, vp, vp->v_label);
118 mac_check_kld_stat(struct ucred *cred)
122 MAC_CHECK(check_kld_stat, cred);
128 mac_check_system_acct(struct ucred *cred, struct vnode *vp)
133 ASSERT_VOP_LOCKED(vp, "mac_check_system_acct");
136 MAC_CHECK(check_system_acct, cred, vp,
137 vp != NULL ? vp->v_label : NULL);
143 mac_check_system_reboot(struct ucred *cred, int howto)
147 MAC_CHECK(check_system_reboot, cred, howto);
153 mac_check_system_swapon(struct ucred *cred, struct vnode *vp)
157 ASSERT_VOP_LOCKED(vp, "mac_check_system_swapon");
159 MAC_CHECK(check_system_swapon, cred, vp, vp->v_label);
164 mac_check_system_swapoff(struct ucred *cred, struct vnode *vp)
168 ASSERT_VOP_LOCKED(vp, "mac_check_system_swapoff");
170 MAC_CHECK(check_system_swapoff, cred, vp, vp->v_label);
175 mac_check_system_sysctl(struct ucred *cred, struct sysctl_oid *oidp,
176 void *arg1, int arg2, struct sysctl_req *req)
181 * XXXMAC: We would very much like to assert the SYSCTL_LOCK here,
182 * but since it's not exported from kern_sysctl.c, we can't.
184 MAC_CHECK(check_system_sysctl, cred, oidp, arg1, arg2, req);