/*-1* Copyright (c) 1999-2002, 2009 Robert N. M. Watson2* Copyright (c) 2001 Ilmar S. Habibulin3* Copyright (c) 2001-2004 Networks Associates Technology, Inc.4* Copyright (c) 2006 SPARTA, Inc.5*6* This software was developed by Robert Watson and Ilmar Habibulin for the7* TrustedBSD Project.8*9* This software was developed for the FreeBSD Project in part by Network10* Associates Laboratories, the Security Research Division of Network11* Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"),12* as part of the DARPA CHATS research program.13*14* This software was enhanced by SPARTA ISSO under SPAWAR contract15* N66001-04-C-6019 ("SEFOS").16*17* This software was developed at the University of Cambridge Computer18* Laboratory with support from a grant from Google, Inc.19*20* Redistribution and use in source and binary forms, with or without21* modification, are permitted provided that the following conditions22* are met:23* 1. Redistributions of source code must retain the above copyright24* notice, this list of conditions and the following disclaimer.25* 2. Redistributions in binary form must reproduce the above copyright26* notice, this list of conditions and the following disclaimer in the27* documentation and/or other materials provided with the distribution.28*29* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND30* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE31* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE32* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE33* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL34* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS35* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)36* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT37* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY38* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF39* SUCH DAMAGE.40*/4142#include <sys/param.h>43#include <sys/kernel.h>44#include <sys/module.h>45#include <sys/queue.h>46#include <sys/sdt.h>47#include <sys/vnode.h>4849#include <security/audit/audit.h>5051#include <security/mac/mac_framework.h>52#include <security/mac/mac_internal.h>53#include <security/mac/mac_policy.h>5455MAC_CHECK_PROBE_DEFINE2(cred_check_setaudit, "struct ucred *",56"struct auditinfo *");5758int59mac_cred_check_setaudit(struct ucred *cred, struct auditinfo *ai)60{61int error;6263MAC_POLICY_CHECK_NOSLEEP(cred_check_setaudit, cred, ai);64MAC_CHECK_PROBE2(cred_check_setaudit, error, cred, ai);6566return (error);67}6869MAC_CHECK_PROBE_DEFINE2(cred_check_setaudit_addr, "struct ucred *",70"struct auditinfo_addr *");7172int73mac_cred_check_setaudit_addr(struct ucred *cred, struct auditinfo_addr *aia)74{75int error;7677MAC_POLICY_CHECK_NOSLEEP(cred_check_setaudit_addr, cred, aia);78MAC_CHECK_PROBE2(cred_check_setaudit_addr, error, cred, aia);7980return (error);81}8283MAC_CHECK_PROBE_DEFINE2(cred_check_setauid, "struct ucred *", "uid_t");8485int86mac_cred_check_setauid(struct ucred *cred, uid_t auid)87{88int error;8990MAC_POLICY_CHECK_NOSLEEP(cred_check_setauid, cred, auid);91MAC_CHECK_PROBE2(cred_check_setauid, error, cred, auid);9293return (error);94}9596MAC_CHECK_PROBE_DEFINE3(system_check_audit, "struct ucred *", "void *",97"int");9899int100mac_system_check_audit(struct ucred *cred, void *record, int length)101{102int error;103104MAC_POLICY_CHECK_NOSLEEP(system_check_audit, cred, record, length);105MAC_CHECK_PROBE3(system_check_audit, error, cred, record, length);106107return (error);108}109110MAC_CHECK_PROBE_DEFINE2(system_check_auditctl, "struct ucred *",111"struct vnode *");112113int114mac_system_check_auditctl(struct ucred *cred, struct vnode *vp)115{116int error;117struct label *vl;118119ASSERT_VOP_LOCKED(vp, "mac_system_check_auditctl");120121vl = (vp != NULL) ? vp->v_label : NULL;122MAC_POLICY_CHECK(system_check_auditctl, cred, vp, vl);123MAC_CHECK_PROBE2(system_check_auditctl, error, cred, vp);124125return (error);126}127128MAC_CHECK_PROBE_DEFINE2(system_check_auditon, "struct ucred *", "int");129130int131mac_system_check_auditon(struct ucred *cred, int cmd)132{133int error;134135MAC_POLICY_CHECK_NOSLEEP(system_check_auditon, cred, cmd);136MAC_CHECK_PROBE2(system_check_auditon, error, cred, cmd);137138return (error);139}140141142