mac_process.c revision 123173
1100894Srwatson/*-
2100894Srwatson * Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson
3100894Srwatson * Copyright (c) 2001 Ilmar S. Habibulin
4113681Srwatson * Copyright (c) 2001, 2002, 2003 Networks Associates Technology, Inc.
5100894Srwatson * All rights reserved.
6100894Srwatson *
7100894Srwatson * This software was developed by Robert Watson and Ilmar Habibulin for the
8100894Srwatson * TrustedBSD Project.
9100894Srwatson *
10106392Srwatson * This software was developed for the FreeBSD Project in part by Network
11106392Srwatson * Associates Laboratories, the Security Research Division of Network
12106392Srwatson * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"),
13106392Srwatson * as part of the DARPA CHATS research program.
14100894Srwatson *
15100894Srwatson * Redistribution and use in source and binary forms, with or without
16100894Srwatson * modification, are permitted provided that the following conditions
17100894Srwatson * are met:
18100894Srwatson * 1. Redistributions of source code must retain the above copyright
19100894Srwatson *    notice, this list of conditions and the following disclaimer.
20100894Srwatson * 2. Redistributions in binary form must reproduce the above copyright
21100894Srwatson *    notice, this list of conditions and the following disclaimer in the
22100894Srwatson *    documentation and/or other materials provided with the distribution.
23100894Srwatson *
24100894Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
25100894Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26100894Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27100894Srwatson * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
28100894Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29100894Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30100894Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31100894Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32100894Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33100894Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34100894Srwatson * SUCH DAMAGE.
35100894Srwatson */
36116182Sobrien
37116182Sobrien#include <sys/cdefs.h>
38116182Sobrien__FBSDID("$FreeBSD: head/sys/security/mac/mac_process.c 123173 2003-12-06 21:48:03Z rwatson $");
39116182Sobrien
40100894Srwatson#include "opt_mac.h"
41101173Srwatson
42100894Srwatson#include <sys/param.h>
43106856Srwatson#include <sys/condvar.h>
44106468Srwatson#include <sys/imgact.h>
45100979Srwatson#include <sys/kernel.h>
46100979Srwatson#include <sys/lock.h>
47102949Sbde#include <sys/malloc.h>
48100979Srwatson#include <sys/mutex.h>
49100979Srwatson#include <sys/mac.h>
50100979Srwatson#include <sys/proc.h>
51116701Srwatson#include <sys/sbuf.h>
52100979Srwatson#include <sys/systm.h>
53100979Srwatson#include <sys/vnode.h>
54100979Srwatson#include <sys/mount.h>
55100979Srwatson#include <sys/file.h>
56100979Srwatson#include <sys/namei.h>
57100979Srwatson#include <sys/sysctl.h>
58100894Srwatson
59100979Srwatson#include <vm/vm.h>
60100979Srwatson#include <vm/pmap.h>
61100979Srwatson#include <vm/vm_map.h>
62100979Srwatson#include <vm/vm_object.h>
63100979Srwatson
64100979Srwatson#include <sys/mac_policy.h>
65100979Srwatson
66121361Srwatson#include <security/mac/mac_internal.h>
67100979Srwatson
68121361Srwatsonint	mac_enforce_process = 1;
69100979SrwatsonSYSCTL_INT(_security_mac, OID_AUTO, enforce_process, CTLFLAG_RW,
70100979Srwatson    &mac_enforce_process, 0, "Enforce MAC policy on inter-process operations");
71100979SrwatsonTUNABLE_INT("security.mac.enforce_process", &mac_enforce_process);
72100979Srwatson
73121361Srwatsonint	mac_enforce_vm = 1;
74103514SrwatsonSYSCTL_INT(_security_mac, OID_AUTO, enforce_vm, CTLFLAG_RW,
75103514Srwatson    &mac_enforce_vm, 0, "Enforce MAC policy on vm operations");
76104236SrwatsonTUNABLE_INT("security.mac.enforce_vm", &mac_enforce_vm);
77103514Srwatson
78103136Srwatsonstatic int	mac_mmap_revocation = 1;
79103136SrwatsonSYSCTL_INT(_security_mac, OID_AUTO, mmap_revocation, CTLFLAG_RW,
80103136Srwatson    &mac_mmap_revocation, 0, "Revoke mmap access to files on subject "
81103136Srwatson    "relabel");
82121361Srwatson
83101892Srwatsonstatic int	mac_mmap_revocation_via_cow = 0;
84100979SrwatsonSYSCTL_INT(_security_mac, OID_AUTO, mmap_revocation_via_cow, CTLFLAG_RW,
85100979Srwatson    &mac_mmap_revocation_via_cow, 0, "Revoke mmap access to files via "
86100979Srwatson    "copy-on-write semantics, or by removing all write access");
87100979Srwatson
88101988Srwatson#ifdef MAC_DEBUG
89121361Srwatsonstatic unsigned int nmaccreds, nmacprocs;
90104517SrwatsonSYSCTL_UINT(_security_mac_debug_counters, OID_AUTO, creds, CTLFLAG_RD,
91100979Srwatson    &nmaccreds, 0, "number of ucreds in use");
92107105SrwatsonSYSCTL_UINT(_security_mac_debug_counters, OID_AUTO, procs, CTLFLAG_RD,
93107105Srwatson    &nmacprocs, 0, "number of procs in use");
94101988Srwatson#endif
95100979Srwatson
96100979Srwatsonstatic void	mac_cred_mmapped_drop_perms_recurse(struct thread *td,
97100979Srwatson		    struct ucred *cred, struct vm_map *map);
98100979Srwatson
99122524Srwatsonstruct label *
100122524Srwatsonmac_cred_label_alloc(void)
101104521Srwatson{
102122524Srwatson	struct label *label;
103104521Srwatson
104122524Srwatson	label = mac_labelzone_alloc(M_WAITOK);
105105694Srwatson	MAC_PERFORM(init_cred_label, label);
106119184Srwatson	MAC_DEBUG_COUNTER_INC(&nmaccreds);
107122524Srwatson	return (label);
108104521Srwatson}
109104521Srwatson
110104521Srwatsonvoid
111105694Srwatsonmac_init_cred(struct ucred *cred)
112105694Srwatson{
113105694Srwatson
114122524Srwatson	cred->cr_label = mac_cred_label_alloc();
115105694Srwatson}
116105694Srwatson
117122524Srwatsonstatic struct label *
118122524Srwatsonmac_proc_label_alloc(void)
119122524Srwatson{
120122524Srwatson	struct label *label;
121122524Srwatson
122122524Srwatson	label = mac_labelzone_alloc(M_WAITOK);
123122524Srwatson	MAC_PERFORM(init_proc_label, label);
124122524Srwatson	MAC_DEBUG_COUNTER_INC(&nmacprocs);
125122524Srwatson	return (label);
126122524Srwatson}
127122524Srwatson
128105694Srwatsonvoid
129107105Srwatsonmac_init_proc(struct proc *p)
130107105Srwatson{
131107105Srwatson
132122524Srwatson	p->p_label = mac_proc_label_alloc();
133107105Srwatson}
134107105Srwatson
135105988Srwatsonvoid
136122524Srwatsonmac_cred_label_free(struct label *label)
137104521Srwatson{
138104521Srwatson
139105694Srwatson	MAC_PERFORM(destroy_cred_label, label);
140122524Srwatson	mac_labelzone_free(label);
141119184Srwatson	MAC_DEBUG_COUNTER_DEC(&nmaccreds);
142104521Srwatson}
143104521Srwatson
144104521Srwatsonvoid
145105694Srwatsonmac_destroy_cred(struct ucred *cred)
146105694Srwatson{
147105694Srwatson
148122524Srwatson	mac_cred_label_free(cred->cr_label);
149122524Srwatson	cred->cr_label = NULL;
150105694Srwatson}
151105694Srwatson
152122524Srwatsonstatic void
153122524Srwatsonmac_proc_label_free(struct label *label)
154122524Srwatson{
155122524Srwatson
156122524Srwatson	MAC_PERFORM(destroy_proc_label, label);
157122524Srwatson	mac_labelzone_free(label);
158122524Srwatson	MAC_DEBUG_COUNTER_DEC(&nmacprocs);
159122524Srwatson}
160122524Srwatson
161105694Srwatsonvoid
162107105Srwatsonmac_destroy_proc(struct proc *p)
163107105Srwatson{
164107105Srwatson
165122524Srwatson	mac_proc_label_free(p->p_label);
166122524Srwatson	p->p_label = NULL;
167107105Srwatson}
168107105Srwatson
169121361Srwatsonint
170105694Srwatsonmac_externalize_cred_label(struct label *label, char *elements,
171122159Srwatson    char *outbuf, size_t outbuflen)
172105694Srwatson{
173104522Srwatson	int error;
174104522Srwatson
175121507Srwatson	MAC_EXTERNALIZE(cred, label, elements, outbuf, outbuflen);
176104522Srwatson
177104522Srwatson	return (error);
178104522Srwatson}
179104522Srwatson
180121361Srwatsonint
181105694Srwatsonmac_internalize_cred_label(struct label *label, char *string)
182105694Srwatson{
183105694Srwatson	int error;
184105694Srwatson
185121507Srwatson	MAC_INTERNALIZE(cred, label, string);
186105694Srwatson
187105694Srwatson	return (error);
188105694Srwatson}
189105694Srwatson
190104522Srwatson/*
191104522Srwatson * Initialize MAC label for the first kernel process, from which other
192104522Srwatson * kernel processes and threads are spawned.
193104522Srwatson */
194104521Srwatsonvoid
195104522Srwatsonmac_create_proc0(struct ucred *cred)
196104522Srwatson{
197104522Srwatson
198104522Srwatson	MAC_PERFORM(create_proc0, cred);
199104522Srwatson}
200104522Srwatson
201104522Srwatson/*
202104522Srwatson * Initialize MAC label for the first userland process, from which other
203104522Srwatson * userland processes and threads are spawned.
204104522Srwatson */
205104522Srwatsonvoid
206104522Srwatsonmac_create_proc1(struct ucred *cred)
207104522Srwatson{
208104522Srwatson
209104522Srwatson	MAC_PERFORM(create_proc1, cred);
210104522Srwatson}
211104522Srwatson
212104522Srwatsonvoid
213104522Srwatsonmac_thread_userret(struct thread *td)
214104522Srwatson{
215104522Srwatson
216104522Srwatson	MAC_PERFORM(thread_userret, td);
217104522Srwatson}
218104522Srwatson
219104522Srwatson/*
220104522Srwatson * When a new process is created, its label must be initialized.  Generally,
221104522Srwatson * this involves inheritence from the parent process, modulo possible
222104522Srwatson * deltas.  This function allows that processing to take place.
223104522Srwatson */
224104522Srwatsonvoid
225123173Srwatsonmac_copy_cred(struct ucred *src, struct ucred *dest)
226104522Srwatson{
227104522Srwatson
228123173Srwatson	MAC_PERFORM(copy_cred_label, src->cr_label, dest->cr_label);
229104522Srwatson}
230104522Srwatson
231105988Srwatsonint
232122524Srwatsonmac_execve_enter(struct image_params *imgp, struct mac *mac_p)
233106468Srwatson{
234122524Srwatson	struct label *label;
235106468Srwatson	struct mac mac;
236106468Srwatson	char *buffer;
237106468Srwatson	int error;
238106468Srwatson
239106468Srwatson	if (mac_p == NULL)
240106468Srwatson		return (0);
241106468Srwatson
242106468Srwatson	error = copyin(mac_p, &mac, sizeof(mac));
243106468Srwatson	if (error)
244106468Srwatson		return (error);
245106468Srwatson
246106468Srwatson	error = mac_check_structmac_consistent(&mac);
247106468Srwatson	if (error)
248106468Srwatson		return (error);
249106468Srwatson
250111119Simp	buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK);
251106468Srwatson	error = copyinstr(mac.m_string, buffer, mac.m_buflen, NULL);
252106468Srwatson	if (error) {
253106468Srwatson		free(buffer, M_MACTEMP);
254106468Srwatson		return (error);
255106468Srwatson	}
256106468Srwatson
257122524Srwatson	label = mac_cred_label_alloc();
258122524Srwatson	error = mac_internalize_cred_label(label, buffer);
259106468Srwatson	free(buffer, M_MACTEMP);
260106468Srwatson	if (error) {
261122524Srwatson		mac_cred_label_free(label);
262106468Srwatson		return (error);
263106468Srwatson	}
264122524Srwatson	imgp->execlabel = label;
265106468Srwatson	return (0);
266106468Srwatson}
267106468Srwatson
268100979Srwatsonvoid
269106468Srwatsonmac_execve_exit(struct image_params *imgp)
270100979Srwatson{
271122524Srwatson	if (imgp->execlabel != NULL) {
272122524Srwatson		mac_cred_label_free(imgp->execlabel);
273122524Srwatson		imgp->execlabel = NULL;
274122524Srwatson	}
275106468Srwatson}
276100979Srwatson
277100979Srwatson/*
278100979Srwatson * When relabeling a process, call out to the policies for the maximum
279100979Srwatson * permission allowed for each object type we know about in its
280100979Srwatson * memory space, and revoke access (in the least surprising ways we
281100979Srwatson * know) when necessary.  The process lock is not held here.
282100979Srwatson */
283107271Srwatsonvoid
284100979Srwatsonmac_cred_mmapped_drop_perms(struct thread *td, struct ucred *cred)
285100979Srwatson{
286100979Srwatson
287100979Srwatson	/* XXX freeze all other threads */
288100979Srwatson	mac_cred_mmapped_drop_perms_recurse(td, cred,
289100979Srwatson	    &td->td_proc->p_vmspace->vm_map);
290100979Srwatson	/* XXX allow other threads to continue */
291100979Srwatson}
292100979Srwatson
293100979Srwatsonstatic __inline const char *
294100979Srwatsonprot2str(vm_prot_t prot)
295100979Srwatson{
296100979Srwatson
297100979Srwatson	switch (prot & VM_PROT_ALL) {
298100979Srwatson	case VM_PROT_READ:
299100979Srwatson		return ("r--");
300100979Srwatson	case VM_PROT_READ | VM_PROT_WRITE:
301100979Srwatson		return ("rw-");
302100979Srwatson	case VM_PROT_READ | VM_PROT_EXECUTE:
303100979Srwatson		return ("r-x");
304100979Srwatson	case VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE:
305100979Srwatson		return ("rwx");
306100979Srwatson	case VM_PROT_WRITE:
307100979Srwatson		return ("-w-");
308100979Srwatson	case VM_PROT_EXECUTE:
309100979Srwatson		return ("--x");
310100979Srwatson	case VM_PROT_WRITE | VM_PROT_EXECUTE:
311100979Srwatson		return ("-wx");
312100979Srwatson	default:
313100979Srwatson		return ("---");
314100979Srwatson	}
315100979Srwatson}
316100979Srwatson
317100979Srwatsonstatic void
318100979Srwatsonmac_cred_mmapped_drop_perms_recurse(struct thread *td, struct ucred *cred,
319100979Srwatson    struct vm_map *map)
320100979Srwatson{
321100979Srwatson	struct vm_map_entry *vme;
322104546Srwatson	int result;
323104546Srwatson	vm_prot_t revokeperms;
324100979Srwatson	vm_object_t object;
325100979Srwatson	vm_ooffset_t offset;
326100979Srwatson	struct vnode *vp;
327100979Srwatson
328103136Srwatson	if (!mac_mmap_revocation)
329103136Srwatson		return;
330103136Srwatson
331100979Srwatson	vm_map_lock_read(map);
332100979Srwatson	for (vme = map->header.next; vme != &map->header; vme = vme->next) {
333100979Srwatson		if (vme->eflags & MAP_ENTRY_IS_SUB_MAP) {
334100979Srwatson			mac_cred_mmapped_drop_perms_recurse(td, cred,
335100979Srwatson			    vme->object.sub_map);
336100979Srwatson			continue;
337100979Srwatson		}
338100979Srwatson		/*
339100979Srwatson		 * Skip over entries that obviously are not shared.
340100979Srwatson		 */
341100979Srwatson		if (vme->eflags & (MAP_ENTRY_COW | MAP_ENTRY_NOSYNC) ||
342100979Srwatson		    !vme->max_protection)
343100979Srwatson			continue;
344100979Srwatson		/*
345100979Srwatson		 * Drill down to the deepest backing object.
346100979Srwatson		 */
347100979Srwatson		offset = vme->offset;
348100979Srwatson		object = vme->object.vm_object;
349100979Srwatson		if (object == NULL)
350100979Srwatson			continue;
351100979Srwatson		while (object->backing_object != NULL) {
352100979Srwatson			object = object->backing_object;
353100979Srwatson			offset += object->backing_object_offset;
354100979Srwatson		}
355100979Srwatson		/*
356100979Srwatson		 * At the moment, vm_maps and objects aren't considered
357100979Srwatson		 * by the MAC system, so only things with backing by a
358100979Srwatson		 * normal object (read: vnodes) are checked.
359100979Srwatson		 */
360100979Srwatson		if (object->type != OBJT_VNODE)
361100979Srwatson			continue;
362100979Srwatson		vp = (struct vnode *)object->handle;
363100979Srwatson		vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
364104546Srwatson		result = vme->max_protection;
365104546Srwatson		mac_check_vnode_mmap_downgrade(cred, vp, &result);
366100979Srwatson		VOP_UNLOCK(vp, 0, td);
367100979Srwatson		/*
368100979Srwatson		 * Find out what maximum protection we may be allowing
369100979Srwatson		 * now but a policy needs to get removed.
370100979Srwatson		 */
371100979Srwatson		revokeperms = vme->max_protection & ~result;
372100979Srwatson		if (!revokeperms)
373100979Srwatson			continue;
374102949Sbde		printf("pid %ld: revoking %s perms from %#lx:%ld "
375102949Sbde		    "(max %s/cur %s)\n", (long)td->td_proc->p_pid,
376102949Sbde		    prot2str(revokeperms), (u_long)vme->start,
377102949Sbde		    (long)(vme->end - vme->start),
378100979Srwatson		    prot2str(vme->max_protection), prot2str(vme->protection));
379100979Srwatson		vm_map_lock_upgrade(map);
380100979Srwatson		/*
381100979Srwatson		 * This is the really simple case: if a map has more
382100979Srwatson		 * max_protection than is allowed, but it's not being
383100979Srwatson		 * actually used (that is, the current protection is
384100979Srwatson		 * still allowed), we can just wipe it out and do
385100979Srwatson		 * nothing more.
386100979Srwatson		 */
387100979Srwatson		if ((vme->protection & revokeperms) == 0) {
388100979Srwatson			vme->max_protection -= revokeperms;
389100979Srwatson		} else {
390100979Srwatson			if (revokeperms & VM_PROT_WRITE) {
391100979Srwatson				/*
392100979Srwatson				 * In the more complicated case, flush out all
393100979Srwatson				 * pending changes to the object then turn it
394100979Srwatson				 * copy-on-write.
395100979Srwatson				 */
396100979Srwatson				vm_object_reference(object);
397100979Srwatson				vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
398113955Salc				VM_OBJECT_LOCK(object);
399100979Srwatson				vm_object_page_clean(object,
400100979Srwatson				    OFF_TO_IDX(offset),
401100979Srwatson				    OFF_TO_IDX(offset + vme->end - vme->start +
402100979Srwatson					PAGE_MASK),
403100979Srwatson				    OBJPC_SYNC);
404113955Salc				VM_OBJECT_UNLOCK(object);
405100979Srwatson				VOP_UNLOCK(vp, 0, td);
406100979Srwatson				vm_object_deallocate(object);
407100979Srwatson				/*
408100979Srwatson				 * Why bother if there's no read permissions
409100979Srwatson				 * anymore?  For the rest, we need to leave
410100979Srwatson				 * the write permissions on for COW, or
411100979Srwatson				 * remove them entirely if configured to.
412100979Srwatson				 */
413100979Srwatson				if (!mac_mmap_revocation_via_cow) {
414100979Srwatson					vme->max_protection &= ~VM_PROT_WRITE;
415100979Srwatson					vme->protection &= ~VM_PROT_WRITE;
416100979Srwatson				} if ((revokeperms & VM_PROT_READ) == 0)
417100979Srwatson					vme->eflags |= MAP_ENTRY_COW |
418100979Srwatson					    MAP_ENTRY_NEEDS_COPY;
419100979Srwatson			}
420100979Srwatson			if (revokeperms & VM_PROT_EXECUTE) {
421100979Srwatson				vme->max_protection &= ~VM_PROT_EXECUTE;
422100979Srwatson				vme->protection &= ~VM_PROT_EXECUTE;
423100979Srwatson			}
424100979Srwatson			if (revokeperms & VM_PROT_READ) {
425100979Srwatson				vme->max_protection = 0;
426100979Srwatson				vme->protection = 0;
427100979Srwatson			}
428100979Srwatson			pmap_protect(map->pmap, vme->start, vme->end,
429100979Srwatson			    vme->protection & ~revokeperms);
430100979Srwatson			vm_map_simplify_entry(map, vme);
431100979Srwatson		}
432100979Srwatson		vm_map_lock_downgrade(map);
433100979Srwatson	}
434100979Srwatson	vm_map_unlock_read(map);
435100979Srwatson}
436100979Srwatson
437100979Srwatson/*
438100979Srwatson * When the subject's label changes, it may require revocation of privilege
439100979Srwatson * to mapped objects.  This can't be done on-the-fly later with a unified
440100979Srwatson * buffer cache.
441100979Srwatson */
442121361Srwatsonvoid
443100979Srwatsonmac_relabel_cred(struct ucred *cred, struct label *newlabel)
444100979Srwatson{
445100979Srwatson
446100979Srwatson	MAC_PERFORM(relabel_cred, cred, newlabel);
447100979Srwatson}
448100979Srwatson
449100979Srwatsonint
450100979Srwatsonmac_check_cred_relabel(struct ucred *cred, struct label *newlabel)
451100979Srwatson{
452100979Srwatson	int error;
453100979Srwatson
454100979Srwatson	MAC_CHECK(check_cred_relabel, cred, newlabel);
455100979Srwatson
456100979Srwatson	return (error);
457100979Srwatson}
458100979Srwatson
459100979Srwatsonint
460100979Srwatsonmac_check_cred_visible(struct ucred *u1, struct ucred *u2)
461100979Srwatson{
462100979Srwatson	int error;
463100979Srwatson
464100979Srwatson	if (!mac_enforce_process)
465100979Srwatson		return (0);
466100979Srwatson
467100979Srwatson	MAC_CHECK(check_cred_visible, u1, u2);
468100979Srwatson
469100979Srwatson	return (error);
470100979Srwatson}
471100979Srwatson
472100979Srwatsonint
473100979Srwatsonmac_check_proc_debug(struct ucred *cred, struct proc *proc)
474100979Srwatson{
475100979Srwatson	int error;
476100979Srwatson
477102103Srwatson	PROC_LOCK_ASSERT(proc, MA_OWNED);
478102103Srwatson
479100979Srwatson	if (!mac_enforce_process)
480100979Srwatson		return (0);
481100979Srwatson
482100979Srwatson	MAC_CHECK(check_proc_debug, cred, proc);
483100979Srwatson
484100979Srwatson	return (error);
485100979Srwatson}
486100979Srwatson
487100979Srwatsonint
488100979Srwatsonmac_check_proc_sched(struct ucred *cred, struct proc *proc)
489100979Srwatson{
490100979Srwatson	int error;
491100979Srwatson
492102103Srwatson	PROC_LOCK_ASSERT(proc, MA_OWNED);
493102103Srwatson
494100979Srwatson	if (!mac_enforce_process)
495100979Srwatson		return (0);
496100979Srwatson
497100979Srwatson	MAC_CHECK(check_proc_sched, cred, proc);
498100979Srwatson
499100979Srwatson	return (error);
500100979Srwatson}
501100979Srwatson
502100979Srwatsonint
503100979Srwatsonmac_check_proc_signal(struct ucred *cred, struct proc *proc, int signum)
504100979Srwatson{
505100979Srwatson	int error;
506100979Srwatson
507102103Srwatson	PROC_LOCK_ASSERT(proc, MA_OWNED);
508102103Srwatson
509100979Srwatson	if (!mac_enforce_process)
510100979Srwatson		return (0);
511100979Srwatson
512100979Srwatson	MAC_CHECK(check_proc_signal, cred, proc, signum);
513100979Srwatson
514100979Srwatson	return (error);
515100979Srwatson}
516