mac_cred.c revision 172930
1100894Srwatson/*- 2126097Srwatson * Copyright (c) 1999-2002 Robert N. M. Watson 3100894Srwatson * Copyright (c) 2001 Ilmar S. Habibulin 4126097Srwatson * Copyright (c) 2001-2003 Networks Associates Technology, Inc. 5145147Srwatson * Copyright (c) 2005 Samy Al Bahra 6172930Srwatson * Copyright (c) 2006 SPARTA, Inc. 7100894Srwatson * All rights reserved. 8100894Srwatson * 9100894Srwatson * This software was developed by Robert Watson and Ilmar Habibulin for the 10100894Srwatson * TrustedBSD Project. 11100894Srwatson * 12106392Srwatson * This software was developed for the FreeBSD Project in part by Network 13106392Srwatson * Associates Laboratories, the Security Research Division of Network 14106392Srwatson * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), 15106392Srwatson * as part of the DARPA CHATS research program. 16100894Srwatson * 17172930Srwatson * This software was enhanced by SPARTA ISSO under SPAWAR contract 18172930Srwatson * N66001-04-C-6019 ("SEFOS"). 19172930Srwatson * 20100894Srwatson * Redistribution and use in source and binary forms, with or without 21100894Srwatson * modification, are permitted provided that the following conditions 22100894Srwatson * are met: 23100894Srwatson * 1. Redistributions of source code must retain the above copyright 24100894Srwatson * notice, this list of conditions and the following disclaimer. 25100894Srwatson * 2. Redistributions in binary form must reproduce the above copyright 26100894Srwatson * notice, this list of conditions and the following disclaimer in the 27100894Srwatson * documentation and/or other materials provided with the distribution. 28100894Srwatson * 29100894Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 30100894Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 31100894Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 32100894Srwatson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 33100894Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34100894Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35100894Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36100894Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37100894Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38100894Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39100894Srwatson * SUCH DAMAGE. 40100894Srwatson */ 41116182Sobrien 42116182Sobrien#include <sys/cdefs.h> 43116182Sobrien__FBSDID("$FreeBSD: head/sys/security/mac/mac_process.c 172930 2007-10-24 19:04:04Z rwatson $"); 44116182Sobrien 45100894Srwatson#include "opt_mac.h" 46101173Srwatson 47100894Srwatson#include <sys/param.h> 48106856Srwatson#include <sys/condvar.h> 49106468Srwatson#include <sys/imgact.h> 50100979Srwatson#include <sys/kernel.h> 51100979Srwatson#include <sys/lock.h> 52102949Sbde#include <sys/malloc.h> 53100979Srwatson#include <sys/mutex.h> 54100979Srwatson#include <sys/mac.h> 55100979Srwatson#include <sys/proc.h> 56116701Srwatson#include <sys/sbuf.h> 57100979Srwatson#include <sys/systm.h> 58100979Srwatson#include <sys/vnode.h> 59100979Srwatson#include <sys/mount.h> 60100979Srwatson#include <sys/file.h> 61100979Srwatson#include <sys/namei.h> 62100979Srwatson#include <sys/sysctl.h> 63100894Srwatson 64100979Srwatson#include <vm/vm.h> 65100979Srwatson#include <vm/pmap.h> 66100979Srwatson#include <vm/vm_map.h> 67100979Srwatson#include <vm/vm_object.h> 68100979Srwatson 69163606Srwatson#include <security/mac/mac_framework.h> 70121361Srwatson#include <security/mac/mac_internal.h> 71165469Srwatson#include <security/mac/mac_policy.h> 72100979Srwatson 73103136Srwatsonstatic int mac_mmap_revocation = 1; 74103136SrwatsonSYSCTL_INT(_security_mac, OID_AUTO, mmap_revocation, CTLFLAG_RW, 75103136Srwatson &mac_mmap_revocation, 0, "Revoke mmap access to files on subject " 76103136Srwatson "relabel"); 77121361Srwatson 78101892Srwatsonstatic int mac_mmap_revocation_via_cow = 0; 79100979SrwatsonSYSCTL_INT(_security_mac, OID_AUTO, mmap_revocation_via_cow, CTLFLAG_RW, 80100979Srwatson &mac_mmap_revocation_via_cow, 0, "Revoke mmap access to files via " 81100979Srwatson "copy-on-write semantics, or by removing all write access"); 82100979Srwatson 83100979Srwatsonstatic void mac_cred_mmapped_drop_perms_recurse(struct thread *td, 84100979Srwatson struct ucred *cred, struct vm_map *map); 85100979Srwatson 86122524Srwatsonstruct label * 87122524Srwatsonmac_cred_label_alloc(void) 88104521Srwatson{ 89122524Srwatson struct label *label; 90104521Srwatson 91122524Srwatson label = mac_labelzone_alloc(M_WAITOK); 92172930Srwatson MAC_PERFORM(cred_init_label, label); 93122524Srwatson return (label); 94104521Srwatson} 95104521Srwatson 96104521Srwatsonvoid 97172930Srwatsonmac_cred_init(struct ucred *cred) 98105694Srwatson{ 99105694Srwatson 100122524Srwatson cred->cr_label = mac_cred_label_alloc(); 101105694Srwatson} 102105694Srwatson 103122524Srwatsonstatic struct label * 104122524Srwatsonmac_proc_label_alloc(void) 105122524Srwatson{ 106122524Srwatson struct label *label; 107122524Srwatson 108122524Srwatson label = mac_labelzone_alloc(M_WAITOK); 109172930Srwatson MAC_PERFORM(proc_init_label, label); 110122524Srwatson return (label); 111122524Srwatson} 112122524Srwatson 113105694Srwatsonvoid 114172930Srwatsonmac_proc_init(struct proc *p) 115107105Srwatson{ 116107105Srwatson 117122524Srwatson p->p_label = mac_proc_label_alloc(); 118107105Srwatson} 119107105Srwatson 120105988Srwatsonvoid 121122524Srwatsonmac_cred_label_free(struct label *label) 122104521Srwatson{ 123104521Srwatson 124172930Srwatson MAC_PERFORM(cred_destroy_label, label); 125122524Srwatson mac_labelzone_free(label); 126104521Srwatson} 127104521Srwatson 128104521Srwatsonvoid 129172930Srwatsonmac_cred_destroy(struct ucred *cred) 130105694Srwatson{ 131105694Srwatson 132122524Srwatson mac_cred_label_free(cred->cr_label); 133122524Srwatson cred->cr_label = NULL; 134105694Srwatson} 135105694Srwatson 136122524Srwatsonstatic void 137122524Srwatsonmac_proc_label_free(struct label *label) 138122524Srwatson{ 139122524Srwatson 140172930Srwatson MAC_PERFORM(proc_destroy_label, label); 141122524Srwatson mac_labelzone_free(label); 142122524Srwatson} 143122524Srwatson 144105694Srwatsonvoid 145172930Srwatsonmac_proc_destroy(struct proc *p) 146107105Srwatson{ 147107105Srwatson 148122524Srwatson mac_proc_label_free(p->p_label); 149122524Srwatson p->p_label = NULL; 150107105Srwatson} 151107105Srwatson 152121361Srwatsonint 153172930Srwatsonmac_cred_externalize_label(struct label *label, char *elements, 154122159Srwatson char *outbuf, size_t outbuflen) 155105694Srwatson{ 156104522Srwatson int error; 157104522Srwatson 158121507Srwatson MAC_EXTERNALIZE(cred, label, elements, outbuf, outbuflen); 159104522Srwatson 160104522Srwatson return (error); 161104522Srwatson} 162104522Srwatson 163121361Srwatsonint 164172930Srwatsonmac_cred_internalize_label(struct label *label, char *string) 165105694Srwatson{ 166105694Srwatson int error; 167105694Srwatson 168121507Srwatson MAC_INTERNALIZE(cred, label, string); 169105694Srwatson 170105694Srwatson return (error); 171105694Srwatson} 172105694Srwatson 173104522Srwatson/* 174165425Srwatson * Initialize MAC label for the first kernel process, from which other kernel 175165425Srwatson * processes and threads are spawned. 176104522Srwatson */ 177104521Srwatsonvoid 178172930Srwatsonmac_proc_create_swapper(struct ucred *cred) 179104522Srwatson{ 180104522Srwatson 181172930Srwatson MAC_PERFORM(proc_create_swapper, cred); 182104522Srwatson} 183104522Srwatson 184104522Srwatson/* 185104522Srwatson * Initialize MAC label for the first userland process, from which other 186104522Srwatson * userland processes and threads are spawned. 187104522Srwatson */ 188104522Srwatsonvoid 189172930Srwatsonmac_proc_create_init(struct ucred *cred) 190104522Srwatson{ 191104522Srwatson 192172930Srwatson MAC_PERFORM(proc_create_init, cred); 193104522Srwatson} 194104522Srwatson 195104522Srwatsonvoid 196104522Srwatsonmac_thread_userret(struct thread *td) 197104522Srwatson{ 198104522Srwatson 199104522Srwatson MAC_PERFORM(thread_userret, td); 200104522Srwatson} 201104522Srwatson 202104522Srwatson/* 203104522Srwatson * When a new process is created, its label must be initialized. Generally, 204165425Srwatson * this involves inheritence from the parent process, modulo possible deltas. 205165425Srwatson * This function allows that processing to take place. 206104522Srwatson */ 207104522Srwatsonvoid 208172930Srwatsonmac_cred_copy(struct ucred *src, struct ucred *dest) 209104522Srwatson{ 210104522Srwatson 211172930Srwatson MAC_PERFORM(cred_copy_label, src->cr_label, dest->cr_label); 212104522Srwatson} 213104522Srwatson 214105988Srwatsonint 215122524Srwatsonmac_execve_enter(struct image_params *imgp, struct mac *mac_p) 216106468Srwatson{ 217122524Srwatson struct label *label; 218106468Srwatson struct mac mac; 219106468Srwatson char *buffer; 220106468Srwatson int error; 221106468Srwatson 222106468Srwatson if (mac_p == NULL) 223106468Srwatson return (0); 224106468Srwatson 225106468Srwatson error = copyin(mac_p, &mac, sizeof(mac)); 226106468Srwatson if (error) 227106468Srwatson return (error); 228106468Srwatson 229106468Srwatson error = mac_check_structmac_consistent(&mac); 230106468Srwatson if (error) 231106468Srwatson return (error); 232106468Srwatson 233111119Simp buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK); 234106468Srwatson error = copyinstr(mac.m_string, buffer, mac.m_buflen, NULL); 235106468Srwatson if (error) { 236106468Srwatson free(buffer, M_MACTEMP); 237106468Srwatson return (error); 238106468Srwatson } 239106468Srwatson 240122524Srwatson label = mac_cred_label_alloc(); 241172930Srwatson error = mac_cred_internalize_label(label, buffer); 242106468Srwatson free(buffer, M_MACTEMP); 243106468Srwatson if (error) { 244122524Srwatson mac_cred_label_free(label); 245106468Srwatson return (error); 246106468Srwatson } 247122524Srwatson imgp->execlabel = label; 248106468Srwatson return (0); 249106468Srwatson} 250106468Srwatson 251100979Srwatsonvoid 252106468Srwatsonmac_execve_exit(struct image_params *imgp) 253100979Srwatson{ 254122524Srwatson if (imgp->execlabel != NULL) { 255122524Srwatson mac_cred_label_free(imgp->execlabel); 256122524Srwatson imgp->execlabel = NULL; 257122524Srwatson } 258106468Srwatson} 259100979Srwatson 260100979Srwatson/* 261100979Srwatson * When relabeling a process, call out to the policies for the maximum 262165425Srwatson * permission allowed for each object type we know about in its memory space, 263165425Srwatson * and revoke access (in the least surprising ways we know) when necessary. 264165425Srwatson * The process lock is not held here. 265100979Srwatson */ 266107271Srwatsonvoid 267100979Srwatsonmac_cred_mmapped_drop_perms(struct thread *td, struct ucred *cred) 268100979Srwatson{ 269100979Srwatson 270100979Srwatson /* XXX freeze all other threads */ 271100979Srwatson mac_cred_mmapped_drop_perms_recurse(td, cred, 272100979Srwatson &td->td_proc->p_vmspace->vm_map); 273100979Srwatson /* XXX allow other threads to continue */ 274100979Srwatson} 275100979Srwatson 276100979Srwatsonstatic __inline const char * 277100979Srwatsonprot2str(vm_prot_t prot) 278100979Srwatson{ 279100979Srwatson 280100979Srwatson switch (prot & VM_PROT_ALL) { 281100979Srwatson case VM_PROT_READ: 282100979Srwatson return ("r--"); 283100979Srwatson case VM_PROT_READ | VM_PROT_WRITE: 284100979Srwatson return ("rw-"); 285100979Srwatson case VM_PROT_READ | VM_PROT_EXECUTE: 286100979Srwatson return ("r-x"); 287100979Srwatson case VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE: 288100979Srwatson return ("rwx"); 289100979Srwatson case VM_PROT_WRITE: 290100979Srwatson return ("-w-"); 291100979Srwatson case VM_PROT_EXECUTE: 292100979Srwatson return ("--x"); 293100979Srwatson case VM_PROT_WRITE | VM_PROT_EXECUTE: 294100979Srwatson return ("-wx"); 295100979Srwatson default: 296100979Srwatson return ("---"); 297100979Srwatson } 298100979Srwatson} 299100979Srwatson 300100979Srwatsonstatic void 301100979Srwatsonmac_cred_mmapped_drop_perms_recurse(struct thread *td, struct ucred *cred, 302100979Srwatson struct vm_map *map) 303100979Srwatson{ 304100979Srwatson struct vm_map_entry *vme; 305150913Scsjp int vfslocked, result; 306104546Srwatson vm_prot_t revokeperms; 307151115Scsjp vm_object_t backing_object, object; 308100979Srwatson vm_ooffset_t offset; 309100979Srwatson struct vnode *vp; 310156225Stegge struct mount *mp; 311100979Srwatson 312103136Srwatson if (!mac_mmap_revocation) 313103136Srwatson return; 314103136Srwatson 315100979Srwatson vm_map_lock_read(map); 316100979Srwatson for (vme = map->header.next; vme != &map->header; vme = vme->next) { 317100979Srwatson if (vme->eflags & MAP_ENTRY_IS_SUB_MAP) { 318100979Srwatson mac_cred_mmapped_drop_perms_recurse(td, cred, 319100979Srwatson vme->object.sub_map); 320100979Srwatson continue; 321100979Srwatson } 322100979Srwatson /* 323100979Srwatson * Skip over entries that obviously are not shared. 324100979Srwatson */ 325100979Srwatson if (vme->eflags & (MAP_ENTRY_COW | MAP_ENTRY_NOSYNC) || 326100979Srwatson !vme->max_protection) 327100979Srwatson continue; 328100979Srwatson /* 329100979Srwatson * Drill down to the deepest backing object. 330100979Srwatson */ 331100979Srwatson offset = vme->offset; 332100979Srwatson object = vme->object.vm_object; 333100979Srwatson if (object == NULL) 334100979Srwatson continue; 335151115Scsjp VM_OBJECT_LOCK(object); 336151115Scsjp while ((backing_object = object->backing_object) != NULL) { 337151115Scsjp VM_OBJECT_LOCK(backing_object); 338150923Scsjp offset += object->backing_object_offset; 339151115Scsjp VM_OBJECT_UNLOCK(object); 340151115Scsjp object = backing_object; 341100979Srwatson } 342151115Scsjp VM_OBJECT_UNLOCK(object); 343100979Srwatson /* 344165425Srwatson * At the moment, vm_maps and objects aren't considered by 345165425Srwatson * the MAC system, so only things with backing by a normal 346165425Srwatson * object (read: vnodes) are checked. 347100979Srwatson */ 348100979Srwatson if (object->type != OBJT_VNODE) 349100979Srwatson continue; 350100979Srwatson vp = (struct vnode *)object->handle; 351150913Scsjp vfslocked = VFS_LOCK_GIANT(vp->v_mount); 352100979Srwatson vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); 353104546Srwatson result = vme->max_protection; 354172930Srwatson mac_vnode_check_mmap_downgrade(cred, vp, &result); 355100979Srwatson VOP_UNLOCK(vp, 0, td); 356100979Srwatson /* 357165425Srwatson * Find out what maximum protection we may be allowing now 358165425Srwatson * but a policy needs to get removed. 359100979Srwatson */ 360100979Srwatson revokeperms = vme->max_protection & ~result; 361150913Scsjp if (!revokeperms) { 362150913Scsjp VFS_UNLOCK_GIANT(vfslocked); 363100979Srwatson continue; 364150913Scsjp } 365102949Sbde printf("pid %ld: revoking %s perms from %#lx:%ld " 366102949Sbde "(max %s/cur %s)\n", (long)td->td_proc->p_pid, 367102949Sbde prot2str(revokeperms), (u_long)vme->start, 368102949Sbde (long)(vme->end - vme->start), 369100979Srwatson prot2str(vme->max_protection), prot2str(vme->protection)); 370100979Srwatson vm_map_lock_upgrade(map); 371100979Srwatson /* 372100979Srwatson * This is the really simple case: if a map has more 373100979Srwatson * max_protection than is allowed, but it's not being 374165425Srwatson * actually used (that is, the current protection is still 375165425Srwatson * allowed), we can just wipe it out and do nothing more. 376100979Srwatson */ 377100979Srwatson if ((vme->protection & revokeperms) == 0) { 378100979Srwatson vme->max_protection -= revokeperms; 379100979Srwatson } else { 380100979Srwatson if (revokeperms & VM_PROT_WRITE) { 381100979Srwatson /* 382100979Srwatson * In the more complicated case, flush out all 383100979Srwatson * pending changes to the object then turn it 384100979Srwatson * copy-on-write. 385100979Srwatson */ 386100979Srwatson vm_object_reference(object); 387156225Stegge (void) vn_start_write(vp, &mp, V_WAIT); 388100979Srwatson vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); 389113955Salc VM_OBJECT_LOCK(object); 390100979Srwatson vm_object_page_clean(object, 391100979Srwatson OFF_TO_IDX(offset), 392100979Srwatson OFF_TO_IDX(offset + vme->end - vme->start + 393100979Srwatson PAGE_MASK), 394100979Srwatson OBJPC_SYNC); 395113955Salc VM_OBJECT_UNLOCK(object); 396100979Srwatson VOP_UNLOCK(vp, 0, td); 397156225Stegge vn_finished_write(mp); 398100979Srwatson vm_object_deallocate(object); 399100979Srwatson /* 400100979Srwatson * Why bother if there's no read permissions 401100979Srwatson * anymore? For the rest, we need to leave 402100979Srwatson * the write permissions on for COW, or 403100979Srwatson * remove them entirely if configured to. 404100979Srwatson */ 405100979Srwatson if (!mac_mmap_revocation_via_cow) { 406100979Srwatson vme->max_protection &= ~VM_PROT_WRITE; 407100979Srwatson vme->protection &= ~VM_PROT_WRITE; 408100979Srwatson } if ((revokeperms & VM_PROT_READ) == 0) 409100979Srwatson vme->eflags |= MAP_ENTRY_COW | 410100979Srwatson MAP_ENTRY_NEEDS_COPY; 411100979Srwatson } 412100979Srwatson if (revokeperms & VM_PROT_EXECUTE) { 413100979Srwatson vme->max_protection &= ~VM_PROT_EXECUTE; 414100979Srwatson vme->protection &= ~VM_PROT_EXECUTE; 415100979Srwatson } 416100979Srwatson if (revokeperms & VM_PROT_READ) { 417100979Srwatson vme->max_protection = 0; 418100979Srwatson vme->protection = 0; 419100979Srwatson } 420100979Srwatson pmap_protect(map->pmap, vme->start, vme->end, 421100979Srwatson vme->protection & ~revokeperms); 422100979Srwatson vm_map_simplify_entry(map, vme); 423100979Srwatson } 424100979Srwatson vm_map_lock_downgrade(map); 425150913Scsjp VFS_UNLOCK_GIANT(vfslocked); 426100979Srwatson } 427100979Srwatson vm_map_unlock_read(map); 428100979Srwatson} 429100979Srwatson 430100979Srwatson/* 431100979Srwatson * When the subject's label changes, it may require revocation of privilege 432100979Srwatson * to mapped objects. This can't be done on-the-fly later with a unified 433100979Srwatson * buffer cache. 434100979Srwatson */ 435121361Srwatsonvoid 436172930Srwatsonmac_cred_relabel(struct ucred *cred, struct label *newlabel) 437100979Srwatson{ 438100979Srwatson 439172930Srwatson MAC_PERFORM(cred_relabel, cred, newlabel); 440100979Srwatson} 441100979Srwatson 442100979Srwatsonint 443172930Srwatsonmac_cred_check_relabel(struct ucred *cred, struct label *newlabel) 444100979Srwatson{ 445100979Srwatson int error; 446100979Srwatson 447172930Srwatson MAC_CHECK(cred_check_relabel, cred, newlabel); 448100979Srwatson 449100979Srwatson return (error); 450100979Srwatson} 451100979Srwatson 452100979Srwatsonint 453172930Srwatsonmac_cred_check_visible(struct ucred *cr1, struct ucred *cr2) 454100979Srwatson{ 455100979Srwatson int error; 456100979Srwatson 457172930Srwatson MAC_CHECK(cred_check_visible, cr1, cr2); 458100979Srwatson 459100979Srwatson return (error); 460100979Srwatson} 461100979Srwatson 462100979Srwatsonint 463172930Srwatsonmac_proc_check_debug(struct ucred *cred, struct proc *p) 464100979Srwatson{ 465100979Srwatson int error; 466100979Srwatson 467168955Srwatson PROC_LOCK_ASSERT(p, MA_OWNED); 468102103Srwatson 469172930Srwatson MAC_CHECK(proc_check_debug, cred, p); 470100979Srwatson 471100979Srwatson return (error); 472100979Srwatson} 473100979Srwatson 474100979Srwatsonint 475172930Srwatsonmac_proc_check_sched(struct ucred *cred, struct proc *p) 476100979Srwatson{ 477100979Srwatson int error; 478100979Srwatson 479168955Srwatson PROC_LOCK_ASSERT(p, MA_OWNED); 480102103Srwatson 481172930Srwatson MAC_CHECK(proc_check_sched, cred, p); 482100979Srwatson 483100979Srwatson return (error); 484100979Srwatson} 485100979Srwatson 486100979Srwatsonint 487172930Srwatsonmac_proc_check_signal(struct ucred *cred, struct proc *p, int signum) 488100979Srwatson{ 489100979Srwatson int error; 490100979Srwatson 491168955Srwatson PROC_LOCK_ASSERT(p, MA_OWNED); 492102103Srwatson 493172930Srwatson MAC_CHECK(proc_check_signal, cred, p, signum); 494100979Srwatson 495100979Srwatson return (error); 496100979Srwatson} 497145147Srwatson 498145147Srwatsonint 499172930Srwatsonmac_proc_check_setuid(struct proc *p, struct ucred *cred, uid_t uid) 500145147Srwatson{ 501145147Srwatson int error; 502145147Srwatson 503168955Srwatson PROC_LOCK_ASSERT(p, MA_OWNED); 504145147Srwatson 505172930Srwatson MAC_CHECK(proc_check_setuid, cred, uid); 506145147Srwatson return (error); 507145147Srwatson} 508145147Srwatson 509145147Srwatsonint 510172930Srwatsonmac_proc_check_seteuid(struct proc *p, struct ucred *cred, uid_t euid) 511145147Srwatson{ 512145147Srwatson int error; 513145147Srwatson 514168955Srwatson PROC_LOCK_ASSERT(p, MA_OWNED); 515145147Srwatson 516172930Srwatson MAC_CHECK(proc_check_seteuid, cred, euid); 517145147Srwatson return (error); 518145147Srwatson} 519145147Srwatson 520145147Srwatsonint 521172930Srwatsonmac_proc_check_setgid(struct proc *p, struct ucred *cred, gid_t gid) 522145147Srwatson{ 523145147Srwatson int error; 524145147Srwatson 525168955Srwatson PROC_LOCK_ASSERT(p, MA_OWNED); 526145147Srwatson 527172930Srwatson MAC_CHECK(proc_check_setgid, cred, gid); 528168955Srwatson 529145147Srwatson return (error); 530145147Srwatson} 531145147Srwatson 532145147Srwatsonint 533172930Srwatsonmac_proc_check_setegid(struct proc *p, struct ucred *cred, gid_t egid) 534145147Srwatson{ 535145147Srwatson int error; 536145147Srwatson 537168955Srwatson PROC_LOCK_ASSERT(p, MA_OWNED); 538145147Srwatson 539172930Srwatson MAC_CHECK(proc_check_setegid, cred, egid); 540168955Srwatson 541145147Srwatson return (error); 542145147Srwatson} 543145147Srwatson 544145147Srwatsonint 545172930Srwatsonmac_proc_check_setgroups(struct proc *p, struct ucred *cred, int ngroups, 546168955Srwatson gid_t *gidset) 547145147Srwatson{ 548145147Srwatson int error; 549145147Srwatson 550168955Srwatson PROC_LOCK_ASSERT(p, MA_OWNED); 551145147Srwatson 552172930Srwatson MAC_CHECK(proc_check_setgroups, cred, ngroups, gidset); 553145147Srwatson return (error); 554145147Srwatson} 555145147Srwatson 556145147Srwatsonint 557172930Srwatsonmac_proc_check_setreuid(struct proc *p, struct ucred *cred, uid_t ruid, 558168955Srwatson uid_t euid) 559145147Srwatson{ 560145147Srwatson int error; 561145147Srwatson 562168955Srwatson PROC_LOCK_ASSERT(p, MA_OWNED); 563145147Srwatson 564172930Srwatson MAC_CHECK(proc_check_setreuid, cred, ruid, euid); 565168955Srwatson 566145147Srwatson return (error); 567145147Srwatson} 568145147Srwatson 569145147Srwatsonint 570172930Srwatsonmac_proc_check_setregid(struct proc *proc, struct ucred *cred, gid_t rgid, 571168955Srwatson gid_t egid) 572145147Srwatson{ 573145147Srwatson int error; 574145147Srwatson 575145147Srwatson PROC_LOCK_ASSERT(proc, MA_OWNED); 576145147Srwatson 577172930Srwatson MAC_CHECK(proc_check_setregid, cred, rgid, egid); 578168955Srwatson 579145147Srwatson return (error); 580145147Srwatson} 581145147Srwatson 582145147Srwatsonint 583172930Srwatsonmac_proc_check_setresuid(struct proc *p, struct ucred *cred, uid_t ruid, 584168955Srwatson uid_t euid, uid_t suid) 585145147Srwatson{ 586145147Srwatson int error; 587145147Srwatson 588168955Srwatson PROC_LOCK_ASSERT(p, MA_OWNED); 589145147Srwatson 590172930Srwatson MAC_CHECK(proc_check_setresuid, cred, ruid, euid, suid); 591145147Srwatson return (error); 592145147Srwatson} 593145147Srwatson 594145147Srwatsonint 595172930Srwatsonmac_proc_check_setresgid(struct proc *p, struct ucred *cred, gid_t rgid, 596168955Srwatson gid_t egid, gid_t sgid) 597145147Srwatson{ 598145147Srwatson int error; 599145147Srwatson 600168955Srwatson PROC_LOCK_ASSERT(p, MA_OWNED); 601145147Srwatson 602172930Srwatson MAC_CHECK(proc_check_setresgid, cred, rgid, egid, sgid); 603168955Srwatson 604145147Srwatson return (error); 605145147Srwatson} 606145234Srwatson 607145234Srwatsonint 608172930Srwatsonmac_proc_check_wait(struct ucred *cred, struct proc *p) 609145234Srwatson{ 610145234Srwatson int error; 611145234Srwatson 612168955Srwatson PROC_LOCK_ASSERT(p, MA_OWNED); 613145234Srwatson 614172930Srwatson MAC_CHECK(proc_check_wait, cred, p); 615145234Srwatson 616145234Srwatson return (error); 617145234Srwatson} 618