2 * Copyright (c) 1999-2002, 2009 Robert N. M. Watson
3 * Copyright (c) 2001 Ilmar S. Habibulin
4 * Copyright (c) 2001-2004 Networks Associates Technology, Inc.
5 * Copyright (c) 2006 SPARTA, Inc.
7 * This software was developed by Robert Watson and Ilmar Habibulin for the
10 * This software was developed for the FreeBSD Project in part by Network
11 * Associates Laboratories, the Security Research Division of Network
12 * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"),
13 * as part of the DARPA CHATS research program.
15 * This software was enhanced by SPARTA ISSO under SPAWAR contract
16 * N66001-04-C-6019 ("SEFOS").
18 * This software was developed at the University of Cambridge Computer
19 * Laboratory with support from a grant from Google, Inc.
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions
24 * 1. Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * 2. Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in the
28 * documentation and/or other materials provided with the distribution.
30 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 #include <sys/cdefs.h>
44 __FBSDID("$FreeBSD$");
46 #include "opt_kdtrace.h"
48 #include <sys/param.h>
49 #include <sys/kernel.h>
50 #include <sys/module.h>
51 #include <sys/queue.h>
53 #include <sys/vnode.h>
55 #include <security/audit/audit.h>
57 #include <security/mac/mac_framework.h>
58 #include <security/mac/mac_internal.h>
59 #include <security/mac/mac_policy.h>
61 MAC_CHECK_PROBE_DEFINE2(cred_check_setaudit, "struct ucred *",
62 "struct auditinfo *");
65 mac_cred_check_setaudit(struct ucred *cred, struct auditinfo *ai)
69 MAC_POLICY_CHECK_NOSLEEP(cred_check_setaudit, cred, ai);
70 MAC_CHECK_PROBE2(cred_check_setaudit, error, cred, ai);
75 MAC_CHECK_PROBE_DEFINE2(cred_check_setaudit_addr, "struct ucred *",
76 "struct auditinfo_addr *");
79 mac_cred_check_setaudit_addr(struct ucred *cred, struct auditinfo_addr *aia)
83 MAC_POLICY_CHECK_NOSLEEP(cred_check_setaudit_addr, cred, aia);
84 MAC_CHECK_PROBE2(cred_check_setaudit_addr, error, cred, aia);
89 MAC_CHECK_PROBE_DEFINE2(cred_check_setauid, "struct ucred *", "uid_t");
92 mac_cred_check_setauid(struct ucred *cred, uid_t auid)
96 MAC_POLICY_CHECK_NOSLEEP(cred_check_setauid, cred, auid);
97 MAC_CHECK_PROBE2(cred_check_setauid, error, cred, auid);
102 MAC_CHECK_PROBE_DEFINE3(system_check_audit, "struct ucred *", "void *",
106 mac_system_check_audit(struct ucred *cred, void *record, int length)
110 MAC_POLICY_CHECK_NOSLEEP(system_check_audit, cred, record, length);
111 MAC_CHECK_PROBE3(system_check_audit, error, cred, record, length);
116 MAC_CHECK_PROBE_DEFINE2(system_check_auditctl, "struct ucred *",
120 mac_system_check_auditctl(struct ucred *cred, struct vnode *vp)
125 ASSERT_VOP_LOCKED(vp, "mac_system_check_auditctl");
127 vl = (vp != NULL) ? vp->v_label : NULL;
128 MAC_POLICY_CHECK(system_check_auditctl, cred, vp, vl);
129 MAC_CHECK_PROBE2(system_check_auditctl, error, cred, vp);
134 MAC_CHECK_PROBE_DEFINE2(system_check_auditon, "struct ucred *", "int");
137 mac_system_check_auditon(struct ucred *cred, int cmd)
141 MAC_POLICY_CHECK_NOSLEEP(system_check_auditon, cred, cmd);
142 MAC_CHECK_PROBE2(system_check_auditon, error, cred, cmd);