1*a1e26a70SApple OSS Distributions /* 2*a1e26a70SApple OSS Distributions * Copyright (c) 2007-2016 Apple Inc. All rights reserved. 3*a1e26a70SApple OSS Distributions * 4*a1e26a70SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5*a1e26a70SApple OSS Distributions * 6*a1e26a70SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code 7*a1e26a70SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License 8*a1e26a70SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in 9*a1e26a70SApple OSS Distributions * compliance with the License. The rights granted to you under the License 10*a1e26a70SApple OSS Distributions * may not be used to create, or enable the creation or redistribution of, 11*a1e26a70SApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to 12*a1e26a70SApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any 13*a1e26a70SApple OSS Distributions * terms of an Apple operating system software license agreement. 14*a1e26a70SApple OSS Distributions * 15*a1e26a70SApple OSS Distributions * Please obtain a copy of the License at 16*a1e26a70SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file. 17*a1e26a70SApple OSS Distributions * 18*a1e26a70SApple OSS Distributions * The Original Code and all software distributed under the License are 19*a1e26a70SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20*a1e26a70SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21*a1e26a70SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22*a1e26a70SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23*a1e26a70SApple OSS Distributions * Please see the License for the specific language governing rights and 24*a1e26a70SApple OSS Distributions * limitations under the License. 25*a1e26a70SApple OSS Distributions * 26*a1e26a70SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27*a1e26a70SApple OSS Distributions */ 28*a1e26a70SApple OSS Distributions /*- 29*a1e26a70SApple OSS Distributions * Copyright (c) 1999-2002 Robert N. M. Watson 30*a1e26a70SApple OSS Distributions * Copyright (c) 2001-2005 Networks Associates Technology, Inc. 31*a1e26a70SApple OSS Distributions * Copyright (c) 2005-2007 SPARTA, Inc. 32*a1e26a70SApple OSS Distributions * All rights reserved. 33*a1e26a70SApple OSS Distributions * 34*a1e26a70SApple OSS Distributions * This software was developed by Robert Watson for the TrustedBSD Project. 35*a1e26a70SApple OSS Distributions * 36*a1e26a70SApple OSS Distributions * This software was developed for the FreeBSD Project in part by Network 37*a1e26a70SApple OSS Distributions * Associates Laboratories, the Security Research Division of Network 38*a1e26a70SApple OSS Distributions * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), 39*a1e26a70SApple OSS Distributions * as part of the DARPA CHATS research program. 40*a1e26a70SApple OSS Distributions * 41*a1e26a70SApple OSS Distributions * This software was enhanced by SPARTA ISSO under SPAWAR contract 42*a1e26a70SApple OSS Distributions * N66001-04-C-6019 ("SEFOS"). 43*a1e26a70SApple OSS Distributions * 44*a1e26a70SApple OSS Distributions * Redistribution and use in source and binary forms, with or without 45*a1e26a70SApple OSS Distributions * modification, are permitted provided that the following conditions 46*a1e26a70SApple OSS Distributions * are met: 47*a1e26a70SApple OSS Distributions * 1. Redistributions of source code must retain the above copyright 48*a1e26a70SApple OSS Distributions * notice, this list of conditions and the following disclaimer. 49*a1e26a70SApple OSS Distributions * 2. Redistributions in binary form must reproduce the above copyright 50*a1e26a70SApple OSS Distributions * notice, this list of conditions and the following disclaimer in the 51*a1e26a70SApple OSS Distributions * documentation and/or other materials provided with the distribution. 52*a1e26a70SApple OSS Distributions * 53*a1e26a70SApple OSS Distributions * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 54*a1e26a70SApple OSS Distributions * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 55*a1e26a70SApple OSS Distributions * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 56*a1e26a70SApple OSS Distributions * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 57*a1e26a70SApple OSS Distributions * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 58*a1e26a70SApple OSS Distributions * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 59*a1e26a70SApple OSS Distributions * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 60*a1e26a70SApple OSS Distributions * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 61*a1e26a70SApple OSS Distributions * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 62*a1e26a70SApple OSS Distributions * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 63*a1e26a70SApple OSS Distributions * SUCH DAMAGE. 64*a1e26a70SApple OSS Distributions * 65*a1e26a70SApple OSS Distributions * $FreeBSD: src/sys/sys/mac_policy.h,v 1.39 2003/04/18 19:57:37 rwatson Exp $ 66*a1e26a70SApple OSS Distributions */ 67*a1e26a70SApple OSS Distributions 68*a1e26a70SApple OSS Distributions /** 69*a1e26a70SApple OSS Distributions * @file mac_policy.h 70*a1e26a70SApple OSS Distributions * @brief Kernel Interfaces for MAC policy modules 71*a1e26a70SApple OSS Distributions * 72*a1e26a70SApple OSS Distributions * This header defines the list of operations that are defined by the 73*a1e26a70SApple OSS Distributions * TrustedBSD MAC Framwork on Darwin. MAC Policy modules register 74*a1e26a70SApple OSS Distributions * with the framework to declare interest in a specific set of 75*a1e26a70SApple OSS Distributions * operations. If interest in an entry point is not declared, then 76*a1e26a70SApple OSS Distributions * the policy will be ignored when the Framework evaluates that entry 77*a1e26a70SApple OSS Distributions * point. 78*a1e26a70SApple OSS Distributions */ 79*a1e26a70SApple OSS Distributions 80*a1e26a70SApple OSS Distributions #ifndef _SECURITY_MAC_POLICY_H_ 81*a1e26a70SApple OSS Distributions #define _SECURITY_MAC_POLICY_H_ 82*a1e26a70SApple OSS Distributions 83*a1e26a70SApple OSS Distributions #ifndef PRIVATE 84*a1e26a70SApple OSS Distributions #warning "MAC policy is not KPI, see Technical Q&A QA1574, this header will be removed in next version" 85*a1e26a70SApple OSS Distributions #endif 86*a1e26a70SApple OSS Distributions 87*a1e26a70SApple OSS Distributions #include <security/_label.h> 88*a1e26a70SApple OSS Distributions #include <kern/cs_blobs.h> 89*a1e26a70SApple OSS Distributions 90*a1e26a70SApple OSS Distributions struct attrlist; 91*a1e26a70SApple OSS Distributions struct auditinfo; 92*a1e26a70SApple OSS Distributions struct bpf_d; 93*a1e26a70SApple OSS Distributions struct cs_blob; 94*a1e26a70SApple OSS Distributions struct devnode; 95*a1e26a70SApple OSS Distributions struct exception_action; 96*a1e26a70SApple OSS Distributions struct fileglob; 97*a1e26a70SApple OSS Distributions struct ifnet; 98*a1e26a70SApple OSS Distributions struct inpcb; 99*a1e26a70SApple OSS Distributions struct ipq; 100*a1e26a70SApple OSS Distributions struct label; 101*a1e26a70SApple OSS Distributions struct mac_policy_conf; 102*a1e26a70SApple OSS Distributions struct mbuf; 103*a1e26a70SApple OSS Distributions struct mount; 104*a1e26a70SApple OSS Distributions struct msg; 105*a1e26a70SApple OSS Distributions struct msqid_kernel; 106*a1e26a70SApple OSS Distributions struct pipe; 107*a1e26a70SApple OSS Distributions struct pseminfo; 108*a1e26a70SApple OSS Distributions struct pshminfo; 109*a1e26a70SApple OSS Distributions struct sbuf; 110*a1e26a70SApple OSS Distributions struct semid_kernel; 111*a1e26a70SApple OSS Distributions struct shmid_kernel; 112*a1e26a70SApple OSS Distributions struct socket; 113*a1e26a70SApple OSS Distributions struct sockopt; 114*a1e26a70SApple OSS Distributions struct task; 115*a1e26a70SApple OSS Distributions struct thread; 116*a1e26a70SApple OSS Distributions struct tty; 117*a1e26a70SApple OSS Distributions struct ucred; 118*a1e26a70SApple OSS Distributions struct vfs_attr; 119*a1e26a70SApple OSS Distributions struct vnode; 120*a1e26a70SApple OSS Distributions struct sockaddr; 121*a1e26a70SApple OSS Distributions /** @struct dummy */ 122*a1e26a70SApple OSS Distributions 123*a1e26a70SApple OSS Distributions 124*a1e26a70SApple OSS Distributions /* 125*a1e26a70SApple OSS Distributions * proc_ident_t support, see: rdar://problem/58928152 126*a1e26a70SApple OSS Distributions * Should be removed once all dependent parties adopt 127*a1e26a70SApple OSS Distributions * proc_ident_t. 128*a1e26a70SApple OSS Distributions */ 129*a1e26a70SApple OSS Distributions #define MAC_PROC_IDENT_SUPPORT 130*a1e26a70SApple OSS Distributions 131*a1e26a70SApple OSS Distributions #ifndef _KAUTH_CRED_T 132*a1e26a70SApple OSS Distributions #define _KAUTH_CRED_T 133*a1e26a70SApple OSS Distributions typedef struct ucred *kauth_cred_t; 134*a1e26a70SApple OSS Distributions #endif /* !_KAUTH_CRED_T */ 135*a1e26a70SApple OSS Distributions 136*a1e26a70SApple OSS Distributions #ifndef __IOKIT_PORTS_DEFINED__ 137*a1e26a70SApple OSS Distributions #define __IOKIT_PORTS_DEFINED__ 138*a1e26a70SApple OSS Distributions #ifdef __cplusplus 139*a1e26a70SApple OSS Distributions class OSObject; 140*a1e26a70SApple OSS Distributions typedef OSObject *io_object_t; 141*a1e26a70SApple OSS Distributions #else 142*a1e26a70SApple OSS Distributions struct OSObject; 143*a1e26a70SApple OSS Distributions typedef struct OSObject *io_object_t; 144*a1e26a70SApple OSS Distributions #endif 145*a1e26a70SApple OSS Distributions #endif /* __IOKIT_PORTS_DEFINED__ */ 146*a1e26a70SApple OSS Distributions 147*a1e26a70SApple OSS Distributions /*- 148*a1e26a70SApple OSS Distributions * MAC entry points are generally named using the following template: 149*a1e26a70SApple OSS Distributions * 150*a1e26a70SApple OSS Distributions * mpo_<object>_<operation>() 151*a1e26a70SApple OSS Distributions * 152*a1e26a70SApple OSS Distributions * or: 153*a1e26a70SApple OSS Distributions * 154*a1e26a70SApple OSS Distributions * mpo_<object>_check_<operation>() 155*a1e26a70SApple OSS Distributions * 156*a1e26a70SApple OSS Distributions * Entry points are sorted by object type. 157*a1e26a70SApple OSS Distributions * 158*a1e26a70SApple OSS Distributions * It may be desirable also to consider some subsystems as "objects", such 159*a1e26a70SApple OSS Distributions * as system, iokit, etc. 160*a1e26a70SApple OSS Distributions */ 161*a1e26a70SApple OSS Distributions 162*a1e26a70SApple OSS Distributions /** 163*a1e26a70SApple OSS Distributions * @name Entry Points for Label Management 164*a1e26a70SApple OSS Distributions * 165*a1e26a70SApple OSS Distributions * These are the entry points corresponding to the life cycle events for 166*a1e26a70SApple OSS Distributions * kernel objects, such as initialization, creation, and destruction. 167*a1e26a70SApple OSS Distributions * 168*a1e26a70SApple OSS Distributions * Most policies (that use labels) will initialize labels by allocating 169*a1e26a70SApple OSS Distributions * space for policy-specific data. In most cases, it is permitted to 170*a1e26a70SApple OSS Distributions * sleep during label initialization operations; it will be noted when 171*a1e26a70SApple OSS Distributions * it is not permitted. 172*a1e26a70SApple OSS Distributions * 173*a1e26a70SApple OSS Distributions * Initialization usually will not require doing more than allocating a 174*a1e26a70SApple OSS Distributions * generic label for the given object. What follows initialization is 175*a1e26a70SApple OSS Distributions * creation, where a label is made specific to the object it is associated 176*a1e26a70SApple OSS Distributions * with. Destruction occurs when the label is no longer needed, such as 177*a1e26a70SApple OSS Distributions * when the corresponding object is destroyed. All necessary cleanup should 178*a1e26a70SApple OSS Distributions * be performed in label destroy operations. 179*a1e26a70SApple OSS Distributions * 180*a1e26a70SApple OSS Distributions * Where possible, the label entry points have identical parameters. If 181*a1e26a70SApple OSS Distributions * the policy module does not require structure-specific label 182*a1e26a70SApple OSS Distributions * information, the same function may be registered in the policy 183*a1e26a70SApple OSS Distributions * operation vector. Many policies will implement two such generic 184*a1e26a70SApple OSS Distributions * allocation calls: one to handle sleepable requests, and one to handle 185*a1e26a70SApple OSS Distributions * potentially non-sleepable requests. 186*a1e26a70SApple OSS Distributions */ 187*a1e26a70SApple OSS Distributions 188*a1e26a70SApple OSS Distributions 189*a1e26a70SApple OSS Distributions /** 190*a1e26a70SApple OSS Distributions * @brief Audit event postselection 191*a1e26a70SApple OSS Distributions * @param cred Subject credential 192*a1e26a70SApple OSS Distributions * @param syscode Syscall number 193*a1e26a70SApple OSS Distributions * @param args Syscall arguments 194*a1e26a70SApple OSS Distributions * @param error Syscall errno 195*a1e26a70SApple OSS Distributions * @param retval Syscall return value 196*a1e26a70SApple OSS Distributions * 197*a1e26a70SApple OSS Distributions * This is the MAC Framework audit postselect, which is called before 198*a1e26a70SApple OSS Distributions * exiting a syscall to determine if an audit event should be committed. 199*a1e26a70SApple OSS Distributions * A return value of MAC_AUDIT_NO forces the audit record to be suppressed. 200*a1e26a70SApple OSS Distributions * Any other return value results in the audit record being committed. 201*a1e26a70SApple OSS Distributions * 202*a1e26a70SApple OSS Distributions * @warning The suppression behavior will probably go away in Apple's 203*a1e26a70SApple OSS Distributions * future version of the audit implementation. 204*a1e26a70SApple OSS Distributions * 205*a1e26a70SApple OSS Distributions * @return Return MAC_AUDIT_NO to force suppression of the audit record. 206*a1e26a70SApple OSS Distributions * Any other value results in the audit record being committed. 207*a1e26a70SApple OSS Distributions * 208*a1e26a70SApple OSS Distributions */ 209*a1e26a70SApple OSS Distributions typedef int mpo_audit_check_postselect_t( 210*a1e26a70SApple OSS Distributions kauth_cred_t cred, 211*a1e26a70SApple OSS Distributions unsigned short syscode, 212*a1e26a70SApple OSS Distributions void *args, 213*a1e26a70SApple OSS Distributions int error, 214*a1e26a70SApple OSS Distributions int retval 215*a1e26a70SApple OSS Distributions ); 216*a1e26a70SApple OSS Distributions /** 217*a1e26a70SApple OSS Distributions * @brief Audit event preselection 218*a1e26a70SApple OSS Distributions * @param cred Subject credential 219*a1e26a70SApple OSS Distributions * @param syscode Syscall number 220*a1e26a70SApple OSS Distributions * @param args Syscall arguments 221*a1e26a70SApple OSS Distributions * 222*a1e26a70SApple OSS Distributions * This is the MAC Framework audit preselect, which is called before a 223*a1e26a70SApple OSS Distributions * syscall is entered to determine if an audit event should be created. 224*a1e26a70SApple OSS Distributions * If the MAC policy forces the syscall to be audited, MAC_AUDIT_YES should be 225*a1e26a70SApple OSS Distributions * returned. A return value of MAC_AUDIT_NO causes the audit record to 226*a1e26a70SApple OSS Distributions * be suppressed. Returning MAC_POLICY_DEFAULT indicates that the policy wants 227*a1e26a70SApple OSS Distributions * to defer to the system's existing preselection mechanism. 228*a1e26a70SApple OSS Distributions * 229*a1e26a70SApple OSS Distributions * When policies return different preferences, the Framework decides what action 230*a1e26a70SApple OSS Distributions * to take based on the following policy. If any policy returns MAC_AUDIT_YES, 231*a1e26a70SApple OSS Distributions * then create an audit record, else if any policy returns MAC_AUDIT_NO, then 232*a1e26a70SApple OSS Distributions * suppress the creations of an audit record, else defer to the system's 233*a1e26a70SApple OSS Distributions * existing preselection mechanism. 234*a1e26a70SApple OSS Distributions * 235*a1e26a70SApple OSS Distributions * @warning The audit implementation in Apple's current version is 236*a1e26a70SApple OSS Distributions * incomplete, so the MAC policies have priority over the system's existing 237*a1e26a70SApple OSS Distributions * mechanisms. This will probably change in the future version where 238*a1e26a70SApple OSS Distributions * the audit implementation is more complete. 239*a1e26a70SApple OSS Distributions * 240*a1e26a70SApple OSS Distributions * @return Return MAC_AUDIT_YES to force auditing of the syscall, 241*a1e26a70SApple OSS Distributions * MAC_AUDIT_NO to force no auditing of the syscall, MAC_AUDIT_DEFAULT 242*a1e26a70SApple OSS Distributions * to allow auditing mechanisms to determine if the syscall is audited. 243*a1e26a70SApple OSS Distributions * 244*a1e26a70SApple OSS Distributions */ 245*a1e26a70SApple OSS Distributions typedef int mpo_audit_check_preselect_t( 246*a1e26a70SApple OSS Distributions kauth_cred_t cred, 247*a1e26a70SApple OSS Distributions unsigned short syscode, 248*a1e26a70SApple OSS Distributions void *args 249*a1e26a70SApple OSS Distributions ); 250*a1e26a70SApple OSS Distributions /** 251*a1e26a70SApple OSS Distributions * @brief Indicate desire to change the process label at exec time 252*a1e26a70SApple OSS Distributions * @param old Existing subject credential 253*a1e26a70SApple OSS Distributions * @param vp File being executed 254*a1e26a70SApple OSS Distributions * @param offset Offset of binary within file being executed 255*a1e26a70SApple OSS Distributions * @param scriptvp Script being executed by interpreter, if any. 256*a1e26a70SApple OSS Distributions * @param vnodelabel Label corresponding to vp 257*a1e26a70SApple OSS Distributions * @param scriptvnodelabel Script vnode label 258*a1e26a70SApple OSS Distributions * @param execlabel Userspace provided execution label 259*a1e26a70SApple OSS Distributions * @param p Object process 260*a1e26a70SApple OSS Distributions * @param macpolicyattr MAC policy-specific spawn attribute data 261*a1e26a70SApple OSS Distributions * @param macpolicyattrlen Length of policy-specific spawn attribute data 262*a1e26a70SApple OSS Distributions * @see mac_execve 263*a1e26a70SApple OSS Distributions * @see mpo_cred_label_update_execve_t 264*a1e26a70SApple OSS Distributions * @see mpo_vnode_check_exec_t 265*a1e26a70SApple OSS Distributions * 266*a1e26a70SApple OSS Distributions * Indicate whether this policy intends to update the label of a newly 267*a1e26a70SApple OSS Distributions * created credential from the existing subject credential (old). This 268*a1e26a70SApple OSS Distributions * call occurs when a process executes the passed vnode. If a policy 269*a1e26a70SApple OSS Distributions * returns success from this entry point, the mpo_cred_label_update_execve 270*a1e26a70SApple OSS Distributions * entry point will later be called with the same parameters. Access 271*a1e26a70SApple OSS Distributions * has already been checked via the mpo_vnode_check_exec entry point, 272*a1e26a70SApple OSS Distributions * this entry point is necessary to preserve kernel locking constraints 273*a1e26a70SApple OSS Distributions * during program execution. 274*a1e26a70SApple OSS Distributions * 275*a1e26a70SApple OSS Distributions * The supplied vnode and vnodelabel correspond with the file actually 276*a1e26a70SApple OSS Distributions * being executed; in the case that the file is interpreted (for 277*a1e26a70SApple OSS Distributions * example, a script), the label of the original exec-time vnode has 278*a1e26a70SApple OSS Distributions * been preserved in scriptvnodelabel. 279*a1e26a70SApple OSS Distributions * 280*a1e26a70SApple OSS Distributions * The final label, execlabel, corresponds to a label supplied by a 281*a1e26a70SApple OSS Distributions * user space application through the use of the mac_execve system call. 282*a1e26a70SApple OSS Distributions * 283*a1e26a70SApple OSS Distributions * The vnode lock is held during this operation. No changes should be 284*a1e26a70SApple OSS Distributions * made to the old credential structure. 285*a1e26a70SApple OSS Distributions * 286*a1e26a70SApple OSS Distributions * @warning Even if a policy returns 0, it should behave correctly in 287*a1e26a70SApple OSS Distributions * the presence of an invocation of mpo_cred_label_update_execve, as that 288*a1e26a70SApple OSS Distributions * call may happen as a result of another policy requesting a transition. 289*a1e26a70SApple OSS Distributions * 290*a1e26a70SApple OSS Distributions * @return Non-zero if a transition is required, 0 otherwise. 291*a1e26a70SApple OSS Distributions */ 292*a1e26a70SApple OSS Distributions typedef int mpo_cred_check_label_update_execve_t( 293*a1e26a70SApple OSS Distributions kauth_cred_t old, 294*a1e26a70SApple OSS Distributions struct vnode *vp, 295*a1e26a70SApple OSS Distributions off_t offset, 296*a1e26a70SApple OSS Distributions struct vnode *scriptvp, 297*a1e26a70SApple OSS Distributions struct label *vnodelabel, 298*a1e26a70SApple OSS Distributions struct label *scriptvnodelabel, 299*a1e26a70SApple OSS Distributions struct label *execlabel, 300*a1e26a70SApple OSS Distributions struct proc *p, 301*a1e26a70SApple OSS Distributions void *macpolicyattr, 302*a1e26a70SApple OSS Distributions size_t macpolicyattrlen 303*a1e26a70SApple OSS Distributions ); 304*a1e26a70SApple OSS Distributions /** 305*a1e26a70SApple OSS Distributions * @brief Access control check for relabelling processes 306*a1e26a70SApple OSS Distributions * @param cred Subject credential 307*a1e26a70SApple OSS Distributions * @param newlabel New label to apply to the user credential 308*a1e26a70SApple OSS Distributions * @see mpo_cred_label_update_t 309*a1e26a70SApple OSS Distributions * @see mac_set_proc 310*a1e26a70SApple OSS Distributions * 311*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can relabel 312*a1e26a70SApple OSS Distributions * itself to the supplied new label (newlabel). This access control check 313*a1e26a70SApple OSS Distributions * is called when the mac_set_proc system call is invoked. A user space 314*a1e26a70SApple OSS Distributions * application will supply a new value, the value will be internalized 315*a1e26a70SApple OSS Distributions * and provided in newlabel. 316*a1e26a70SApple OSS Distributions * 317*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 318*a1e26a70SApple OSS Distributions * errno should be returned. 319*a1e26a70SApple OSS Distributions */ 320*a1e26a70SApple OSS Distributions typedef int mpo_cred_check_label_update_t( 321*a1e26a70SApple OSS Distributions kauth_cred_t cred, 322*a1e26a70SApple OSS Distributions struct label *newlabel 323*a1e26a70SApple OSS Distributions ); 324*a1e26a70SApple OSS Distributions /** 325*a1e26a70SApple OSS Distributions * @brief Access control check for visibility of other subjects 326*a1e26a70SApple OSS Distributions * @param u1 Subject credential 327*a1e26a70SApple OSS Distributions * @param u2 Object credential 328*a1e26a70SApple OSS Distributions * 329*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential u1 can 330*a1e26a70SApple OSS Distributions * "see" other subjects with the passed subject credential u2. This call 331*a1e26a70SApple OSS Distributions * may be made in a number of situations, including inter-process status 332*a1e26a70SApple OSS Distributions * sysctls used by ps, and in procfs lookups. 333*a1e26a70SApple OSS Distributions * 334*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 335*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch, 336*a1e26a70SApple OSS Distributions * EPERM for lack of privilege, or ESRCH to hide visibility. 337*a1e26a70SApple OSS Distributions */ 338*a1e26a70SApple OSS Distributions typedef int mpo_cred_check_visible_t( 339*a1e26a70SApple OSS Distributions kauth_cred_t u1, 340*a1e26a70SApple OSS Distributions kauth_cred_t u2 341*a1e26a70SApple OSS Distributions ); 342*a1e26a70SApple OSS Distributions /** 343*a1e26a70SApple OSS Distributions * @brief Associate a credential with a new process at fork 344*a1e26a70SApple OSS Distributions * @param cred credential to inherited by new process 345*a1e26a70SApple OSS Distributions * @param proc the new process 346*a1e26a70SApple OSS Distributions * 347*a1e26a70SApple OSS Distributions * Allow a process to associate the credential with a new 348*a1e26a70SApple OSS Distributions * process for reference countng purposes. 349*a1e26a70SApple OSS Distributions * NOTE: the credential can be dis-associated in ways other 350*a1e26a70SApple OSS Distributions * than exit - so this strategy is flawed - should just 351*a1e26a70SApple OSS Distributions * catch label destroy callback. 352*a1e26a70SApple OSS Distributions */ 353*a1e26a70SApple OSS Distributions typedef void mpo_cred_label_associate_fork_t( 354*a1e26a70SApple OSS Distributions kauth_cred_t cred, 355*a1e26a70SApple OSS Distributions proc_t proc 356*a1e26a70SApple OSS Distributions ); 357*a1e26a70SApple OSS Distributions /** 358*a1e26a70SApple OSS Distributions * @brief Create the first process 359*a1e26a70SApple OSS Distributions * @param cred Subject credential to be labeled 360*a1e26a70SApple OSS Distributions * 361*a1e26a70SApple OSS Distributions * Create the subject credential of process 0, the parent of all BSD 362*a1e26a70SApple OSS Distributions * kernel processes. Policies should update the label in the 363*a1e26a70SApple OSS Distributions * previously initialized credential structure. 364*a1e26a70SApple OSS Distributions */ 365*a1e26a70SApple OSS Distributions typedef void mpo_cred_label_associate_kernel_t( 366*a1e26a70SApple OSS Distributions kauth_cred_t cred 367*a1e26a70SApple OSS Distributions ); 368*a1e26a70SApple OSS Distributions /** 369*a1e26a70SApple OSS Distributions * @brief Create a credential label 370*a1e26a70SApple OSS Distributions * @param parent_cred Parent credential 371*a1e26a70SApple OSS Distributions * @param child_cred Child credential 372*a1e26a70SApple OSS Distributions * 373*a1e26a70SApple OSS Distributions * Set the label of a newly created credential, most likely using the 374*a1e26a70SApple OSS Distributions * information in the supplied parent credential. 375*a1e26a70SApple OSS Distributions * 376*a1e26a70SApple OSS Distributions * @warning This call is made when crcopy or crdup is invoked on a 377*a1e26a70SApple OSS Distributions * newly created struct ucred, and should not be confused with a 378*a1e26a70SApple OSS Distributions * process fork or creation event. 379*a1e26a70SApple OSS Distributions */ 380*a1e26a70SApple OSS Distributions typedef void mpo_cred_label_associate_t( 381*a1e26a70SApple OSS Distributions kauth_cred_t parent_cred, 382*a1e26a70SApple OSS Distributions kauth_cred_t child_cred 383*a1e26a70SApple OSS Distributions ); 384*a1e26a70SApple OSS Distributions /** 385*a1e26a70SApple OSS Distributions * @brief Create the first process 386*a1e26a70SApple OSS Distributions * @param cred Subject credential to be labeled 387*a1e26a70SApple OSS Distributions * 388*a1e26a70SApple OSS Distributions * Create the subject credential of process 1, the parent of all BSD 389*a1e26a70SApple OSS Distributions * user processes. Policies should update the label in the previously 390*a1e26a70SApple OSS Distributions * initialized credential structure. This is the 'init' process. 391*a1e26a70SApple OSS Distributions */ 392*a1e26a70SApple OSS Distributions typedef void mpo_cred_label_associate_user_t( 393*a1e26a70SApple OSS Distributions kauth_cred_t cred 394*a1e26a70SApple OSS Distributions ); 395*a1e26a70SApple OSS Distributions /** 396*a1e26a70SApple OSS Distributions * @brief Destroy credential label 397*a1e26a70SApple OSS Distributions * @param label The label to be destroyed 398*a1e26a70SApple OSS Distributions * 399*a1e26a70SApple OSS Distributions * Destroy a user credential label. Since the user credential 400*a1e26a70SApple OSS Distributions * is going out of scope, policy modules should free any internal 401*a1e26a70SApple OSS Distributions * storage associated with the label so that it may be destroyed. 402*a1e26a70SApple OSS Distributions */ 403*a1e26a70SApple OSS Distributions typedef void mpo_cred_label_destroy_t( 404*a1e26a70SApple OSS Distributions struct label *label 405*a1e26a70SApple OSS Distributions ); 406*a1e26a70SApple OSS Distributions /** 407*a1e26a70SApple OSS Distributions * @brief Externalize a user credential label for auditing 408*a1e26a70SApple OSS Distributions * @param label Label to be externalized 409*a1e26a70SApple OSS Distributions * @param element_name Name of the label namespace for which labels should be 410*a1e26a70SApple OSS Distributions * externalized 411*a1e26a70SApple OSS Distributions * @param sb String buffer to be filled with a text representation of the label 412*a1e26a70SApple OSS Distributions * 413*a1e26a70SApple OSS Distributions * Produce an external representation of the label on a user credential for 414*a1e26a70SApple OSS Distributions * inclusion in an audit record. An externalized label consists of a text 415*a1e26a70SApple OSS Distributions * representation of the label contents that will be added to the audit record 416*a1e26a70SApple OSS Distributions * as part of a text token. Policy-agnostic user space tools will display 417*a1e26a70SApple OSS Distributions * this externalized version. 418*a1e26a70SApple OSS Distributions * 419*a1e26a70SApple OSS Distributions * @return 0 on success, return non-zero if an error occurs while 420*a1e26a70SApple OSS Distributions * externalizing the label data. 421*a1e26a70SApple OSS Distributions * 422*a1e26a70SApple OSS Distributions */ 423*a1e26a70SApple OSS Distributions typedef int mpo_cred_label_externalize_audit_t( 424*a1e26a70SApple OSS Distributions struct label *label, 425*a1e26a70SApple OSS Distributions char *element_name, 426*a1e26a70SApple OSS Distributions struct sbuf *sb 427*a1e26a70SApple OSS Distributions ); 428*a1e26a70SApple OSS Distributions /** 429*a1e26a70SApple OSS Distributions * @brief Externalize a user credential label 430*a1e26a70SApple OSS Distributions * @param label Label to be externalized 431*a1e26a70SApple OSS Distributions * @param element_name Name of the label namespace for which labels should be 432*a1e26a70SApple OSS Distributions * externalized 433*a1e26a70SApple OSS Distributions * @param sb String buffer to be filled with a text representation of the label 434*a1e26a70SApple OSS Distributions * 435*a1e26a70SApple OSS Distributions * Produce an external representation of the label on a user 436*a1e26a70SApple OSS Distributions * credential. An externalized label consists of a text representation 437*a1e26a70SApple OSS Distributions * of the label contents that can be used with user applications. 438*a1e26a70SApple OSS Distributions * Policy-agnostic user space tools will display this externalized 439*a1e26a70SApple OSS Distributions * version. 440*a1e26a70SApple OSS Distributions * 441*a1e26a70SApple OSS Distributions * @return 0 on success, return non-zero if an error occurs while 442*a1e26a70SApple OSS Distributions * externalizing the label data. 443*a1e26a70SApple OSS Distributions * 444*a1e26a70SApple OSS Distributions */ 445*a1e26a70SApple OSS Distributions typedef int mpo_cred_label_externalize_t( 446*a1e26a70SApple OSS Distributions struct label *label, 447*a1e26a70SApple OSS Distributions char *element_name, 448*a1e26a70SApple OSS Distributions struct sbuf *sb 449*a1e26a70SApple OSS Distributions ); 450*a1e26a70SApple OSS Distributions /** 451*a1e26a70SApple OSS Distributions * @brief Initialize user credential label 452*a1e26a70SApple OSS Distributions * @param label New label to initialize 453*a1e26a70SApple OSS Distributions * 454*a1e26a70SApple OSS Distributions * Initialize the label for a newly instantiated user credential. 455*a1e26a70SApple OSS Distributions * Sleeping is permitted. 456*a1e26a70SApple OSS Distributions */ 457*a1e26a70SApple OSS Distributions typedef void mpo_cred_label_init_t( 458*a1e26a70SApple OSS Distributions struct label *label 459*a1e26a70SApple OSS Distributions ); 460*a1e26a70SApple OSS Distributions /** 461*a1e26a70SApple OSS Distributions * @brief Internalize a user credential label 462*a1e26a70SApple OSS Distributions * @param label Label to be internalized 463*a1e26a70SApple OSS Distributions * @param element_name Name of the label namespace for which the label should 464*a1e26a70SApple OSS Distributions * be internalized 465*a1e26a70SApple OSS Distributions * @param element_data Text data to be internalized 466*a1e26a70SApple OSS Distributions * 467*a1e26a70SApple OSS Distributions * Produce a user credential label from an external representation. An 468*a1e26a70SApple OSS Distributions * externalized label consists of a text representation of the label 469*a1e26a70SApple OSS Distributions * contents that can be used with user applications. Policy-agnostic 470*a1e26a70SApple OSS Distributions * user space tools will forward text version to the kernel for 471*a1e26a70SApple OSS Distributions * processing by individual policy modules. 472*a1e26a70SApple OSS Distributions * 473*a1e26a70SApple OSS Distributions * The policy's internalize entry points will be called only if the 474*a1e26a70SApple OSS Distributions * policy has registered interest in the label namespace. 475*a1e26a70SApple OSS Distributions * 476*a1e26a70SApple OSS Distributions * @return 0 on success, Otherwise, return non-zero if an error occurs 477*a1e26a70SApple OSS Distributions * while internalizing the label data. 478*a1e26a70SApple OSS Distributions * 479*a1e26a70SApple OSS Distributions */ 480*a1e26a70SApple OSS Distributions typedef int mpo_cred_label_internalize_t( 481*a1e26a70SApple OSS Distributions struct label *label, 482*a1e26a70SApple OSS Distributions char *element_name, 483*a1e26a70SApple OSS Distributions char *element_data 484*a1e26a70SApple OSS Distributions ); 485*a1e26a70SApple OSS Distributions /** 486*a1e26a70SApple OSS Distributions * @brief Update credential at exec time 487*a1e26a70SApple OSS Distributions * @param old_cred Existing subject credential 488*a1e26a70SApple OSS Distributions * @param new_cred New subject credential to be labeled 489*a1e26a70SApple OSS Distributions * @param p Object process. 490*a1e26a70SApple OSS Distributions * @param vp File being executed 491*a1e26a70SApple OSS Distributions * @param offset Offset of binary within file being executed 492*a1e26a70SApple OSS Distributions * @param scriptvp Script being executed by interpreter, if any. 493*a1e26a70SApple OSS Distributions * @param vnodelabel Label corresponding to vp 494*a1e26a70SApple OSS Distributions * @param scriptvnodelabel Script vnode label 495*a1e26a70SApple OSS Distributions * @param execlabel Userspace provided execution label 496*a1e26a70SApple OSS Distributions * @param csflags Code signing flags to be set after exec 497*a1e26a70SApple OSS Distributions * @param macpolicyattr MAC policy-specific spawn attribute data. 498*a1e26a70SApple OSS Distributions * @param macpolicyattrlen Length of policy-specific spawn attribute data. 499*a1e26a70SApple OSS Distributions * @see mac_execve 500*a1e26a70SApple OSS Distributions * @see mpo_cred_check_label_update_execve_t 501*a1e26a70SApple OSS Distributions * @see mpo_vnode_check_exec_t 502*a1e26a70SApple OSS Distributions * 503*a1e26a70SApple OSS Distributions * Update the label of a newly created credential (new) from the 504*a1e26a70SApple OSS Distributions * existing subject credential (old). This call occurs when a process 505*a1e26a70SApple OSS Distributions * executes the passed vnode and one of the loaded policy modules has 506*a1e26a70SApple OSS Distributions * returned success from the mpo_cred_check_label_update_execve entry point. 507*a1e26a70SApple OSS Distributions * Access has already been checked via the mpo_vnode_check_exec entry 508*a1e26a70SApple OSS Distributions * point, this entry point is only used to update any policy state. 509*a1e26a70SApple OSS Distributions * 510*a1e26a70SApple OSS Distributions * The supplied vnode and vnodelabel correspond with the file actually 511*a1e26a70SApple OSS Distributions * being executed; in the case that the file is interpreted (for 512*a1e26a70SApple OSS Distributions * example, a script), the label of the original exec-time vnode has 513*a1e26a70SApple OSS Distributions * been preserved in scriptvnodelabel. 514*a1e26a70SApple OSS Distributions * 515*a1e26a70SApple OSS Distributions * The final label, execlabel, corresponds to a label supplied by a 516*a1e26a70SApple OSS Distributions * user space application through the use of the mac_execve system call. 517*a1e26a70SApple OSS Distributions * 518*a1e26a70SApple OSS Distributions * If non-NULL, the value pointed to by disjointp will be set to 0 to 519*a1e26a70SApple OSS Distributions * indicate that the old and new credentials are not disjoint, or 1 to 520*a1e26a70SApple OSS Distributions * indicate that they are. 521*a1e26a70SApple OSS Distributions * 522*a1e26a70SApple OSS Distributions * The vnode lock is held during this operation. No changes should be 523*a1e26a70SApple OSS Distributions * made to the old credential structure. 524*a1e26a70SApple OSS Distributions * @return 0 on success, Otherwise, return non-zero if update results in 525*a1e26a70SApple OSS Distributions * termination of child. 526*a1e26a70SApple OSS Distributions */ 527*a1e26a70SApple OSS Distributions typedef int mpo_cred_label_update_execve_t( 528*a1e26a70SApple OSS Distributions kauth_cred_t old_cred, 529*a1e26a70SApple OSS Distributions kauth_cred_t new_cred, 530*a1e26a70SApple OSS Distributions struct proc *p, 531*a1e26a70SApple OSS Distributions struct vnode *vp, 532*a1e26a70SApple OSS Distributions off_t offset, 533*a1e26a70SApple OSS Distributions struct vnode *scriptvp, 534*a1e26a70SApple OSS Distributions struct label *vnodelabel, 535*a1e26a70SApple OSS Distributions struct label *scriptvnodelabel, 536*a1e26a70SApple OSS Distributions struct label *execlabel, 537*a1e26a70SApple OSS Distributions u_int *csflags, 538*a1e26a70SApple OSS Distributions void *macpolicyattr, 539*a1e26a70SApple OSS Distributions size_t macpolicyattrlen, 540*a1e26a70SApple OSS Distributions int *disjointp 541*a1e26a70SApple OSS Distributions ); 542*a1e26a70SApple OSS Distributions /** 543*a1e26a70SApple OSS Distributions * @brief Update a credential label 544*a1e26a70SApple OSS Distributions * @param cred The existing credential 545*a1e26a70SApple OSS Distributions * @param newlabel A new label to apply to the credential 546*a1e26a70SApple OSS Distributions * @see mpo_cred_check_label_update_t 547*a1e26a70SApple OSS Distributions * @see mac_set_proc 548*a1e26a70SApple OSS Distributions * 549*a1e26a70SApple OSS Distributions * Update the label on a user credential, using the supplied new label. 550*a1e26a70SApple OSS Distributions * This is called as a result of a process relabel operation. Access 551*a1e26a70SApple OSS Distributions * control was already confirmed by mpo_cred_check_label_update. 552*a1e26a70SApple OSS Distributions */ 553*a1e26a70SApple OSS Distributions typedef void mpo_cred_label_update_t( 554*a1e26a70SApple OSS Distributions kauth_cred_t cred, 555*a1e26a70SApple OSS Distributions struct label *newlabel 556*a1e26a70SApple OSS Distributions ); 557*a1e26a70SApple OSS Distributions /** 558*a1e26a70SApple OSS Distributions * @brief Access control for launching a process with constraints 559*a1e26a70SApple OSS Distributions * @param curr_p The new process 560*a1e26a70SApple OSS Distributions * @param original_parent_id The pid of the original parent that spawned this process 561*a1e26a70SApple OSS Distributions * @param responsible_pid The pid of the responsible process that spawned this process 562*a1e26a70SApple OSS Distributions * @param macpolicyattr MAC policy-specific spawn attribute data 563*a1e26a70SApple OSS Distributions * @param macpolicyattrlen Length of policy-specific spawn attribute data 564*a1e26a70SApple OSS Distributions * @param fatal_failure_desc Description of fatal failure 565*a1e26a70SApple OSS Distributions * @param fatal_failure_desc_len Failure description len, failure is fatal if non-0 566*a1e26a70SApple OSS Distributions * 567*a1e26a70SApple OSS Distributions * Detemine whether the process being spawned adheres to the launch 568*a1e26a70SApple OSS Distributions * constraints (e.g. whether the process is spawned by launchd) and should 569*a1e26a70SApple OSS Distributions * be allowed to execute. This call occurs during execve or posix_spawn. 570*a1e26a70SApple OSS Distributions * 571*a1e26a70SApple OSS Distributions * @return Return 0 if process can be created, otherwise an appropriate value for 572*a1e26a70SApple OSS Distributions * errno should be returned. 573*a1e26a70SApple OSS Distributions */ 574*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_launch_constraints_t( 575*a1e26a70SApple OSS Distributions proc_t curr_p, 576*a1e26a70SApple OSS Distributions pid_t original_parent_id, 577*a1e26a70SApple OSS Distributions pid_t responsible_pid, 578*a1e26a70SApple OSS Distributions void *macpolicyattr, 579*a1e26a70SApple OSS Distributions size_t macpolicyattrlen, 580*a1e26a70SApple OSS Distributions launch_constraint_data_t lcd, 581*a1e26a70SApple OSS Distributions char **fatal_failure_desc, size_t *fatal_failure_desc_len 582*a1e26a70SApple OSS Distributions ); 583*a1e26a70SApple OSS Distributions /** 584*a1e26a70SApple OSS Distributions * @brief Create a new devfs device 585*a1e26a70SApple OSS Distributions * @param dev Major and minor numbers of special file 586*a1e26a70SApple OSS Distributions * @param de "inode" of new device file 587*a1e26a70SApple OSS Distributions * @param label Destination label 588*a1e26a70SApple OSS Distributions * @param fullpath Path relative to mount (e.g. /dev) of new device file 589*a1e26a70SApple OSS Distributions * 590*a1e26a70SApple OSS Distributions * This entry point labels a new devfs device. The label will likely be based 591*a1e26a70SApple OSS Distributions * on the path to the device, or the major and minor numbers. 592*a1e26a70SApple OSS Distributions * The policy should store an appropriate label into 'label'. 593*a1e26a70SApple OSS Distributions */ 594*a1e26a70SApple OSS Distributions typedef void mpo_devfs_label_associate_device_t( 595*a1e26a70SApple OSS Distributions dev_t dev, 596*a1e26a70SApple OSS Distributions struct devnode *de, 597*a1e26a70SApple OSS Distributions struct label *label, 598*a1e26a70SApple OSS Distributions const char *fullpath 599*a1e26a70SApple OSS Distributions ); 600*a1e26a70SApple OSS Distributions /** 601*a1e26a70SApple OSS Distributions * @brief Create a new devfs directory 602*a1e26a70SApple OSS Distributions * @param dirname Name of new directory 603*a1e26a70SApple OSS Distributions * @param dirnamelen Length of 'dirname' 604*a1e26a70SApple OSS Distributions * @param de "inode" of new directory 605*a1e26a70SApple OSS Distributions * @param label Destination label 606*a1e26a70SApple OSS Distributions * @param fullpath Path relative to mount (e.g. /dev) of new directory 607*a1e26a70SApple OSS Distributions * 608*a1e26a70SApple OSS Distributions * This entry point labels a new devfs directory. The label will likely be 609*a1e26a70SApple OSS Distributions * based on the path of the new directory. The policy should store an appropriate 610*a1e26a70SApple OSS Distributions * label into 'label'. The devfs root directory is labelled in this way. 611*a1e26a70SApple OSS Distributions */ 612*a1e26a70SApple OSS Distributions typedef void mpo_devfs_label_associate_directory_t( 613*a1e26a70SApple OSS Distributions const char *dirname, 614*a1e26a70SApple OSS Distributions int dirnamelen, 615*a1e26a70SApple OSS Distributions struct devnode *de, 616*a1e26a70SApple OSS Distributions struct label *label, 617*a1e26a70SApple OSS Distributions const char *fullpath 618*a1e26a70SApple OSS Distributions ); 619*a1e26a70SApple OSS Distributions /** 620*a1e26a70SApple OSS Distributions * @brief Copy a devfs label 621*a1e26a70SApple OSS Distributions * @param src Source devfs label 622*a1e26a70SApple OSS Distributions * @param dest Destination devfs label 623*a1e26a70SApple OSS Distributions * 624*a1e26a70SApple OSS Distributions * Copy the label information from src to dest. The devfs file system 625*a1e26a70SApple OSS Distributions * often duplicates (splits) existing device nodes rather than creating 626*a1e26a70SApple OSS Distributions * new ones. 627*a1e26a70SApple OSS Distributions */ 628*a1e26a70SApple OSS Distributions typedef void mpo_devfs_label_copy_t( 629*a1e26a70SApple OSS Distributions struct label *src, 630*a1e26a70SApple OSS Distributions struct label *dest 631*a1e26a70SApple OSS Distributions ); 632*a1e26a70SApple OSS Distributions /** 633*a1e26a70SApple OSS Distributions * @brief Destroy devfs label 634*a1e26a70SApple OSS Distributions * @param label The label to be destroyed 635*a1e26a70SApple OSS Distributions * 636*a1e26a70SApple OSS Distributions * Destroy a devfs entry label. Since the object is going out 637*a1e26a70SApple OSS Distributions * of scope, policy modules should free any internal storage associated 638*a1e26a70SApple OSS Distributions * with the label so that it may be destroyed. 639*a1e26a70SApple OSS Distributions */ 640*a1e26a70SApple OSS Distributions typedef void mpo_devfs_label_destroy_t( 641*a1e26a70SApple OSS Distributions struct label *label 642*a1e26a70SApple OSS Distributions ); 643*a1e26a70SApple OSS Distributions /** 644*a1e26a70SApple OSS Distributions * @brief Initialize devfs label 645*a1e26a70SApple OSS Distributions * @param label New label to initialize 646*a1e26a70SApple OSS Distributions * 647*a1e26a70SApple OSS Distributions * Initialize the label for a newly instantiated devfs entry. Sleeping 648*a1e26a70SApple OSS Distributions * is permitted. 649*a1e26a70SApple OSS Distributions */ 650*a1e26a70SApple OSS Distributions typedef void mpo_devfs_label_init_t( 651*a1e26a70SApple OSS Distributions struct label *label 652*a1e26a70SApple OSS Distributions ); 653*a1e26a70SApple OSS Distributions /** 654*a1e26a70SApple OSS Distributions * @brief Update a devfs label after relabelling its vnode 655*a1e26a70SApple OSS Distributions * @param mp Devfs mount point 656*a1e26a70SApple OSS Distributions * @param de Affected devfs directory entry 657*a1e26a70SApple OSS Distributions * @param delabel Label of devfs directory entry 658*a1e26a70SApple OSS Distributions * @param vp Vnode associated with de 659*a1e26a70SApple OSS Distributions * @param vnodelabel New label of vnode 660*a1e26a70SApple OSS Distributions * 661*a1e26a70SApple OSS Distributions * Update a devfs label when its vnode is manually relabelled, 662*a1e26a70SApple OSS Distributions * for example with setfmac(1). Typically, this will simply copy 663*a1e26a70SApple OSS Distributions * the vnode label into the devfs label. 664*a1e26a70SApple OSS Distributions */ 665*a1e26a70SApple OSS Distributions typedef void mpo_devfs_label_update_t( 666*a1e26a70SApple OSS Distributions struct mount *mp, 667*a1e26a70SApple OSS Distributions struct devnode *de, 668*a1e26a70SApple OSS Distributions struct label *delabel, 669*a1e26a70SApple OSS Distributions struct vnode *vp, 670*a1e26a70SApple OSS Distributions struct label *vnodelabel 671*a1e26a70SApple OSS Distributions ); 672*a1e26a70SApple OSS Distributions /** 673*a1e26a70SApple OSS Distributions * @brief Access control for sending an exception to an exception action 674*a1e26a70SApple OSS Distributions * @param crashlabel The crashing process's label 675*a1e26a70SApple OSS Distributions * @param action Exception action 676*a1e26a70SApple OSS Distributions * @param exclabel Policy label for exception action 677*a1e26a70SApple OSS Distributions * 678*a1e26a70SApple OSS Distributions * Determine whether the the exception message caused by the victim 679*a1e26a70SApple OSS Distributions * process can be sent to the exception action. The policy may compare 680*a1e26a70SApple OSS Distributions * credentials in the crashlabel, which are derived from the process at 681*a1e26a70SApple OSS Distributions * the time the exception occurs, with the credentials in the exclabel, 682*a1e26a70SApple OSS Distributions * which was set at the time the exception port was set, to determine 683*a1e26a70SApple OSS Distributions * its decision. Note that any process from which the policy derived 684*a1e26a70SApple OSS Distributions * any credentials may not exist anymore at the time of this policy 685*a1e26a70SApple OSS Distributions * operation. Sleeping is permitted. 686*a1e26a70SApple OSS Distributions * 687*a1e26a70SApple OSS Distributions * @return Return 0 if the message can be sent, otherwise an 688*a1e26a70SApple OSS Distributions * appropriate value for errno should be returned. 689*a1e26a70SApple OSS Distributions */ 690*a1e26a70SApple OSS Distributions typedef int mpo_exc_action_check_exception_send_t( 691*a1e26a70SApple OSS Distributions struct label *crashlabel, 692*a1e26a70SApple OSS Distributions struct exception_action *action, 693*a1e26a70SApple OSS Distributions struct label *exclabel 694*a1e26a70SApple OSS Distributions ); 695*a1e26a70SApple OSS Distributions /** 696*a1e26a70SApple OSS Distributions * @brief Associate an exception action label 697*a1e26a70SApple OSS Distributions * @param action Exception action to label 698*a1e26a70SApple OSS Distributions * @param exclabel Policy label to be filled in for exception action 699*a1e26a70SApple OSS Distributions * 700*a1e26a70SApple OSS Distributions * Set the label on an exception action. 701*a1e26a70SApple OSS Distributions */ 702*a1e26a70SApple OSS Distributions typedef void mpo_exc_action_label_associate_t( 703*a1e26a70SApple OSS Distributions struct exception_action *action, 704*a1e26a70SApple OSS Distributions struct label *exclabel 705*a1e26a70SApple OSS Distributions ); 706*a1e26a70SApple OSS Distributions /** 707*a1e26a70SApple OSS Distributions * @brief Destroy exception action label 708*a1e26a70SApple OSS Distributions * @param label The label to be destroyed 709*a1e26a70SApple OSS Distributions * 710*a1e26a70SApple OSS Distributions * Destroy the label on an exception action. Since the object is going 711*a1e26a70SApple OSS Distributions * out of scope, policy modules should free any internal storage 712*a1e26a70SApple OSS Distributions * associated with the label so that it may be destroyed. Sleeping is 713*a1e26a70SApple OSS Distributions * permitted. 714*a1e26a70SApple OSS Distributions */ 715*a1e26a70SApple OSS Distributions typedef void mpo_exc_action_label_destroy_t( 716*a1e26a70SApple OSS Distributions struct label *label 717*a1e26a70SApple OSS Distributions ); 718*a1e26a70SApple OSS Distributions /** 719*a1e26a70SApple OSS Distributions * @brief Populate an exception action label with process credentials 720*a1e26a70SApple OSS Distributions * @param label The label to be populated 721*a1e26a70SApple OSS Distributions * @param proc Process to derive credentials from 722*a1e26a70SApple OSS Distributions * 723*a1e26a70SApple OSS Distributions * Populate a label with credentials derived from a process. At 724*a1e26a70SApple OSS Distributions * exception delivery time, the policy should compare credentials of the 725*a1e26a70SApple OSS Distributions * process that set an exception ports with the credentials of the 726*a1e26a70SApple OSS Distributions * process or corpse that experienced the exception. Note that the 727*a1e26a70SApple OSS Distributions * process that set the port may not exist at that time anymore, so 728*a1e26a70SApple OSS Distributions * labels should carry copies of live credentials if necessary. 729*a1e26a70SApple OSS Distributions */ 730*a1e26a70SApple OSS Distributions typedef void mpo_exc_action_label_populate_t( 731*a1e26a70SApple OSS Distributions struct label *label, 732*a1e26a70SApple OSS Distributions struct proc *proc 733*a1e26a70SApple OSS Distributions ); 734*a1e26a70SApple OSS Distributions /** 735*a1e26a70SApple OSS Distributions * @brief Initialize exception action label 736*a1e26a70SApple OSS Distributions * @param label New label to initialize 737*a1e26a70SApple OSS Distributions * 738*a1e26a70SApple OSS Distributions * Initialize a label for an exception action. Usually performs 739*a1e26a70SApple OSS Distributions * policy specific allocations. Sleeping is permitted. 740*a1e26a70SApple OSS Distributions */ 741*a1e26a70SApple OSS Distributions typedef int mpo_exc_action_label_init_t( 742*a1e26a70SApple OSS Distributions struct label *label 743*a1e26a70SApple OSS Distributions ); 744*a1e26a70SApple OSS Distributions /** 745*a1e26a70SApple OSS Distributions * @brief Update the label on an exception action 746*a1e26a70SApple OSS Distributions * @param action Exception action that the label belongs to (may be 747*a1e26a70SApple OSS Distributions * NULL if none) 748*a1e26a70SApple OSS Distributions * @param label Policy label to update 749*a1e26a70SApple OSS Distributions * @param newlabel New label for update 750*a1e26a70SApple OSS Distributions * 751*a1e26a70SApple OSS Distributions * Update the credentials of an exception action from the given 752*a1e26a70SApple OSS Distributions * label. The policy should copy over any credentials (process and 753*a1e26a70SApple OSS Distributions * otherwise) from the new label into the label to update. Must not 754*a1e26a70SApple OSS Distributions * sleep, must be quick and can be called with locks held. 755*a1e26a70SApple OSS Distributions */ 756*a1e26a70SApple OSS Distributions typedef int mpo_exc_action_label_update_t( 757*a1e26a70SApple OSS Distributions struct exception_action *action, 758*a1e26a70SApple OSS Distributions struct label *label, 759*a1e26a70SApple OSS Distributions struct label *newlabel 760*a1e26a70SApple OSS Distributions ); 761*a1e26a70SApple OSS Distributions /** 762*a1e26a70SApple OSS Distributions * @brief Access control for changing the offset of a file descriptor 763*a1e26a70SApple OSS Distributions * @param cred Subject credential 764*a1e26a70SApple OSS Distributions * @param fg Fileglob structure 765*a1e26a70SApple OSS Distributions * @param label Policy label for fg 766*a1e26a70SApple OSS Distributions * 767*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 768*a1e26a70SApple OSS Distributions * change the offset of the file represented by fg. 769*a1e26a70SApple OSS Distributions * 770*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 771*a1e26a70SApple OSS Distributions * value for errno should be returned. 772*a1e26a70SApple OSS Distributions */ 773*a1e26a70SApple OSS Distributions typedef int mpo_file_check_change_offset_t( 774*a1e26a70SApple OSS Distributions kauth_cred_t cred, 775*a1e26a70SApple OSS Distributions struct fileglob *fg, 776*a1e26a70SApple OSS Distributions struct label *label 777*a1e26a70SApple OSS Distributions ); 778*a1e26a70SApple OSS Distributions /** 779*a1e26a70SApple OSS Distributions * @brief Access control for creating a file descriptor 780*a1e26a70SApple OSS Distributions * @param cred Subject credential 781*a1e26a70SApple OSS Distributions * 782*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 783*a1e26a70SApple OSS Distributions * allocate a new file descriptor. 784*a1e26a70SApple OSS Distributions * 785*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 786*a1e26a70SApple OSS Distributions * value for errno should be returned. 787*a1e26a70SApple OSS Distributions */ 788*a1e26a70SApple OSS Distributions typedef int mpo_file_check_create_t( 789*a1e26a70SApple OSS Distributions kauth_cred_t cred 790*a1e26a70SApple OSS Distributions ); 791*a1e26a70SApple OSS Distributions /** 792*a1e26a70SApple OSS Distributions * @brief Access control for duplicating a file descriptor 793*a1e26a70SApple OSS Distributions * @param cred Subject credential 794*a1e26a70SApple OSS Distributions * @param fg Fileglob structure 795*a1e26a70SApple OSS Distributions * @param label Policy label for fg 796*a1e26a70SApple OSS Distributions * @param newfd New file descriptor number 797*a1e26a70SApple OSS Distributions * 798*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 799*a1e26a70SApple OSS Distributions * duplicate the fileglob structure represented by fg and as file 800*a1e26a70SApple OSS Distributions * descriptor number newfd. 801*a1e26a70SApple OSS Distributions * 802*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 803*a1e26a70SApple OSS Distributions * value for errno should be returned. 804*a1e26a70SApple OSS Distributions */ 805*a1e26a70SApple OSS Distributions typedef int mpo_file_check_dup_t( 806*a1e26a70SApple OSS Distributions kauth_cred_t cred, 807*a1e26a70SApple OSS Distributions struct fileglob *fg, 808*a1e26a70SApple OSS Distributions struct label *label, 809*a1e26a70SApple OSS Distributions int newfd 810*a1e26a70SApple OSS Distributions ); 811*a1e26a70SApple OSS Distributions /** 812*a1e26a70SApple OSS Distributions * @brief Access control check for fcntl 813*a1e26a70SApple OSS Distributions * @param cred Subject credential 814*a1e26a70SApple OSS Distributions * @param fg Fileglob structure 815*a1e26a70SApple OSS Distributions * @param label Policy label for fg 816*a1e26a70SApple OSS Distributions * @param cmd Control operation to be performed; see fcntl(2) 817*a1e26a70SApple OSS Distributions * @param arg fcnt arguments; see fcntl(2) 818*a1e26a70SApple OSS Distributions * 819*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 820*a1e26a70SApple OSS Distributions * the file control operation indicated by cmd. 821*a1e26a70SApple OSS Distributions * 822*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 823*a1e26a70SApple OSS Distributions * errno should be returned. 824*a1e26a70SApple OSS Distributions */ 825*a1e26a70SApple OSS Distributions typedef int mpo_file_check_fcntl_t( 826*a1e26a70SApple OSS Distributions kauth_cred_t cred, 827*a1e26a70SApple OSS Distributions struct fileglob *fg, 828*a1e26a70SApple OSS Distributions struct label *label, 829*a1e26a70SApple OSS Distributions int cmd, 830*a1e26a70SApple OSS Distributions user_long_t arg 831*a1e26a70SApple OSS Distributions ); 832*a1e26a70SApple OSS Distributions /** 833*a1e26a70SApple OSS Distributions * @brief Access control check for mac_get_fd 834*a1e26a70SApple OSS Distributions * @param cred Subject credential 835*a1e26a70SApple OSS Distributions * @param fg Fileglob structure 836*a1e26a70SApple OSS Distributions * @param elements Element buffer 837*a1e26a70SApple OSS Distributions * @param len Length of buffer 838*a1e26a70SApple OSS Distributions * 839*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be allowed 840*a1e26a70SApple OSS Distributions * to get an externalized version of the label on the object indicated by fd. 841*a1e26a70SApple OSS Distributions * 842*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 843*a1e26a70SApple OSS Distributions * errno should be returned. 844*a1e26a70SApple OSS Distributions */ 845*a1e26a70SApple OSS Distributions typedef int mpo_file_check_get_t( 846*a1e26a70SApple OSS Distributions kauth_cred_t cred, 847*a1e26a70SApple OSS Distributions struct fileglob *fg, 848*a1e26a70SApple OSS Distributions char *elements, 849*a1e26a70SApple OSS Distributions size_t len 850*a1e26a70SApple OSS Distributions ); 851*a1e26a70SApple OSS Distributions /** 852*a1e26a70SApple OSS Distributions * @brief Access control for getting the offset of a file descriptor 853*a1e26a70SApple OSS Distributions * @param cred Subject credential 854*a1e26a70SApple OSS Distributions * @param fg Fileglob structure 855*a1e26a70SApple OSS Distributions * @param label Policy label for fg 856*a1e26a70SApple OSS Distributions * 857*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 858*a1e26a70SApple OSS Distributions * get the offset of the file represented by fg. 859*a1e26a70SApple OSS Distributions * 860*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 861*a1e26a70SApple OSS Distributions * value for errno should be returned. 862*a1e26a70SApple OSS Distributions */ 863*a1e26a70SApple OSS Distributions typedef int mpo_file_check_get_offset_t( 864*a1e26a70SApple OSS Distributions kauth_cred_t cred, 865*a1e26a70SApple OSS Distributions struct fileglob *fg, 866*a1e26a70SApple OSS Distributions struct label *label 867*a1e26a70SApple OSS Distributions ); 868*a1e26a70SApple OSS Distributions /** 869*a1e26a70SApple OSS Distributions * @brief Access control for inheriting a file descriptor 870*a1e26a70SApple OSS Distributions * @param cred Subject credential 871*a1e26a70SApple OSS Distributions * @param fg Fileglob structure 872*a1e26a70SApple OSS Distributions * @param label Policy label for fg 873*a1e26a70SApple OSS Distributions * 874*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 875*a1e26a70SApple OSS Distributions * inherit the fileglob structure represented by fg. 876*a1e26a70SApple OSS Distributions * 877*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 878*a1e26a70SApple OSS Distributions * value for errno should be returned. 879*a1e26a70SApple OSS Distributions */ 880*a1e26a70SApple OSS Distributions typedef int mpo_file_check_inherit_t( 881*a1e26a70SApple OSS Distributions kauth_cred_t cred, 882*a1e26a70SApple OSS Distributions struct fileglob *fg, 883*a1e26a70SApple OSS Distributions struct label *label 884*a1e26a70SApple OSS Distributions ); 885*a1e26a70SApple OSS Distributions /** 886*a1e26a70SApple OSS Distributions * @brief Access control check for file ioctl 887*a1e26a70SApple OSS Distributions * @param cred Subject credential 888*a1e26a70SApple OSS Distributions * @param fg Fileglob structure 889*a1e26a70SApple OSS Distributions * @param label Policy label for fg 890*a1e26a70SApple OSS Distributions * @param cmd The ioctl command; see ioctl(2) 891*a1e26a70SApple OSS Distributions * 892*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 893*a1e26a70SApple OSS Distributions * the ioctl operation indicated by cmd. 894*a1e26a70SApple OSS Distributions * 895*a1e26a70SApple OSS Distributions * @warning Since ioctl data is opaque from the standpoint of the MAC 896*a1e26a70SApple OSS Distributions * framework, policies must exercise extreme care when implementing 897*a1e26a70SApple OSS Distributions * access control checks. 898*a1e26a70SApple OSS Distributions * 899*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 900*a1e26a70SApple OSS Distributions * errno should be returned. 901*a1e26a70SApple OSS Distributions * 902*a1e26a70SApple OSS Distributions */ 903*a1e26a70SApple OSS Distributions typedef int mpo_file_check_ioctl_t( 904*a1e26a70SApple OSS Distributions kauth_cred_t cred, 905*a1e26a70SApple OSS Distributions struct fileglob *fg, 906*a1e26a70SApple OSS Distributions struct label *label, 907*a1e26a70SApple OSS Distributions unsigned long cmd 908*a1e26a70SApple OSS Distributions ); 909*a1e26a70SApple OSS Distributions /** 910*a1e26a70SApple OSS Distributions * @brief Access control check for file locking 911*a1e26a70SApple OSS Distributions * @param cred Subject credential 912*a1e26a70SApple OSS Distributions * @param fg Fileglob structure 913*a1e26a70SApple OSS Distributions * @param label Policy label for fg 914*a1e26a70SApple OSS Distributions * @param op The lock operation (F_GETLK, F_SETLK, F_UNLK) 915*a1e26a70SApple OSS Distributions * @param fl The flock structure 916*a1e26a70SApple OSS Distributions * 917*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 918*a1e26a70SApple OSS Distributions * the lock operation indicated by op and fl on the file represented by fg. 919*a1e26a70SApple OSS Distributions * 920*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 921*a1e26a70SApple OSS Distributions * errno should be returned. 922*a1e26a70SApple OSS Distributions * 923*a1e26a70SApple OSS Distributions */ 924*a1e26a70SApple OSS Distributions typedef int mpo_file_check_lock_t( 925*a1e26a70SApple OSS Distributions kauth_cred_t cred, 926*a1e26a70SApple OSS Distributions struct fileglob *fg, 927*a1e26a70SApple OSS Distributions struct label *label, 928*a1e26a70SApple OSS Distributions int op, 929*a1e26a70SApple OSS Distributions struct flock *fl 930*a1e26a70SApple OSS Distributions ); 931*a1e26a70SApple OSS Distributions /** 932*a1e26a70SApple OSS Distributions * @brief Check with library validation if a Mach-O slice is allowed to be combined into a proc. 933*a1e26a70SApple OSS Distributions * @param p Subject process 934*a1e26a70SApple OSS Distributions * @param fg Fileglob structure 935*a1e26a70SApple OSS Distributions * @param slice_offset offset of the code slice 936*a1e26a70SApple OSS Distributions * @param error_message error message returned to user-space in case of error (userspace pointer) 937*a1e26a70SApple OSS Distributions * @param error_message_size error message size 938*a1e26a70SApple OSS Distributions * 939*a1e26a70SApple OSS Distributions * It's a little odd that the MAC/kext writes into userspace since this 940*a1e26a70SApple OSS Distributions * implies there is only one MAC module that implements this, however 941*a1e26a70SApple OSS Distributions * the alternative is to allocate memory in xnu, in the hope that 942*a1e26a70SApple OSS Distributions * the MAC module will use it, or allocate in the MAC module and then 943*a1e26a70SApple OSS Distributions * free it in xnu. Neither of these is very appealing, so let's go with 944*a1e26a70SApple OSS Distributions * the slightly more hacky way. 945*a1e26a70SApple OSS Distributions * 946*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 947*a1e26a70SApple OSS Distributions * errno should be returned. 948*a1e26a70SApple OSS Distributions */ 949*a1e26a70SApple OSS Distributions typedef int mpo_file_check_library_validation_t( 950*a1e26a70SApple OSS Distributions struct proc *p, 951*a1e26a70SApple OSS Distributions struct fileglob *fg, 952*a1e26a70SApple OSS Distributions off_t slice_offset, 953*a1e26a70SApple OSS Distributions user_long_t error_message, 954*a1e26a70SApple OSS Distributions size_t error_message_size 955*a1e26a70SApple OSS Distributions ); 956*a1e26a70SApple OSS Distributions /** 957*a1e26a70SApple OSS Distributions * @brief Access control check for mapping a file 958*a1e26a70SApple OSS Distributions * @param cred Subject credential 959*a1e26a70SApple OSS Distributions * @param fg fileglob representing file to map 960*a1e26a70SApple OSS Distributions * @param label Policy label associated with vp 961*a1e26a70SApple OSS Distributions * @param prot mmap protections; see mmap(2) 962*a1e26a70SApple OSS Distributions * @param flags Type of mapped object; see mmap(2) 963*a1e26a70SApple OSS Distributions * @param maxprot Maximum rights 964*a1e26a70SApple OSS Distributions * 965*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 966*a1e26a70SApple OSS Distributions * allowed to map the file represented by fg with the protections specified 967*a1e26a70SApple OSS Distributions * in prot. The maxprot field holds the maximum permissions on the new 968*a1e26a70SApple OSS Distributions * mapping, a combination of VM_PROT_READ, VM_PROT_WRITE, and VM_PROT_EXECUTE. 969*a1e26a70SApple OSS Distributions * To avoid overriding prior access control checks, a policy should only 970*a1e26a70SApple OSS Distributions * remove flags from maxprot. 971*a1e26a70SApple OSS Distributions * 972*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 973*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 974*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 975*a1e26a70SApple OSS Distributions */ 976*a1e26a70SApple OSS Distributions typedef int mpo_file_check_mmap_t( 977*a1e26a70SApple OSS Distributions kauth_cred_t cred, 978*a1e26a70SApple OSS Distributions struct fileglob *fg, 979*a1e26a70SApple OSS Distributions struct label *label, 980*a1e26a70SApple OSS Distributions int prot, 981*a1e26a70SApple OSS Distributions int flags, 982*a1e26a70SApple OSS Distributions uint64_t file_pos, 983*a1e26a70SApple OSS Distributions int *maxprot 984*a1e26a70SApple OSS Distributions ); 985*a1e26a70SApple OSS Distributions /** 986*a1e26a70SApple OSS Distributions * @brief Downgrade the mmap protections 987*a1e26a70SApple OSS Distributions * @param cred Subject credential 988*a1e26a70SApple OSS Distributions * @param fg file to map 989*a1e26a70SApple OSS Distributions * @param label Policy label associated with vp 990*a1e26a70SApple OSS Distributions * @param prot mmap protections to be downgraded 991*a1e26a70SApple OSS Distributions * 992*a1e26a70SApple OSS Distributions * Downgrade the mmap protections based on the subject and object labels. 993*a1e26a70SApple OSS Distributions */ 994*a1e26a70SApple OSS Distributions typedef void mpo_file_check_mmap_downgrade_t( 995*a1e26a70SApple OSS Distributions kauth_cred_t cred, 996*a1e26a70SApple OSS Distributions struct fileglob *fg, 997*a1e26a70SApple OSS Distributions struct label *label, 998*a1e26a70SApple OSS Distributions int *prot 999*a1e26a70SApple OSS Distributions ); 1000*a1e26a70SApple OSS Distributions /** 1001*a1e26a70SApple OSS Distributions * @brief Access control for receiving a file descriptor 1002*a1e26a70SApple OSS Distributions * @param cred Subject credential 1003*a1e26a70SApple OSS Distributions * @param fg Fileglob structure 1004*a1e26a70SApple OSS Distributions * @param label Policy label for fg 1005*a1e26a70SApple OSS Distributions * 1006*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 1007*a1e26a70SApple OSS Distributions * receive the fileglob structure represented by fg. 1008*a1e26a70SApple OSS Distributions * 1009*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 1010*a1e26a70SApple OSS Distributions * value for errno should be returned. 1011*a1e26a70SApple OSS Distributions */ 1012*a1e26a70SApple OSS Distributions typedef int mpo_file_check_receive_t( 1013*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1014*a1e26a70SApple OSS Distributions struct fileglob *fg, 1015*a1e26a70SApple OSS Distributions struct label *label 1016*a1e26a70SApple OSS Distributions ); 1017*a1e26a70SApple OSS Distributions /** 1018*a1e26a70SApple OSS Distributions * @brief Access control check for mac_set_fd 1019*a1e26a70SApple OSS Distributions * @param cred Subject credential 1020*a1e26a70SApple OSS Distributions * @param fg Fileglob structure 1021*a1e26a70SApple OSS Distributions * @param elements Elements buffer 1022*a1e26a70SApple OSS Distributions * @param len Length of elements buffer 1023*a1e26a70SApple OSS Distributions * 1024*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 1025*a1e26a70SApple OSS Distributions * perform the mac_set_fd operation. The mac_set_fd operation is used 1026*a1e26a70SApple OSS Distributions * to associate a MAC label with a file. 1027*a1e26a70SApple OSS Distributions * 1028*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1029*a1e26a70SApple OSS Distributions * errno should be returned. 1030*a1e26a70SApple OSS Distributions */ 1031*a1e26a70SApple OSS Distributions typedef int mpo_file_check_set_t( 1032*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1033*a1e26a70SApple OSS Distributions struct fileglob *fg, 1034*a1e26a70SApple OSS Distributions char *elements, 1035*a1e26a70SApple OSS Distributions size_t len 1036*a1e26a70SApple OSS Distributions ); 1037*a1e26a70SApple OSS Distributions /** 1038*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that file is being closed 1039*a1e26a70SApple OSS Distributions * @param cred Subject credential 1040*a1e26a70SApple OSS Distributions * @param fg Fileglob structure 1041*a1e26a70SApple OSS Distributions * @param label Policy label for fg 1042*a1e26a70SApple OSS Distributions * @param modified Boolean; 1 if file was modified, 0 otherwise 1043*a1e26a70SApple OSS Distributions * 1044*a1e26a70SApple OSS Distributions * Called when an open file is being closed, as a result of a call to 1045*a1e26a70SApple OSS Distributions * close(2), the process exiting, or exec(2) w/O_CLOEXEC set. 1046*a1e26a70SApple OSS Distributions */ 1047*a1e26a70SApple OSS Distributions typedef void mpo_file_notify_close_t( 1048*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1049*a1e26a70SApple OSS Distributions struct fileglob *fg, 1050*a1e26a70SApple OSS Distributions struct label *label, 1051*a1e26a70SApple OSS Distributions int modified 1052*a1e26a70SApple OSS Distributions ); 1053*a1e26a70SApple OSS Distributions /** 1054*a1e26a70SApple OSS Distributions * @brief Create file label 1055*a1e26a70SApple OSS Distributions * @param cred Subject credential 1056*a1e26a70SApple OSS Distributions * @param fg Fileglob structure 1057*a1e26a70SApple OSS Distributions * @param label Policy label for fg 1058*a1e26a70SApple OSS Distributions */ 1059*a1e26a70SApple OSS Distributions typedef void mpo_file_label_associate_t( 1060*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1061*a1e26a70SApple OSS Distributions struct fileglob *fg, 1062*a1e26a70SApple OSS Distributions struct label *label 1063*a1e26a70SApple OSS Distributions ); 1064*a1e26a70SApple OSS Distributions /** 1065*a1e26a70SApple OSS Distributions * @brief Destroy file label 1066*a1e26a70SApple OSS Distributions * @param label The label to be destroyed 1067*a1e26a70SApple OSS Distributions * 1068*a1e26a70SApple OSS Distributions * Destroy the label on a file descriptor. In this entry point, a 1069*a1e26a70SApple OSS Distributions * policy module should free any internal storage associated with 1070*a1e26a70SApple OSS Distributions * label so that it may be destroyed. 1071*a1e26a70SApple OSS Distributions */ 1072*a1e26a70SApple OSS Distributions typedef void mpo_file_label_destroy_t( 1073*a1e26a70SApple OSS Distributions struct label *label 1074*a1e26a70SApple OSS Distributions ); 1075*a1e26a70SApple OSS Distributions /** 1076*a1e26a70SApple OSS Distributions * @brief Initialize file label 1077*a1e26a70SApple OSS Distributions * @param label New label to initialize 1078*a1e26a70SApple OSS Distributions */ 1079*a1e26a70SApple OSS Distributions typedef void mpo_file_label_init_t( 1080*a1e26a70SApple OSS Distributions struct label *label 1081*a1e26a70SApple OSS Distributions ); 1082*a1e26a70SApple OSS Distributions /** 1083*a1e26a70SApple OSS Distributions * @brief Access control check for opening an I/O Kit device 1084*a1e26a70SApple OSS Distributions * @param cred Subject credential 1085*a1e26a70SApple OSS Distributions * @param user_client User client instance 1086*a1e26a70SApple OSS Distributions * @param user_client_type User client type 1087*a1e26a70SApple OSS Distributions * 1088*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can open an 1089*a1e26a70SApple OSS Distributions * I/O Kit device at the passed path of the passed user client class and 1090*a1e26a70SApple OSS Distributions * type. This check is performed after instantiating the user client. 1091*a1e26a70SApple OSS Distributions * See also mpo_iokit_check_open_service_t. 1092*a1e26a70SApple OSS Distributions * 1093*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, or an appropriate value for 1094*a1e26a70SApple OSS Distributions * errno should be returned. 1095*a1e26a70SApple OSS Distributions */ 1096*a1e26a70SApple OSS Distributions typedef int mpo_iokit_check_open_t( 1097*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1098*a1e26a70SApple OSS Distributions io_object_t user_client, 1099*a1e26a70SApple OSS Distributions unsigned int user_client_type 1100*a1e26a70SApple OSS Distributions ); 1101*a1e26a70SApple OSS Distributions /** 1102*a1e26a70SApple OSS Distributions * @brief Access control check for opening an I/O Kit device 1103*a1e26a70SApple OSS Distributions * @param cred Subject credential 1104*a1e26a70SApple OSS Distributions * @param service Service instance 1105*a1e26a70SApple OSS Distributions * @param user_client_type User client type 1106*a1e26a70SApple OSS Distributions * 1107*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can open a 1108*a1e26a70SApple OSS Distributions * I/O Kit user client of the passed service and user client type. 1109*a1e26a70SApple OSS Distributions * This check is performed before instantiating the user client. See also 1110*a1e26a70SApple OSS Distributions * mpo_iokit_check_open_t. 1111*a1e26a70SApple OSS Distributions * 1112*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, or an appropriate value for 1113*a1e26a70SApple OSS Distributions * errno should be returned. 1114*a1e26a70SApple OSS Distributions */ 1115*a1e26a70SApple OSS Distributions typedef int mpo_iokit_check_open_service_t( 1116*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1117*a1e26a70SApple OSS Distributions io_object_t service, 1118*a1e26a70SApple OSS Distributions unsigned int user_client_type 1119*a1e26a70SApple OSS Distributions ); 1120*a1e26a70SApple OSS Distributions /** 1121*a1e26a70SApple OSS Distributions * @brief Access control check for setting I/O Kit device properties 1122*a1e26a70SApple OSS Distributions * @param cred Subject credential 1123*a1e26a70SApple OSS Distributions * @param entry Target device 1124*a1e26a70SApple OSS Distributions * @param properties Property list 1125*a1e26a70SApple OSS Distributions * 1126*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can set 1127*a1e26a70SApple OSS Distributions * properties on an I/O Kit device. 1128*a1e26a70SApple OSS Distributions * 1129*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, or an appropriate value for 1130*a1e26a70SApple OSS Distributions * errno should be returned. 1131*a1e26a70SApple OSS Distributions */ 1132*a1e26a70SApple OSS Distributions typedef int mpo_iokit_check_set_properties_t( 1133*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1134*a1e26a70SApple OSS Distributions io_object_t entry, 1135*a1e26a70SApple OSS Distributions io_object_t properties 1136*a1e26a70SApple OSS Distributions ); 1137*a1e26a70SApple OSS Distributions /** 1138*a1e26a70SApple OSS Distributions * @brief Indicate desire to filter I/O Kit devices properties 1139*a1e26a70SApple OSS Distributions * @param cred Subject credential 1140*a1e26a70SApple OSS Distributions * @param entry Target device 1141*a1e26a70SApple OSS Distributions * @see mpo_iokit_check_get_property_t 1142*a1e26a70SApple OSS Distributions * 1143*a1e26a70SApple OSS Distributions * Indicate whether this policy may restrict the subject credential 1144*a1e26a70SApple OSS Distributions * from reading properties of the target device. 1145*a1e26a70SApple OSS Distributions * If a policy returns success from this entry point, the 1146*a1e26a70SApple OSS Distributions * mpo_iokit_check_get_property entry point will later be called 1147*a1e26a70SApple OSS Distributions * for each property that the subject credential tries to read from 1148*a1e26a70SApple OSS Distributions * the target device. 1149*a1e26a70SApple OSS Distributions * 1150*a1e26a70SApple OSS Distributions * This entry point is primarilly to optimize bulk property reads 1151*a1e26a70SApple OSS Distributions * by skipping calls to the mpo_iokit_check_get_property entry point 1152*a1e26a70SApple OSS Distributions * for credentials / devices no MAC policy is interested in. 1153*a1e26a70SApple OSS Distributions * 1154*a1e26a70SApple OSS Distributions * @warning Even if a policy returns 0, it should behave correctly in 1155*a1e26a70SApple OSS Distributions * the presence of an invocation of mpo_iokit_check_get_property, as that 1156*a1e26a70SApple OSS Distributions * call may happen as a result of another policy requesting a transition. 1157*a1e26a70SApple OSS Distributions * 1158*a1e26a70SApple OSS Distributions * @return Non-zero if a transition is required, 0 otherwise. 1159*a1e26a70SApple OSS Distributions */ 1160*a1e26a70SApple OSS Distributions typedef int mpo_iokit_check_filter_properties_t( 1161*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1162*a1e26a70SApple OSS Distributions io_object_t entry 1163*a1e26a70SApple OSS Distributions ); 1164*a1e26a70SApple OSS Distributions /** 1165*a1e26a70SApple OSS Distributions * @brief Access control check for getting I/O Kit device properties 1166*a1e26a70SApple OSS Distributions * @param cred Subject credential 1167*a1e26a70SApple OSS Distributions * @param entry Target device 1168*a1e26a70SApple OSS Distributions * @param name Property name 1169*a1e26a70SApple OSS Distributions * 1170*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can get 1171*a1e26a70SApple OSS Distributions * properties on an I/O Kit device. 1172*a1e26a70SApple OSS Distributions * 1173*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, or an appropriate value for 1174*a1e26a70SApple OSS Distributions * errno. 1175*a1e26a70SApple OSS Distributions */ 1176*a1e26a70SApple OSS Distributions typedef int mpo_iokit_check_get_property_t( 1177*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1178*a1e26a70SApple OSS Distributions io_object_t entry, 1179*a1e26a70SApple OSS Distributions const char *name 1180*a1e26a70SApple OSS Distributions ); 1181*a1e26a70SApple OSS Distributions /** 1182*a1e26a70SApple OSS Distributions * @brief Access control check for software HID control 1183*a1e26a70SApple OSS Distributions * @param cred Subject credential 1184*a1e26a70SApple OSS Distributions * 1185*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 1186*a1e26a70SApple OSS Distributions * control the HID (Human Interface Device) subsystem, such as to 1187*a1e26a70SApple OSS Distributions * post synthetic keypresses, pointer movement and clicks. 1188*a1e26a70SApple OSS Distributions * 1189*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, or an appropriate value for 1190*a1e26a70SApple OSS Distributions * errno. 1191*a1e26a70SApple OSS Distributions */ 1192*a1e26a70SApple OSS Distributions typedef int mpo_iokit_check_hid_control_t( 1193*a1e26a70SApple OSS Distributions kauth_cred_t cred 1194*a1e26a70SApple OSS Distributions ); 1195*a1e26a70SApple OSS Distributions /** 1196*a1e26a70SApple OSS Distributions * @brief Access control check for fsctl 1197*a1e26a70SApple OSS Distributions * @param cred Subject credential 1198*a1e26a70SApple OSS Distributions * @param mp The mount point 1199*a1e26a70SApple OSS Distributions * @param label Label associated with the mount point 1200*a1e26a70SApple OSS Distributions * @param cmd Filesystem-dependent request code; see fsctl(2) 1201*a1e26a70SApple OSS Distributions * 1202*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 1203*a1e26a70SApple OSS Distributions * the volume operation indicated by com. 1204*a1e26a70SApple OSS Distributions * 1205*a1e26a70SApple OSS Distributions * @warning The fsctl() system call is directly analogous to ioctl(); since 1206*a1e26a70SApple OSS Distributions * the associated data is opaque from the standpoint of the MAC framework 1207*a1e26a70SApple OSS Distributions * and since these operations can affect many aspects of system operation, 1208*a1e26a70SApple OSS Distributions * policies must exercise extreme care when implementing access control checks. 1209*a1e26a70SApple OSS Distributions * 1210*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1211*a1e26a70SApple OSS Distributions * errno should be returned. 1212*a1e26a70SApple OSS Distributions */ 1213*a1e26a70SApple OSS Distributions typedef int mpo_mount_check_fsctl_t( 1214*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1215*a1e26a70SApple OSS Distributions struct mount *mp, 1216*a1e26a70SApple OSS Distributions struct label *label, 1217*a1e26a70SApple OSS Distributions unsigned long cmd 1218*a1e26a70SApple OSS Distributions ); 1219*a1e26a70SApple OSS Distributions /** 1220*a1e26a70SApple OSS Distributions * @brief Access control check for the retrieval of file system attributes 1221*a1e26a70SApple OSS Distributions * @param cred Subject credential 1222*a1e26a70SApple OSS Distributions * @param mp The mount structure of the file system 1223*a1e26a70SApple OSS Distributions * @param vfa The attributes requested 1224*a1e26a70SApple OSS Distributions * 1225*a1e26a70SApple OSS Distributions * This entry point determines whether given subject can get information 1226*a1e26a70SApple OSS Distributions * about the given file system. This check happens during statfs() syscalls, 1227*a1e26a70SApple OSS Distributions * but is also used by other parts within the kernel such as the audit system. 1228*a1e26a70SApple OSS Distributions * 1229*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1230*a1e26a70SApple OSS Distributions * errno should be returned. 1231*a1e26a70SApple OSS Distributions * 1232*a1e26a70SApple OSS Distributions * @note Policies may change the contents of vfa to alter the list of 1233*a1e26a70SApple OSS Distributions * file system attributes returned. 1234*a1e26a70SApple OSS Distributions */ 1235*a1e26a70SApple OSS Distributions 1236*a1e26a70SApple OSS Distributions typedef int mpo_mount_check_getattr_t( 1237*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1238*a1e26a70SApple OSS Distributions struct mount *mp, 1239*a1e26a70SApple OSS Distributions struct label *mp_label, 1240*a1e26a70SApple OSS Distributions struct vfs_attr *vfa 1241*a1e26a70SApple OSS Distributions ); 1242*a1e26a70SApple OSS Distributions /** 1243*a1e26a70SApple OSS Distributions * @brief Access control check for mount point relabeling 1244*a1e26a70SApple OSS Distributions * @param cred Subject credential 1245*a1e26a70SApple OSS Distributions * @param mp Object file system mount point 1246*a1e26a70SApple OSS Distributions * @param mntlabel Policy label for fle system mount point 1247*a1e26a70SApple OSS Distributions * 1248*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can relabel 1249*a1e26a70SApple OSS Distributions * the mount point. This call is made when a file system mount is updated. 1250*a1e26a70SApple OSS Distributions * 1251*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1252*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch 1253*a1e26a70SApple OSS Distributions * or EPERM for lack of privilege. 1254*a1e26a70SApple OSS Distributions */ 1255*a1e26a70SApple OSS Distributions typedef int mpo_mount_check_label_update_t( 1256*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1257*a1e26a70SApple OSS Distributions struct mount *mp, 1258*a1e26a70SApple OSS Distributions struct label *mntlabel 1259*a1e26a70SApple OSS Distributions ); 1260*a1e26a70SApple OSS Distributions /** 1261*a1e26a70SApple OSS Distributions * @brief Access control check for mounting a file system 1262*a1e26a70SApple OSS Distributions * @param cred Subject credential 1263*a1e26a70SApple OSS Distributions * @param vp Vnode that is to be the mount point 1264*a1e26a70SApple OSS Distributions * @param vlabel Label associated with the vnode 1265*a1e26a70SApple OSS Distributions * @param cnp Component name for vp 1266*a1e26a70SApple OSS Distributions * @param vfc_name Filesystem type name 1267*a1e26a70SApple OSS Distributions * 1268*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 1269*a1e26a70SApple OSS Distributions * the mount operation on the target vnode. 1270*a1e26a70SApple OSS Distributions * 1271*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1272*a1e26a70SApple OSS Distributions * errno should be returned. 1273*a1e26a70SApple OSS Distributions */ 1274*a1e26a70SApple OSS Distributions typedef int mpo_mount_check_mount_t( 1275*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1276*a1e26a70SApple OSS Distributions struct vnode *vp, 1277*a1e26a70SApple OSS Distributions struct label *vlabel, 1278*a1e26a70SApple OSS Distributions struct componentname *cnp, 1279*a1e26a70SApple OSS Distributions const char *vfc_name 1280*a1e26a70SApple OSS Distributions ); 1281*a1e26a70SApple OSS Distributions /** 1282*a1e26a70SApple OSS Distributions * @brief Access control check for mounting a file system (late) 1283*a1e26a70SApple OSS Distributions * @param cred Subject credential 1284*a1e26a70SApple OSS Distributions * @param mp Mount point 1285*a1e26a70SApple OSS Distributions * 1286*a1e26a70SApple OSS Distributions * Similar to mpo_mount_check_mount, but occurs after VFS_MOUNT has been 1287*a1e26a70SApple OSS Distributions * called, making it possible to access mnt_vfsstat.f_mntfromname and other 1288*a1e26a70SApple OSS Distributions * fields. 1289*a1e26a70SApple OSS Distributions * 1290*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1291*a1e26a70SApple OSS Distributions * errno should be returned. 1292*a1e26a70SApple OSS Distributions */ 1293*a1e26a70SApple OSS Distributions typedef int mpo_mount_check_mount_late_t( 1294*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1295*a1e26a70SApple OSS Distributions struct mount *mp 1296*a1e26a70SApple OSS Distributions ); 1297*a1e26a70SApple OSS Distributions 1298*a1e26a70SApple OSS Distributions /** 1299*a1e26a70SApple OSS Distributions * @brief Access control check for quotactl 1300*a1e26a70SApple OSS Distributions * @param cred Subject credential 1301*a1e26a70SApple OSS Distributions * @param cmd The quotactl command and subcommand; see quotactl(2) 1302*a1e26a70SApple OSS Distributions * @param id The user or group ID on which cmd will operate 1303*a1e26a70SApple OSS Distributions * 1304*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 1305*a1e26a70SApple OSS Distributions * the quotactl operation indicated by cmd. 1306*a1e26a70SApple OSS Distributions * 1307*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1308*a1e26a70SApple OSS Distributions * errno should be returned. 1309*a1e26a70SApple OSS Distributions */ 1310*a1e26a70SApple OSS Distributions typedef int mpo_mount_check_quotactl_t( 1311*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1312*a1e26a70SApple OSS Distributions struct mount *mp, 1313*a1e26a70SApple OSS Distributions int cmd, 1314*a1e26a70SApple OSS Distributions int id 1315*a1e26a70SApple OSS Distributions ); 1316*a1e26a70SApple OSS Distributions /** 1317*a1e26a70SApple OSS Distributions * @brief Access control check for fs_snapshot_create 1318*a1e26a70SApple OSS Distributions * @param cred Subject credential 1319*a1e26a70SApple OSS Distributions * @mp Filesystem mount point to create snapshot of 1320*a1e26a70SApple OSS Distributions * @name Name of snapshot to create 1321*a1e26a70SApple OSS Distributions * 1322*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 1323*a1e26a70SApple OSS Distributions * create a snapshot of the filesystem at the given mount point. 1324*a1e26a70SApple OSS Distributions * 1325*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value 1326*a1e26a70SApple OSS Distributions * for errno should be returned. 1327*a1e26a70SApple OSS Distributions */ 1328*a1e26a70SApple OSS Distributions typedef int mpo_mount_check_snapshot_create_t( 1329*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1330*a1e26a70SApple OSS Distributions struct mount *mp, 1331*a1e26a70SApple OSS Distributions const char *name 1332*a1e26a70SApple OSS Distributions ); 1333*a1e26a70SApple OSS Distributions /** 1334*a1e26a70SApple OSS Distributions * @brief Access control check for fs_snapshot_delete 1335*a1e26a70SApple OSS Distributions * @param cred Subject credential 1336*a1e26a70SApple OSS Distributions * @mp Filesystem mount point to delete snapshot of 1337*a1e26a70SApple OSS Distributions * @name Name of snapshot to delete 1338*a1e26a70SApple OSS Distributions * 1339*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 1340*a1e26a70SApple OSS Distributions * delete the named snapshot from the filesystem at the given 1341*a1e26a70SApple OSS Distributions * mount point. 1342*a1e26a70SApple OSS Distributions * 1343*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value 1344*a1e26a70SApple OSS Distributions * for errno should be returned. 1345*a1e26a70SApple OSS Distributions */ 1346*a1e26a70SApple OSS Distributions typedef int mpo_mount_check_snapshot_delete_t( 1347*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1348*a1e26a70SApple OSS Distributions struct mount *mp, 1349*a1e26a70SApple OSS Distributions const char *name 1350*a1e26a70SApple OSS Distributions ); 1351*a1e26a70SApple OSS Distributions /** 1352*a1e26a70SApple OSS Distributions * @brief Access control check for fs_snapshot_mount 1353*a1e26a70SApple OSS Distributions * @param cred Subject credential 1354*a1e26a70SApple OSS Distributions * @param rvp Vnode of either the root directory of the 1355*a1e26a70SApple OSS Distributions * filesystem to mount snapshot of, or the device from 1356*a1e26a70SApple OSS Distributions * which to mount the snapshot. 1357*a1e26a70SApple OSS Distributions * @param vp Vnode that is to be the mount point 1358*a1e26a70SApple OSS Distributions * @param cnp Component name for vp 1359*a1e26a70SApple OSS Distributions * @param name Name of snapshot to mount 1360*a1e26a70SApple OSS Distributions * @param vfc_name Filesystem type name 1361*a1e26a70SApple OSS Distributions * 1362*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 1363*a1e26a70SApple OSS Distributions * mount the named snapshot from the filesystem at the given 1364*a1e26a70SApple OSS Distributions * directory. 1365*a1e26a70SApple OSS Distributions * 1366*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value 1367*a1e26a70SApple OSS Distributions * for errno should be returned. 1368*a1e26a70SApple OSS Distributions */ 1369*a1e26a70SApple OSS Distributions typedef int mpo_mount_check_snapshot_mount_t( 1370*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1371*a1e26a70SApple OSS Distributions struct vnode *rvp, 1372*a1e26a70SApple OSS Distributions struct vnode *vp, 1373*a1e26a70SApple OSS Distributions struct componentname *cnp, 1374*a1e26a70SApple OSS Distributions const char *name, 1375*a1e26a70SApple OSS Distributions const char *vfc_name 1376*a1e26a70SApple OSS Distributions ); 1377*a1e26a70SApple OSS Distributions /** 1378*a1e26a70SApple OSS Distributions * @brief Access control check for fs_snapshot_revert 1379*a1e26a70SApple OSS Distributions * @param cred Subject credential 1380*a1e26a70SApple OSS Distributions * @mp Filesystem mount point to revert to snapshot 1381*a1e26a70SApple OSS Distributions * @name Name of snapshot to revert to 1382*a1e26a70SApple OSS Distributions * 1383*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 1384*a1e26a70SApple OSS Distributions * revert the filesystem at the given mount point to the named snapshot. 1385*a1e26a70SApple OSS Distributions * 1386*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value 1387*a1e26a70SApple OSS Distributions * for errno should be returned. 1388*a1e26a70SApple OSS Distributions */ 1389*a1e26a70SApple OSS Distributions typedef int mpo_mount_check_snapshot_revert_t( 1390*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1391*a1e26a70SApple OSS Distributions struct mount *mp, 1392*a1e26a70SApple OSS Distributions const char *name 1393*a1e26a70SApple OSS Distributions ); 1394*a1e26a70SApple OSS Distributions /** 1395*a1e26a70SApple OSS Distributions * @brief Access control check remounting a filesystem 1396*a1e26a70SApple OSS Distributions * @param cred Subject credential 1397*a1e26a70SApple OSS Distributions * @param mp The mount point 1398*a1e26a70SApple OSS Distributions * @param mlabel Label currently associated with the mount point 1399*a1e26a70SApple OSS Distributions * @param flags Requested updated flags 1400*a1e26a70SApple OSS Distributions * 1401*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 1402*a1e26a70SApple OSS Distributions * the remount operation on the target vnode. 1403*a1e26a70SApple OSS Distributions * 1404*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1405*a1e26a70SApple OSS Distributions * errno should be returned. 1406*a1e26a70SApple OSS Distributions */ 1407*a1e26a70SApple OSS Distributions #define NEEDS_RDAR_103115865 1 // Required until both EndpointSecurity & Sandbox are updated 1408*a1e26a70SApple OSS Distributions typedef int mpo_mount_check_remount_t( 1409*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1410*a1e26a70SApple OSS Distributions struct mount *mp, 1411*a1e26a70SApple OSS Distributions struct label *mlabel, 1412*a1e26a70SApple OSS Distributions uint64_t flags 1413*a1e26a70SApple OSS Distributions ); 1414*a1e26a70SApple OSS Distributions /** 1415*a1e26a70SApple OSS Distributions * @brief Access control check for the settting of file system attributes 1416*a1e26a70SApple OSS Distributions * @param cred Subject credential 1417*a1e26a70SApple OSS Distributions * @param mp The mount structure of the file system 1418*a1e26a70SApple OSS Distributions * @param vfa The attributes requested 1419*a1e26a70SApple OSS Distributions * 1420*a1e26a70SApple OSS Distributions * This entry point determines whether given subject can set information 1421*a1e26a70SApple OSS Distributions * about the given file system, for example the volume name. 1422*a1e26a70SApple OSS Distributions * 1423*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1424*a1e26a70SApple OSS Distributions * errno should be returned. 1425*a1e26a70SApple OSS Distributions */ 1426*a1e26a70SApple OSS Distributions 1427*a1e26a70SApple OSS Distributions typedef int mpo_mount_check_setattr_t( 1428*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1429*a1e26a70SApple OSS Distributions struct mount *mp, 1430*a1e26a70SApple OSS Distributions struct label *mp_label, 1431*a1e26a70SApple OSS Distributions struct vfs_attr *vfa 1432*a1e26a70SApple OSS Distributions ); 1433*a1e26a70SApple OSS Distributions /** 1434*a1e26a70SApple OSS Distributions * @brief Access control check for file system statistics 1435*a1e26a70SApple OSS Distributions * @param cred Subject credential 1436*a1e26a70SApple OSS Distributions * @param mp Object file system mount 1437*a1e26a70SApple OSS Distributions * @param mntlabel Policy label for mp 1438*a1e26a70SApple OSS Distributions * 1439*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can see 1440*a1e26a70SApple OSS Distributions * the results of a statfs performed on the file system. This call may 1441*a1e26a70SApple OSS Distributions * be made in a number of situations, including during invocations of 1442*a1e26a70SApple OSS Distributions * statfs(2) and related calls, as well as to determine what file systems 1443*a1e26a70SApple OSS Distributions * to exclude from listings of file systems, such as when getfsstat(2) 1444*a1e26a70SApple OSS Distributions * is invoked. 1445*a1e26a70SApple OSS Distributions * 1446*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1447*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch 1448*a1e26a70SApple OSS Distributions * or EPERM for lack of privilege. 1449*a1e26a70SApple OSS Distributions */ 1450*a1e26a70SApple OSS Distributions typedef int mpo_mount_check_stat_t( 1451*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1452*a1e26a70SApple OSS Distributions struct mount *mp, 1453*a1e26a70SApple OSS Distributions struct label *mntlabel 1454*a1e26a70SApple OSS Distributions ); 1455*a1e26a70SApple OSS Distributions /** 1456*a1e26a70SApple OSS Distributions * @brief Access control check for unmounting a filesystem 1457*a1e26a70SApple OSS Distributions * @param cred Subject credential 1458*a1e26a70SApple OSS Distributions * @param mp The mount point 1459*a1e26a70SApple OSS Distributions * @param mlabel Label associated with the mount point 1460*a1e26a70SApple OSS Distributions * 1461*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 1462*a1e26a70SApple OSS Distributions * the unmount operation on the target vnode. 1463*a1e26a70SApple OSS Distributions * 1464*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1465*a1e26a70SApple OSS Distributions * errno should be returned. 1466*a1e26a70SApple OSS Distributions */ 1467*a1e26a70SApple OSS Distributions typedef int mpo_mount_check_umount_t( 1468*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1469*a1e26a70SApple OSS Distributions struct mount *mp, 1470*a1e26a70SApple OSS Distributions struct label *mlabel 1471*a1e26a70SApple OSS Distributions ); 1472*a1e26a70SApple OSS Distributions /** 1473*a1e26a70SApple OSS Distributions * @brief Create mount labels 1474*a1e26a70SApple OSS Distributions * @param cred Subject credential 1475*a1e26a70SApple OSS Distributions * @param mp Mount point of file system being mounted 1476*a1e26a70SApple OSS Distributions * @param mntlabel Label to associate with the new mount point 1477*a1e26a70SApple OSS Distributions * @see mpo_mount_label_init_t 1478*a1e26a70SApple OSS Distributions * 1479*a1e26a70SApple OSS Distributions * Fill out the labels on the mount point being created by the supplied 1480*a1e26a70SApple OSS Distributions * user credential. This call is made when file systems are first mounted. 1481*a1e26a70SApple OSS Distributions */ 1482*a1e26a70SApple OSS Distributions typedef void mpo_mount_label_associate_t( 1483*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1484*a1e26a70SApple OSS Distributions struct mount *mp, 1485*a1e26a70SApple OSS Distributions struct label *mntlabel 1486*a1e26a70SApple OSS Distributions ); 1487*a1e26a70SApple OSS Distributions /** 1488*a1e26a70SApple OSS Distributions * @brief Destroy mount label 1489*a1e26a70SApple OSS Distributions * @param label The label to be destroyed 1490*a1e26a70SApple OSS Distributions * 1491*a1e26a70SApple OSS Distributions * Destroy a file system mount label. Since the 1492*a1e26a70SApple OSS Distributions * object is going out of scope, policy modules should free any 1493*a1e26a70SApple OSS Distributions * internal storage associated with the label so that it may be 1494*a1e26a70SApple OSS Distributions * destroyed. 1495*a1e26a70SApple OSS Distributions */ 1496*a1e26a70SApple OSS Distributions typedef void mpo_mount_label_destroy_t( 1497*a1e26a70SApple OSS Distributions struct label *label 1498*a1e26a70SApple OSS Distributions ); 1499*a1e26a70SApple OSS Distributions /** 1500*a1e26a70SApple OSS Distributions * @brief Externalize a mount point label 1501*a1e26a70SApple OSS Distributions * @param label Label to be externalized 1502*a1e26a70SApple OSS Distributions * @param element_name Name of the label namespace for which labels should be 1503*a1e26a70SApple OSS Distributions * externalized 1504*a1e26a70SApple OSS Distributions * @param sb String buffer to be filled with a text representation of the label 1505*a1e26a70SApple OSS Distributions * 1506*a1e26a70SApple OSS Distributions * Produce an external representation of the mount point label. An 1507*a1e26a70SApple OSS Distributions * externalized label consists of a text representation of the label 1508*a1e26a70SApple OSS Distributions * contents that can be used with user applications. Policy-agnostic 1509*a1e26a70SApple OSS Distributions * user space tools will display this externalized version. 1510*a1e26a70SApple OSS Distributions * 1511*a1e26a70SApple OSS Distributions * The policy's externalize entry points will be called only if the 1512*a1e26a70SApple OSS Distributions * policy has registered interest in the label namespace. 1513*a1e26a70SApple OSS Distributions * 1514*a1e26a70SApple OSS Distributions * @return 0 on success, return non-zero if an error occurs while 1515*a1e26a70SApple OSS Distributions * externalizing the label data. 1516*a1e26a70SApple OSS Distributions * 1517*a1e26a70SApple OSS Distributions */ 1518*a1e26a70SApple OSS Distributions typedef int mpo_mount_label_externalize_t( 1519*a1e26a70SApple OSS Distributions struct label *label, 1520*a1e26a70SApple OSS Distributions char *element_name, 1521*a1e26a70SApple OSS Distributions struct sbuf *sb 1522*a1e26a70SApple OSS Distributions ); 1523*a1e26a70SApple OSS Distributions /** 1524*a1e26a70SApple OSS Distributions * @brief Initialize mount point label 1525*a1e26a70SApple OSS Distributions * @param label New label to initialize 1526*a1e26a70SApple OSS Distributions * 1527*a1e26a70SApple OSS Distributions * Initialize the label for a newly instantiated mount structure. 1528*a1e26a70SApple OSS Distributions * This label is typically used to store a default label in the case 1529*a1e26a70SApple OSS Distributions * that the file system has been mounted singlelabel. Since some 1530*a1e26a70SApple OSS Distributions * file systems do not support persistent labels (extended attributes) 1531*a1e26a70SApple OSS Distributions * or are read-only (such as CD-ROMs), it is often necessary to store 1532*a1e26a70SApple OSS Distributions * a default label separately from the label of the mount point 1533*a1e26a70SApple OSS Distributions * itself. Sleeping is permitted. 1534*a1e26a70SApple OSS Distributions */ 1535*a1e26a70SApple OSS Distributions typedef void mpo_mount_label_init_t( 1536*a1e26a70SApple OSS Distributions struct label *label 1537*a1e26a70SApple OSS Distributions ); 1538*a1e26a70SApple OSS Distributions /** 1539*a1e26a70SApple OSS Distributions * @brief Internalize a mount point label 1540*a1e26a70SApple OSS Distributions * @param label Label to be internalized 1541*a1e26a70SApple OSS Distributions * @param element_name Name of the label namespace for which the label should 1542*a1e26a70SApple OSS Distributions * be internalized 1543*a1e26a70SApple OSS Distributions * @param element_data Text data to be internalized 1544*a1e26a70SApple OSS Distributions * 1545*a1e26a70SApple OSS Distributions * Produce a mount point file system label from an external representation. 1546*a1e26a70SApple OSS Distributions * An externalized label consists of a text representation of the label 1547*a1e26a70SApple OSS Distributions * contents that can be used with user applications. Policy-agnostic 1548*a1e26a70SApple OSS Distributions * user space tools will forward text version to the kernel for 1549*a1e26a70SApple OSS Distributions * processing by individual policy modules. 1550*a1e26a70SApple OSS Distributions * 1551*a1e26a70SApple OSS Distributions * The policy's internalize entry points will be called only if the 1552*a1e26a70SApple OSS Distributions * policy has registered interest in the label namespace. 1553*a1e26a70SApple OSS Distributions * 1554*a1e26a70SApple OSS Distributions * @return 0 on success, Otherwise, return non-zero if an error occurs 1555*a1e26a70SApple OSS Distributions * while internalizing the label data. 1556*a1e26a70SApple OSS Distributions * 1557*a1e26a70SApple OSS Distributions */ 1558*a1e26a70SApple OSS Distributions typedef int mpo_mount_label_internalize_t( 1559*a1e26a70SApple OSS Distributions struct label *label, 1560*a1e26a70SApple OSS Distributions char *element_name, 1561*a1e26a70SApple OSS Distributions char *element_data 1562*a1e26a70SApple OSS Distributions ); 1563*a1e26a70SApple OSS Distributions /** 1564*a1e26a70SApple OSS Distributions * @brief Notify on successful filesystem mount 1565*a1e26a70SApple OSS Distributions * @param cred Subject credential 1566*a1e26a70SApple OSS Distributions * @param mp Mount point of file system being mounted 1567*a1e26a70SApple OSS Distributions * @param mntlabel Label to associate with the new mount point 1568*a1e26a70SApple OSS Distributions * @see mpo_mount_label_init_t 1569*a1e26a70SApple OSS Distributions * 1570*a1e26a70SApple OSS Distributions * Notify on successful filesystem mount. The mntlabel associated 1571*a1e26a70SApple OSS Distributions * to this mount point should be initalized with mac_mount_label_init 1572*a1e26a70SApple OSS Distributions * prior to this call. 1573*a1e26a70SApple OSS Distributions */ 1574*a1e26a70SApple OSS Distributions typedef void mpo_mount_notify_mount_t( 1575*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1576*a1e26a70SApple OSS Distributions struct mount *mp, 1577*a1e26a70SApple OSS Distributions struct label *mntlabel 1578*a1e26a70SApple OSS Distributions ); 1579*a1e26a70SApple OSS Distributions /** 1580*a1e26a70SApple OSS Distributions * @brief Access control check for opening an NECP file descriptor 1581*a1e26a70SApple OSS Distributions * @param cred Subject credential 1582*a1e26a70SApple OSS Distributions * @param flags Open flags 1583*a1e26a70SApple OSS Distributions * 1584*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can open 1585*a1e26a70SApple OSS Distributions * an NECP file descriptor. 1586*a1e26a70SApple OSS Distributions * 1587*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1588*a1e26a70SApple OSS Distributions * errno should be returned. 1589*a1e26a70SApple OSS Distributions * 1590*a1e26a70SApple OSS Distributions */ 1591*a1e26a70SApple OSS Distributions typedef int mpo_necp_check_open_t( 1592*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1593*a1e26a70SApple OSS Distributions int flags 1594*a1e26a70SApple OSS Distributions ); 1595*a1e26a70SApple OSS Distributions /** 1596*a1e26a70SApple OSS Distributions * @brief Access control check for necp_client_action(2) 1597*a1e26a70SApple OSS Distributions * @param cred Subject credential 1598*a1e26a70SApple OSS Distributions * @param fg NECP fileglob 1599*a1e26a70SApple OSS Distributions * @param action NECP client action 1600*a1e26a70SApple OSS Distributions * 1601*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can open 1602*a1e26a70SApple OSS Distributions * an NECP socket. 1603*a1e26a70SApple OSS Distributions * 1604*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1605*a1e26a70SApple OSS Distributions * errno should be returned. 1606*a1e26a70SApple OSS Distributions * 1607*a1e26a70SApple OSS Distributions */ 1608*a1e26a70SApple OSS Distributions typedef int mpo_necp_check_client_action_t( 1609*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1610*a1e26a70SApple OSS Distributions struct fileglob *fg, 1611*a1e26a70SApple OSS Distributions uint32_t action 1612*a1e26a70SApple OSS Distributions ); 1613*a1e26a70SApple OSS Distributions /** 1614*a1e26a70SApple OSS Distributions * @brief Access control check for pipe ioctl 1615*a1e26a70SApple OSS Distributions * @param cred Subject credential 1616*a1e26a70SApple OSS Distributions * @param cpipe Object to be accessed 1617*a1e26a70SApple OSS Distributions * @param pipelabel The label on the pipe 1618*a1e26a70SApple OSS Distributions * @param cmd The ioctl command; see ioctl(2) 1619*a1e26a70SApple OSS Distributions * 1620*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 1621*a1e26a70SApple OSS Distributions * the ioctl operation indicated by cmd. 1622*a1e26a70SApple OSS Distributions * 1623*a1e26a70SApple OSS Distributions * @warning Since ioctl data is opaque from the standpoint of the MAC 1624*a1e26a70SApple OSS Distributions * framework, policies must exercise extreme care when implementing 1625*a1e26a70SApple OSS Distributions * access control checks. 1626*a1e26a70SApple OSS Distributions * 1627*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1628*a1e26a70SApple OSS Distributions * errno should be returned. 1629*a1e26a70SApple OSS Distributions * 1630*a1e26a70SApple OSS Distributions */ 1631*a1e26a70SApple OSS Distributions typedef int mpo_pipe_check_ioctl_t( 1632*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1633*a1e26a70SApple OSS Distributions struct pipe *cpipe, 1634*a1e26a70SApple OSS Distributions struct label *pipelabel, 1635*a1e26a70SApple OSS Distributions unsigned long cmd 1636*a1e26a70SApple OSS Distributions ); 1637*a1e26a70SApple OSS Distributions /** 1638*a1e26a70SApple OSS Distributions * @brief Access control check for pipe kqfilter 1639*a1e26a70SApple OSS Distributions * @param cred Subject credential 1640*a1e26a70SApple OSS Distributions * @param kn Object knote 1641*a1e26a70SApple OSS Distributions * @param cpipe Object to be accessed 1642*a1e26a70SApple OSS Distributions * @param pipelabel Policy label for the pipe 1643*a1e26a70SApple OSS Distributions * 1644*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 1645*a1e26a70SApple OSS Distributions * receive the knote on the passed pipe. 1646*a1e26a70SApple OSS Distributions * 1647*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 1648*a1e26a70SApple OSS Distributions * value for errno should be returned. 1649*a1e26a70SApple OSS Distributions */ 1650*a1e26a70SApple OSS Distributions typedef int mpo_pipe_check_kqfilter_t( 1651*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1652*a1e26a70SApple OSS Distributions struct knote *kn, 1653*a1e26a70SApple OSS Distributions struct pipe *cpipe, 1654*a1e26a70SApple OSS Distributions struct label *pipelabel 1655*a1e26a70SApple OSS Distributions ); 1656*a1e26a70SApple OSS Distributions /** 1657*a1e26a70SApple OSS Distributions * @brief Access control check for pipe read 1658*a1e26a70SApple OSS Distributions * @param cred Subject credential 1659*a1e26a70SApple OSS Distributions * @param cpipe Object to be accessed 1660*a1e26a70SApple OSS Distributions * @param pipelabel The label on the pipe 1661*a1e26a70SApple OSS Distributions * 1662*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 1663*a1e26a70SApple OSS Distributions * perform a read operation on the passed pipe. The cred object holds 1664*a1e26a70SApple OSS Distributions * the credentials of the subject performing the operation. 1665*a1e26a70SApple OSS Distributions * 1666*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1667*a1e26a70SApple OSS Distributions * errno should be returned. 1668*a1e26a70SApple OSS Distributions * 1669*a1e26a70SApple OSS Distributions */ 1670*a1e26a70SApple OSS Distributions typedef int mpo_pipe_check_read_t( 1671*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1672*a1e26a70SApple OSS Distributions struct pipe *cpipe, 1673*a1e26a70SApple OSS Distributions struct label *pipelabel 1674*a1e26a70SApple OSS Distributions ); 1675*a1e26a70SApple OSS Distributions /** 1676*a1e26a70SApple OSS Distributions * @brief Access control check for pipe select 1677*a1e26a70SApple OSS Distributions * @param cred Subject credential 1678*a1e26a70SApple OSS Distributions * @param cpipe Object to be accessed 1679*a1e26a70SApple OSS Distributions * @param pipelabel The label on the pipe 1680*a1e26a70SApple OSS Distributions * @param which The operation selected on: FREAD or FWRITE 1681*a1e26a70SApple OSS Distributions * 1682*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 1683*a1e26a70SApple OSS Distributions * perform a select operation on the passed pipe. The cred object holds 1684*a1e26a70SApple OSS Distributions * the credentials of the subject performing the operation. 1685*a1e26a70SApple OSS Distributions * 1686*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1687*a1e26a70SApple OSS Distributions * errno should be returned. 1688*a1e26a70SApple OSS Distributions * 1689*a1e26a70SApple OSS Distributions */ 1690*a1e26a70SApple OSS Distributions typedef int mpo_pipe_check_select_t( 1691*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1692*a1e26a70SApple OSS Distributions struct pipe *cpipe, 1693*a1e26a70SApple OSS Distributions struct label *pipelabel, 1694*a1e26a70SApple OSS Distributions int which 1695*a1e26a70SApple OSS Distributions ); 1696*a1e26a70SApple OSS Distributions /** 1697*a1e26a70SApple OSS Distributions * @brief Access control check for pipe stat 1698*a1e26a70SApple OSS Distributions * @param cred Subject credential 1699*a1e26a70SApple OSS Distributions * @param cpipe Object to be accessed 1700*a1e26a70SApple OSS Distributions * @param pipelabel The label on the pipe 1701*a1e26a70SApple OSS Distributions * 1702*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 1703*a1e26a70SApple OSS Distributions * perform a stat operation on the passed pipe. The cred object holds 1704*a1e26a70SApple OSS Distributions * the credentials of the subject performing the operation. 1705*a1e26a70SApple OSS Distributions * 1706*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1707*a1e26a70SApple OSS Distributions * errno should be returned. 1708*a1e26a70SApple OSS Distributions * 1709*a1e26a70SApple OSS Distributions */ 1710*a1e26a70SApple OSS Distributions typedef int mpo_pipe_check_stat_t( 1711*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1712*a1e26a70SApple OSS Distributions struct pipe *cpipe, 1713*a1e26a70SApple OSS Distributions struct label *pipelabel 1714*a1e26a70SApple OSS Distributions ); 1715*a1e26a70SApple OSS Distributions /** 1716*a1e26a70SApple OSS Distributions * @brief Access control check for pipe write 1717*a1e26a70SApple OSS Distributions * @param cred Subject credential 1718*a1e26a70SApple OSS Distributions * @param cpipe Object to be accessed 1719*a1e26a70SApple OSS Distributions * @param pipelabel The label on the pipe 1720*a1e26a70SApple OSS Distributions * 1721*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 1722*a1e26a70SApple OSS Distributions * perform a write operation on the passed pipe. The cred object holds 1723*a1e26a70SApple OSS Distributions * the credentials of the subject performing the operation. 1724*a1e26a70SApple OSS Distributions * 1725*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1726*a1e26a70SApple OSS Distributions * errno should be returned. 1727*a1e26a70SApple OSS Distributions * 1728*a1e26a70SApple OSS Distributions */ 1729*a1e26a70SApple OSS Distributions typedef int mpo_pipe_check_write_t( 1730*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1731*a1e26a70SApple OSS Distributions struct pipe *cpipe, 1732*a1e26a70SApple OSS Distributions struct label *pipelabel 1733*a1e26a70SApple OSS Distributions ); 1734*a1e26a70SApple OSS Distributions /** 1735*a1e26a70SApple OSS Distributions * @brief Create a pipe label 1736*a1e26a70SApple OSS Distributions * @param cred Subject credential 1737*a1e26a70SApple OSS Distributions * @param cpipe object to be labeled 1738*a1e26a70SApple OSS Distributions * @param pipelabel Label for the pipe object 1739*a1e26a70SApple OSS Distributions * 1740*a1e26a70SApple OSS Distributions * Create a label for the pipe object being created by the supplied 1741*a1e26a70SApple OSS Distributions * user credential. This call is made when a pipe pair is being created. 1742*a1e26a70SApple OSS Distributions * The label is shared by both ends of the pipe. 1743*a1e26a70SApple OSS Distributions */ 1744*a1e26a70SApple OSS Distributions typedef void mpo_pipe_label_associate_t( 1745*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1746*a1e26a70SApple OSS Distributions struct pipe *cpipe, 1747*a1e26a70SApple OSS Distributions struct label *pipelabel 1748*a1e26a70SApple OSS Distributions ); 1749*a1e26a70SApple OSS Distributions /** 1750*a1e26a70SApple OSS Distributions * @brief Destroy pipe label 1751*a1e26a70SApple OSS Distributions * @param label The label to be destroyed 1752*a1e26a70SApple OSS Distributions * 1753*a1e26a70SApple OSS Distributions * Destroy a pipe label. Since the object is going out of scope, 1754*a1e26a70SApple OSS Distributions * policy modules should free any internal storage associated with the 1755*a1e26a70SApple OSS Distributions * label so that it may be destroyed. 1756*a1e26a70SApple OSS Distributions */ 1757*a1e26a70SApple OSS Distributions typedef void mpo_pipe_label_destroy_t( 1758*a1e26a70SApple OSS Distributions struct label *label 1759*a1e26a70SApple OSS Distributions ); 1760*a1e26a70SApple OSS Distributions /** 1761*a1e26a70SApple OSS Distributions * @brief Initialize pipe label 1762*a1e26a70SApple OSS Distributions * @param label New label to initialize 1763*a1e26a70SApple OSS Distributions * 1764*a1e26a70SApple OSS Distributions * Initialize label storage for use with a newly instantiated pipe object. 1765*a1e26a70SApple OSS Distributions * Sleeping is permitted. 1766*a1e26a70SApple OSS Distributions */ 1767*a1e26a70SApple OSS Distributions typedef void mpo_pipe_label_init_t( 1768*a1e26a70SApple OSS Distributions struct label *label 1769*a1e26a70SApple OSS Distributions ); 1770*a1e26a70SApple OSS Distributions /** 1771*a1e26a70SApple OSS Distributions * @brief Policy unload event 1772*a1e26a70SApple OSS Distributions * @param mpc MAC policy configuration 1773*a1e26a70SApple OSS Distributions * 1774*a1e26a70SApple OSS Distributions * This is the MAC Framework policy unload event. This entry point will 1775*a1e26a70SApple OSS Distributions * only be called if the module's policy configuration allows unload (if 1776*a1e26a70SApple OSS Distributions * the MPC_LOADTIME_FLAG_UNLOADOK is set). Most security policies won't 1777*a1e26a70SApple OSS Distributions * want to be unloaded; they should set their flags to prevent this 1778*a1e26a70SApple OSS Distributions * entry point from being called. 1779*a1e26a70SApple OSS Distributions * 1780*a1e26a70SApple OSS Distributions * @warning During this call, the mac policy list mutex is held, so 1781*a1e26a70SApple OSS Distributions * sleep operations cannot be performed, and calls out to other kernel 1782*a1e26a70SApple OSS Distributions * subsystems must be made with caution. 1783*a1e26a70SApple OSS Distributions * 1784*a1e26a70SApple OSS Distributions * @see MPC_LOADTIME_FLAG_UNLOADOK 1785*a1e26a70SApple OSS Distributions */ 1786*a1e26a70SApple OSS Distributions typedef void mpo_policy_destroy_t( 1787*a1e26a70SApple OSS Distributions struct mac_policy_conf *mpc 1788*a1e26a70SApple OSS Distributions ); 1789*a1e26a70SApple OSS Distributions /** 1790*a1e26a70SApple OSS Distributions * @brief Policy initialization event 1791*a1e26a70SApple OSS Distributions * @param mpc MAC policy configuration 1792*a1e26a70SApple OSS Distributions * @see mac_policy_register 1793*a1e26a70SApple OSS Distributions * @see mpo_policy_initbsd_t 1794*a1e26a70SApple OSS Distributions * 1795*a1e26a70SApple OSS Distributions * This is the MAC Framework policy initialization event. This entry 1796*a1e26a70SApple OSS Distributions * point is called during mac_policy_register, when the policy module 1797*a1e26a70SApple OSS Distributions * is first registered with the MAC Framework. This is often done very 1798*a1e26a70SApple OSS Distributions * early in the boot process, after the kernel Mach subsystem has been 1799*a1e26a70SApple OSS Distributions * initialized, but prior to the BSD subsystem being initialized. 1800*a1e26a70SApple OSS Distributions * Since the kernel BSD services are not yet available, it is possible 1801*a1e26a70SApple OSS Distributions * that some initialization must occur later, possibly in the 1802*a1e26a70SApple OSS Distributions * mpo_policy_initbsd_t policy entry point, such as registering BSD system 1803*a1e26a70SApple OSS Distributions * controls (sysctls). Policy modules loaded at boot time will be 1804*a1e26a70SApple OSS Distributions * registered and initialized before labeled Mach objects are created. 1805*a1e26a70SApple OSS Distributions * 1806*a1e26a70SApple OSS Distributions * @warning During this call, the mac policy list mutex is held, so 1807*a1e26a70SApple OSS Distributions * sleep operations cannot be performed, and calls out to other kernel 1808*a1e26a70SApple OSS Distributions * subsystems must be made with caution. 1809*a1e26a70SApple OSS Distributions */ 1810*a1e26a70SApple OSS Distributions typedef void mpo_policy_init_t( 1811*a1e26a70SApple OSS Distributions struct mac_policy_conf *mpc 1812*a1e26a70SApple OSS Distributions ); 1813*a1e26a70SApple OSS Distributions /** 1814*a1e26a70SApple OSS Distributions * @brief Policy BSD initialization event 1815*a1e26a70SApple OSS Distributions * @param mpc MAC policy configuration 1816*a1e26a70SApple OSS Distributions * @see mpo_policy_init_t 1817*a1e26a70SApple OSS Distributions * 1818*a1e26a70SApple OSS Distributions * This entry point is called after the kernel BSD subsystem has been 1819*a1e26a70SApple OSS Distributions * initialized. By this point, the module should already be loaded, 1820*a1e26a70SApple OSS Distributions * registered, and initialized. Since policy modules are initialized 1821*a1e26a70SApple OSS Distributions * before kernel BSD services are available, this second initialization 1822*a1e26a70SApple OSS Distributions * phase is necessary. At this point, BSD services (memory management, 1823*a1e26a70SApple OSS Distributions * synchronization primitives, vfs, etc.) are available, but the first 1824*a1e26a70SApple OSS Distributions * process has not yet been created. Mach-related objects and tasks 1825*a1e26a70SApple OSS Distributions * will already be fully initialized and may be in use--policies requiring 1826*a1e26a70SApple OSS Distributions * ubiquitous labeling may also want to implement mpo_policy_init_t. 1827*a1e26a70SApple OSS Distributions * 1828*a1e26a70SApple OSS Distributions * @warning During this call, the mac policy list mutex is held, so 1829*a1e26a70SApple OSS Distributions * sleep operations cannot be performed, and calls out to other kernel 1830*a1e26a70SApple OSS Distributions * subsystems must be made with caution. 1831*a1e26a70SApple OSS Distributions */ 1832*a1e26a70SApple OSS Distributions typedef void mpo_policy_initbsd_t( 1833*a1e26a70SApple OSS Distributions struct mac_policy_conf *mpc 1834*a1e26a70SApple OSS Distributions ); 1835*a1e26a70SApple OSS Distributions /** 1836*a1e26a70SApple OSS Distributions * @brief Policy extension service 1837*a1e26a70SApple OSS Distributions * @param p Calling process 1838*a1e26a70SApple OSS Distributions * @param call Policy-specific syscall number 1839*a1e26a70SApple OSS Distributions * @param arg Pointer to syscall arguments 1840*a1e26a70SApple OSS Distributions * 1841*a1e26a70SApple OSS Distributions * This entry point provides a policy-multiplexed system call so that 1842*a1e26a70SApple OSS Distributions * policies may provide additional services to user processes without 1843*a1e26a70SApple OSS Distributions * registering specific system calls. The policy name provided during 1844*a1e26a70SApple OSS Distributions * registration is used to demux calls from userland, and the arguments 1845*a1e26a70SApple OSS Distributions * will be forwarded to this entry point. When implementing new 1846*a1e26a70SApple OSS Distributions * services, security modules should be sure to invoke appropriate 1847*a1e26a70SApple OSS Distributions * access control checks from the MAC framework as needed. For 1848*a1e26a70SApple OSS Distributions * example, if a policy implements an augmented signal functionality, 1849*a1e26a70SApple OSS Distributions * it should call the necessary signal access control checks to invoke 1850*a1e26a70SApple OSS Distributions * the MAC framework and other registered policies. 1851*a1e26a70SApple OSS Distributions * 1852*a1e26a70SApple OSS Distributions * @warning Since the format and contents of the policy-specific 1853*a1e26a70SApple OSS Distributions * arguments are unknown to the MAC Framework, modules must perform the 1854*a1e26a70SApple OSS Distributions * required copyin() of the syscall data on their own. No policy 1855*a1e26a70SApple OSS Distributions * mediation is performed, so policies must perform any necessary 1856*a1e26a70SApple OSS Distributions * access control checks themselves. If multiple policies are loaded, 1857*a1e26a70SApple OSS Distributions * they will currently be unable to mediate calls to other policies. 1858*a1e26a70SApple OSS Distributions * 1859*a1e26a70SApple OSS Distributions * @return In the event of an error, an appropriate value for errno 1860*a1e26a70SApple OSS Distributions * should be returned, otherwise return 0 upon success. 1861*a1e26a70SApple OSS Distributions */ 1862*a1e26a70SApple OSS Distributions typedef int mpo_policy_syscall_t( 1863*a1e26a70SApple OSS Distributions struct proc *p, 1864*a1e26a70SApple OSS Distributions int call, 1865*a1e26a70SApple OSS Distributions user_addr_t arg 1866*a1e26a70SApple OSS Distributions ); 1867*a1e26a70SApple OSS Distributions /** 1868*a1e26a70SApple OSS Distributions * @brief Access control check for POSIX semaphore create 1869*a1e26a70SApple OSS Distributions * @param cred Subject credential 1870*a1e26a70SApple OSS Distributions * @param name String name of the semaphore 1871*a1e26a70SApple OSS Distributions * 1872*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can create 1873*a1e26a70SApple OSS Distributions * a POSIX semaphore specified by name. 1874*a1e26a70SApple OSS Distributions * 1875*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1876*a1e26a70SApple OSS Distributions * errno should be returned. 1877*a1e26a70SApple OSS Distributions */ 1878*a1e26a70SApple OSS Distributions typedef int mpo_posixsem_check_create_t( 1879*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1880*a1e26a70SApple OSS Distributions const char *name 1881*a1e26a70SApple OSS Distributions ); 1882*a1e26a70SApple OSS Distributions /** 1883*a1e26a70SApple OSS Distributions * @brief Access control check for POSIX semaphore open 1884*a1e26a70SApple OSS Distributions * @param cred Subject credential 1885*a1e26a70SApple OSS Distributions * @param ps Pointer to semaphore information structure 1886*a1e26a70SApple OSS Distributions * @param semlabel Label associated with the semaphore 1887*a1e26a70SApple OSS Distributions * 1888*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can open 1889*a1e26a70SApple OSS Distributions * the named POSIX semaphore with label semlabel. 1890*a1e26a70SApple OSS Distributions * 1891*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1892*a1e26a70SApple OSS Distributions * errno should be returned. 1893*a1e26a70SApple OSS Distributions */ 1894*a1e26a70SApple OSS Distributions typedef int mpo_posixsem_check_open_t( 1895*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1896*a1e26a70SApple OSS Distributions struct pseminfo *ps, 1897*a1e26a70SApple OSS Distributions struct label *semlabel 1898*a1e26a70SApple OSS Distributions ); 1899*a1e26a70SApple OSS Distributions /** 1900*a1e26a70SApple OSS Distributions * @brief Access control check for POSIX semaphore post 1901*a1e26a70SApple OSS Distributions * @param cred Subject credential 1902*a1e26a70SApple OSS Distributions * @param ps Pointer to semaphore information structure 1903*a1e26a70SApple OSS Distributions * @param semlabel Label associated with the semaphore 1904*a1e26a70SApple OSS Distributions * 1905*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can unlock 1906*a1e26a70SApple OSS Distributions * the named POSIX semaphore with label semlabel. 1907*a1e26a70SApple OSS Distributions * 1908*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1909*a1e26a70SApple OSS Distributions * errno should be returned. 1910*a1e26a70SApple OSS Distributions */ 1911*a1e26a70SApple OSS Distributions typedef int mpo_posixsem_check_post_t( 1912*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1913*a1e26a70SApple OSS Distributions struct pseminfo *ps, 1914*a1e26a70SApple OSS Distributions struct label *semlabel 1915*a1e26a70SApple OSS Distributions ); 1916*a1e26a70SApple OSS Distributions /** 1917*a1e26a70SApple OSS Distributions * @brief Access control check for POSIX semaphore unlink 1918*a1e26a70SApple OSS Distributions * @param cred Subject credential 1919*a1e26a70SApple OSS Distributions * @param ps Pointer to semaphore information structure 1920*a1e26a70SApple OSS Distributions * @param semlabel Label associated with the semaphore 1921*a1e26a70SApple OSS Distributions * @param name String name of the semaphore 1922*a1e26a70SApple OSS Distributions * 1923*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can remove 1924*a1e26a70SApple OSS Distributions * the named POSIX semaphore with label semlabel. 1925*a1e26a70SApple OSS Distributions * 1926*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1927*a1e26a70SApple OSS Distributions * errno should be returned. 1928*a1e26a70SApple OSS Distributions */ 1929*a1e26a70SApple OSS Distributions typedef int mpo_posixsem_check_unlink_t( 1930*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1931*a1e26a70SApple OSS Distributions struct pseminfo *ps, 1932*a1e26a70SApple OSS Distributions struct label *semlabel, 1933*a1e26a70SApple OSS Distributions const char *name 1934*a1e26a70SApple OSS Distributions ); 1935*a1e26a70SApple OSS Distributions /** 1936*a1e26a70SApple OSS Distributions * @brief Access control check for POSIX semaphore wait 1937*a1e26a70SApple OSS Distributions * @param cred Subject credential 1938*a1e26a70SApple OSS Distributions * @param ps Pointer to semaphore information structure 1939*a1e26a70SApple OSS Distributions * @param semlabel Label associated with the semaphore 1940*a1e26a70SApple OSS Distributions * 1941*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can lock 1942*a1e26a70SApple OSS Distributions * the named POSIX semaphore with label semlabel. 1943*a1e26a70SApple OSS Distributions * 1944*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 1945*a1e26a70SApple OSS Distributions * errno should be returned. 1946*a1e26a70SApple OSS Distributions */ 1947*a1e26a70SApple OSS Distributions typedef int mpo_posixsem_check_wait_t( 1948*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1949*a1e26a70SApple OSS Distributions struct pseminfo *ps, 1950*a1e26a70SApple OSS Distributions struct label *semlabel 1951*a1e26a70SApple OSS Distributions ); 1952*a1e26a70SApple OSS Distributions /** 1953*a1e26a70SApple OSS Distributions * @brief Create a POSIX semaphore label 1954*a1e26a70SApple OSS Distributions * @param cred Subject credential 1955*a1e26a70SApple OSS Distributions * @param ps Pointer to semaphore information structure 1956*a1e26a70SApple OSS Distributions * @param semlabel Label to associate with the new semaphore 1957*a1e26a70SApple OSS Distributions * @param name String name of the semaphore 1958*a1e26a70SApple OSS Distributions * 1959*a1e26a70SApple OSS Distributions * Label a new POSIX semaphore. The label was previously 1960*a1e26a70SApple OSS Distributions * initialized and associated with the semaphore. At this time, an 1961*a1e26a70SApple OSS Distributions * appropriate initial label value should be assigned to the object and 1962*a1e26a70SApple OSS Distributions * stored in semalabel. 1963*a1e26a70SApple OSS Distributions */ 1964*a1e26a70SApple OSS Distributions typedef void mpo_posixsem_label_associate_t( 1965*a1e26a70SApple OSS Distributions kauth_cred_t cred, 1966*a1e26a70SApple OSS Distributions struct pseminfo *ps, 1967*a1e26a70SApple OSS Distributions struct label *semlabel, 1968*a1e26a70SApple OSS Distributions const char *name 1969*a1e26a70SApple OSS Distributions ); 1970*a1e26a70SApple OSS Distributions /** 1971*a1e26a70SApple OSS Distributions * @brief Destroy POSIX semaphore label 1972*a1e26a70SApple OSS Distributions * @param label The label to be destroyed 1973*a1e26a70SApple OSS Distributions * 1974*a1e26a70SApple OSS Distributions * Destroy a POSIX semaphore label. Since the object is 1975*a1e26a70SApple OSS Distributions * going out of scope, policy modules should free any internal storage 1976*a1e26a70SApple OSS Distributions * associated with the label so that it may be destroyed. 1977*a1e26a70SApple OSS Distributions */ 1978*a1e26a70SApple OSS Distributions typedef void mpo_posixsem_label_destroy_t( 1979*a1e26a70SApple OSS Distributions struct label *label 1980*a1e26a70SApple OSS Distributions ); 1981*a1e26a70SApple OSS Distributions /** 1982*a1e26a70SApple OSS Distributions * @brief Initialize POSIX semaphore label 1983*a1e26a70SApple OSS Distributions * @param label New label to initialize 1984*a1e26a70SApple OSS Distributions * 1985*a1e26a70SApple OSS Distributions * Initialize the label for a newly instantiated POSIX semaphore. Sleeping 1986*a1e26a70SApple OSS Distributions * is permitted. 1987*a1e26a70SApple OSS Distributions */ 1988*a1e26a70SApple OSS Distributions typedef void mpo_posixsem_label_init_t( 1989*a1e26a70SApple OSS Distributions struct label *label 1990*a1e26a70SApple OSS Distributions ); 1991*a1e26a70SApple OSS Distributions /** 1992*a1e26a70SApple OSS Distributions * @brief Access control check for POSIX shared memory region create 1993*a1e26a70SApple OSS Distributions * @param cred Subject credential 1994*a1e26a70SApple OSS Distributions * @param name String name of the shared memory region 1995*a1e26a70SApple OSS Distributions * 1996*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can create 1997*a1e26a70SApple OSS Distributions * the POSIX shared memory region referenced by name. 1998*a1e26a70SApple OSS Distributions * 1999*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2000*a1e26a70SApple OSS Distributions * errno should be returned. 2001*a1e26a70SApple OSS Distributions */ 2002*a1e26a70SApple OSS Distributions typedef int mpo_posixshm_check_create_t( 2003*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2004*a1e26a70SApple OSS Distributions const char *name 2005*a1e26a70SApple OSS Distributions ); 2006*a1e26a70SApple OSS Distributions /** 2007*a1e26a70SApple OSS Distributions * @brief Access control check for mapping POSIX shared memory 2008*a1e26a70SApple OSS Distributions * @param cred Subject credential 2009*a1e26a70SApple OSS Distributions * @param ps Pointer to shared memory information structure 2010*a1e26a70SApple OSS Distributions * @param shmlabel Label associated with the shared memory region 2011*a1e26a70SApple OSS Distributions * @param prot mmap protections; see mmap(2) 2012*a1e26a70SApple OSS Distributions * @param flags shmat flags; see shmat(2) 2013*a1e26a70SApple OSS Distributions * 2014*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can map 2015*a1e26a70SApple OSS Distributions * the POSIX shared memory segment associated with shmlabel. 2016*a1e26a70SApple OSS Distributions * 2017*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2018*a1e26a70SApple OSS Distributions * errno should be returned. 2019*a1e26a70SApple OSS Distributions */ 2020*a1e26a70SApple OSS Distributions typedef int mpo_posixshm_check_mmap_t( 2021*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2022*a1e26a70SApple OSS Distributions struct pshminfo *ps, 2023*a1e26a70SApple OSS Distributions struct label *shmlabel, 2024*a1e26a70SApple OSS Distributions int prot, 2025*a1e26a70SApple OSS Distributions int flags 2026*a1e26a70SApple OSS Distributions ); 2027*a1e26a70SApple OSS Distributions /** 2028*a1e26a70SApple OSS Distributions * @brief Access control check for POSIX shared memory region open 2029*a1e26a70SApple OSS Distributions * @param cred Subject credential 2030*a1e26a70SApple OSS Distributions * @param ps Pointer to shared memory information structure 2031*a1e26a70SApple OSS Distributions * @param shmlabel Label associated with the shared memory region 2032*a1e26a70SApple OSS Distributions * @param fflags shm_open(2) open flags ('fflags' encoded) 2033*a1e26a70SApple OSS Distributions * 2034*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can open 2035*a1e26a70SApple OSS Distributions * the POSIX shared memory region. 2036*a1e26a70SApple OSS Distributions * 2037*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2038*a1e26a70SApple OSS Distributions * errno should be returned. 2039*a1e26a70SApple OSS Distributions */ 2040*a1e26a70SApple OSS Distributions typedef int mpo_posixshm_check_open_t( 2041*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2042*a1e26a70SApple OSS Distributions struct pshminfo *ps, 2043*a1e26a70SApple OSS Distributions struct label *shmlabel, 2044*a1e26a70SApple OSS Distributions int fflags 2045*a1e26a70SApple OSS Distributions ); 2046*a1e26a70SApple OSS Distributions /** 2047*a1e26a70SApple OSS Distributions * @brief Access control check for POSIX shared memory stat 2048*a1e26a70SApple OSS Distributions * @param cred Subject credential 2049*a1e26a70SApple OSS Distributions * @param ps Pointer to shared memory information structure 2050*a1e26a70SApple OSS Distributions * @param shmlabel Label associated with the shared memory region 2051*a1e26a70SApple OSS Distributions * 2052*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can obtain 2053*a1e26a70SApple OSS Distributions * status for the POSIX shared memory segment associated with shmlabel. 2054*a1e26a70SApple OSS Distributions * 2055*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2056*a1e26a70SApple OSS Distributions * errno should be returned. 2057*a1e26a70SApple OSS Distributions */ 2058*a1e26a70SApple OSS Distributions typedef int mpo_posixshm_check_stat_t( 2059*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2060*a1e26a70SApple OSS Distributions struct pshminfo *ps, 2061*a1e26a70SApple OSS Distributions struct label *shmlabel 2062*a1e26a70SApple OSS Distributions ); 2063*a1e26a70SApple OSS Distributions /** 2064*a1e26a70SApple OSS Distributions * @brief Access control check for POSIX shared memory truncate 2065*a1e26a70SApple OSS Distributions * @param cred Subject credential 2066*a1e26a70SApple OSS Distributions * @param ps Pointer to shared memory information structure 2067*a1e26a70SApple OSS Distributions * @param shmlabel Label associated with the shared memory region 2068*a1e26a70SApple OSS Distributions * @param len Length to truncate or extend shared memory segment 2069*a1e26a70SApple OSS Distributions * 2070*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can truncate 2071*a1e26a70SApple OSS Distributions * or extend (to len) the POSIX shared memory segment associated with shmlabel. 2072*a1e26a70SApple OSS Distributions * 2073*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2074*a1e26a70SApple OSS Distributions * errno should be returned. 2075*a1e26a70SApple OSS Distributions */ 2076*a1e26a70SApple OSS Distributions typedef int mpo_posixshm_check_truncate_t( 2077*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2078*a1e26a70SApple OSS Distributions struct pshminfo *ps, 2079*a1e26a70SApple OSS Distributions struct label *shmlabel, 2080*a1e26a70SApple OSS Distributions off_t len 2081*a1e26a70SApple OSS Distributions ); 2082*a1e26a70SApple OSS Distributions /** 2083*a1e26a70SApple OSS Distributions * @brief Access control check for POSIX shared memory unlink 2084*a1e26a70SApple OSS Distributions * @param cred Subject credential 2085*a1e26a70SApple OSS Distributions * @param ps Pointer to shared memory information structure 2086*a1e26a70SApple OSS Distributions * @param shmlabel Label associated with the shared memory region 2087*a1e26a70SApple OSS Distributions * @param name String name of the shared memory region 2088*a1e26a70SApple OSS Distributions * 2089*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can delete 2090*a1e26a70SApple OSS Distributions * the POSIX shared memory segment associated with shmlabel. 2091*a1e26a70SApple OSS Distributions * 2092*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2093*a1e26a70SApple OSS Distributions * errno should be returned. 2094*a1e26a70SApple OSS Distributions */ 2095*a1e26a70SApple OSS Distributions typedef int mpo_posixshm_check_unlink_t( 2096*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2097*a1e26a70SApple OSS Distributions struct pshminfo *ps, 2098*a1e26a70SApple OSS Distributions struct label *shmlabel, 2099*a1e26a70SApple OSS Distributions const char *name 2100*a1e26a70SApple OSS Distributions ); 2101*a1e26a70SApple OSS Distributions /** 2102*a1e26a70SApple OSS Distributions * @brief Create a POSIX shared memory region label 2103*a1e26a70SApple OSS Distributions * @param cred Subject credential 2104*a1e26a70SApple OSS Distributions * @param ps Pointer to shared memory information structure 2105*a1e26a70SApple OSS Distributions * @param shmlabel Label to associate with the new shared memory region 2106*a1e26a70SApple OSS Distributions * @param name String name of the shared memory region 2107*a1e26a70SApple OSS Distributions * 2108*a1e26a70SApple OSS Distributions * Label a new POSIX shared memory region. The label was previously 2109*a1e26a70SApple OSS Distributions * initialized and associated with the shared memory region. At this 2110*a1e26a70SApple OSS Distributions * time, an appropriate initial label value should be assigned to the 2111*a1e26a70SApple OSS Distributions * object and stored in shmlabel. 2112*a1e26a70SApple OSS Distributions */ 2113*a1e26a70SApple OSS Distributions typedef void mpo_posixshm_label_associate_t( 2114*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2115*a1e26a70SApple OSS Distributions struct pshminfo *ps, 2116*a1e26a70SApple OSS Distributions struct label *shmlabel, 2117*a1e26a70SApple OSS Distributions const char *name 2118*a1e26a70SApple OSS Distributions ); 2119*a1e26a70SApple OSS Distributions /** 2120*a1e26a70SApple OSS Distributions * @brief Destroy POSIX shared memory label 2121*a1e26a70SApple OSS Distributions * @param label The label to be destroyed 2122*a1e26a70SApple OSS Distributions * 2123*a1e26a70SApple OSS Distributions * Destroy a POSIX shared memory region label. Since the 2124*a1e26a70SApple OSS Distributions * object is going out of scope, policy modules should free any 2125*a1e26a70SApple OSS Distributions * internal storage associated with the label so that it may be 2126*a1e26a70SApple OSS Distributions * destroyed. 2127*a1e26a70SApple OSS Distributions */ 2128*a1e26a70SApple OSS Distributions typedef void mpo_posixshm_label_destroy_t( 2129*a1e26a70SApple OSS Distributions struct label *label 2130*a1e26a70SApple OSS Distributions ); 2131*a1e26a70SApple OSS Distributions /** 2132*a1e26a70SApple OSS Distributions * @brief Initialize POSIX Shared Memory region label 2133*a1e26a70SApple OSS Distributions * @param label New label to initialize 2134*a1e26a70SApple OSS Distributions * 2135*a1e26a70SApple OSS Distributions * Initialize the label for newly a instantiated POSIX Shared Memory 2136*a1e26a70SApple OSS Distributions * region. Sleeping is permitted. 2137*a1e26a70SApple OSS Distributions */ 2138*a1e26a70SApple OSS Distributions typedef void mpo_posixshm_label_init_t( 2139*a1e26a70SApple OSS Distributions struct label *label 2140*a1e26a70SApple OSS Distributions ); 2141*a1e26a70SApple OSS Distributions /** 2142*a1e26a70SApple OSS Distributions * @brief Access control check for privileged operations 2143*a1e26a70SApple OSS Distributions * @param cred Subject credential 2144*a1e26a70SApple OSS Distributions * @param priv Requested privilege (see sys/priv.h) 2145*a1e26a70SApple OSS Distributions * 2146*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 2147*a1e26a70SApple OSS Distributions * a privileged operation. Privileged operations are allowed if the cred 2148*a1e26a70SApple OSS Distributions * is the superuser or any policy returns zero for mpo_priv_grant, unless 2149*a1e26a70SApple OSS Distributions * any policy returns nonzero for mpo_priv_check. 2150*a1e26a70SApple OSS Distributions * 2151*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise EPERM should be returned. 2152*a1e26a70SApple OSS Distributions */ 2153*a1e26a70SApple OSS Distributions typedef int mpo_priv_check_t( 2154*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2155*a1e26a70SApple OSS Distributions int priv 2156*a1e26a70SApple OSS Distributions ); 2157*a1e26a70SApple OSS Distributions /** 2158*a1e26a70SApple OSS Distributions * @brief Grant regular users the ability to perform privileged operations 2159*a1e26a70SApple OSS Distributions * @param cred Subject credential 2160*a1e26a70SApple OSS Distributions * @param priv Requested privilege (see sys/priv.h) 2161*a1e26a70SApple OSS Distributions * 2162*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 2163*a1e26a70SApple OSS Distributions * allowed to perform a privileged operation that in the absense of any 2164*a1e26a70SApple OSS Distributions * MAC policy it would not be able to perform. Privileged operations are 2165*a1e26a70SApple OSS Distributions * allowed if the cred is the superuser or any policy returns zero for 2166*a1e26a70SApple OSS Distributions * mpo_priv_grant, unless any policy returns nonzero for mpo_priv_check. 2167*a1e26a70SApple OSS Distributions * 2168*a1e26a70SApple OSS Distributions * Unlike other MAC hooks which can only reduce the privilege of a 2169*a1e26a70SApple OSS Distributions * credential, this hook raises the privilege of a credential when it 2170*a1e26a70SApple OSS Distributions * returns 0. Extreme care must be taken when implementing this hook to 2171*a1e26a70SApple OSS Distributions * avoid undermining the security of the system. 2172*a1e26a70SApple OSS Distributions * 2173*a1e26a70SApple OSS Distributions * @return Return 0 if additional privilege is granted, otherwise EPERM 2174*a1e26a70SApple OSS Distributions * should be returned. 2175*a1e26a70SApple OSS Distributions */ 2176*a1e26a70SApple OSS Distributions typedef int mpo_priv_grant_t( 2177*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2178*a1e26a70SApple OSS Distributions int priv 2179*a1e26a70SApple OSS Distributions ); 2180*a1e26a70SApple OSS Distributions /** 2181*a1e26a70SApple OSS Distributions * @brief Access control over process core dumps 2182*a1e26a70SApple OSS Distributions * @param proc Subject process 2183*a1e26a70SApple OSS Distributions * 2184*a1e26a70SApple OSS Distributions * Determine whether a core dump may be written to disk for the subject 2185*a1e26a70SApple OSS Distributions * identified. 2186*a1e26a70SApple OSS Distributions * 2187*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2188*a1e26a70SApple OSS Distributions * errno should be returned. 2189*a1e26a70SApple OSS Distributions */ 2190*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_dump_core_t( 2191*a1e26a70SApple OSS Distributions struct proc *proc 2192*a1e26a70SApple OSS Distributions ); 2193*a1e26a70SApple OSS Distributions /** 2194*a1e26a70SApple OSS Distributions * @brief Access control over remote thread creation 2195*a1e26a70SApple OSS Distributions * @param cred Subject credential 2196*a1e26a70SApple OSS Distributions * @param proc Object process 2197*a1e26a70SApple OSS Distributions * @param flavor Flavor of thread state passed in new_state, or -1 2198*a1e26a70SApple OSS Distributions * @param new_state Thread state to be set on the created thread, or NULL 2199*a1e26a70SApple OSS Distributions * @param new_state_count Size of thread state, in natural_t units, or 0 2200*a1e26a70SApple OSS Distributions * 2201*a1e26a70SApple OSS Distributions * Determine whether the subject can create a thread in the object process 2202*a1e26a70SApple OSS Distributions * by calling the thread_create or thread_create_running MIG routines on 2203*a1e26a70SApple OSS Distributions * another process' task port. For thread_create_running, the flavor, 2204*a1e26a70SApple OSS Distributions * new_state and new_state_count arguments are passed here before they are 2205*a1e26a70SApple OSS Distributions * converted and checked by machine-dependent code. 2206*a1e26a70SApple OSS Distributions * 2207*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2208*a1e26a70SApple OSS Distributions * errno should be returned. 2209*a1e26a70SApple OSS Distributions */ 2210*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_remote_thread_create_t( 2211*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2212*a1e26a70SApple OSS Distributions struct proc *proc, 2213*a1e26a70SApple OSS Distributions int flavor, 2214*a1e26a70SApple OSS Distributions thread_state_t new_state, 2215*a1e26a70SApple OSS Distributions mach_msg_type_number_t new_state_count 2216*a1e26a70SApple OSS Distributions ); 2217*a1e26a70SApple OSS Distributions /** 2218*a1e26a70SApple OSS Distributions * @brief Access control check for debugging process 2219*a1e26a70SApple OSS Distributions * @param cred Subject credential 2220*a1e26a70SApple OSS Distributions * @param pident Object unique process identifier 2221*a1e26a70SApple OSS Distributions * 2222*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can debug 2223*a1e26a70SApple OSS Distributions * the passed process. This call may be made in a number of situations, 2224*a1e26a70SApple OSS Distributions * including use of the ptrace(2) and ktrace(2) APIs, as well as for some 2225*a1e26a70SApple OSS Distributions * types of procfs operations. 2226*a1e26a70SApple OSS Distributions * 2227*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2228*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch, 2229*a1e26a70SApple OSS Distributions * EPERM for lack of privilege, or ESRCH to hide visibility of the target. 2230*a1e26a70SApple OSS Distributions */ 2231*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_debug_t( 2232*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2233*a1e26a70SApple OSS Distributions struct proc_ident *pident 2234*a1e26a70SApple OSS Distributions ); 2235*a1e26a70SApple OSS Distributions /** 2236*a1e26a70SApple OSS Distributions * @brief Access control over fork 2237*a1e26a70SApple OSS Distributions * @param cred Subject credential 2238*a1e26a70SApple OSS Distributions * @param proc Subject process trying to fork 2239*a1e26a70SApple OSS Distributions * 2240*a1e26a70SApple OSS Distributions * Determine whether the subject identified is allowed to fork. 2241*a1e26a70SApple OSS Distributions * 2242*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2243*a1e26a70SApple OSS Distributions * errno should be returned. 2244*a1e26a70SApple OSS Distributions */ 2245*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_fork_t( 2246*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2247*a1e26a70SApple OSS Distributions struct proc *proc 2248*a1e26a70SApple OSS Distributions ); 2249*a1e26a70SApple OSS Distributions /** 2250*a1e26a70SApple OSS Distributions * @brief Access control check for setting host special ports. 2251*a1e26a70SApple OSS Distributions * @param cred Subject credential 2252*a1e26a70SApple OSS Distributions * @param id The host special port to set 2253*a1e26a70SApple OSS Distributions * @param port The new value to set for the special port 2254*a1e26a70SApple OSS Distributions * 2255*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2256*a1e26a70SApple OSS Distributions * errno should be returned. 2257*a1e26a70SApple OSS Distributions */ 2258*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_set_host_special_port_t( 2259*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2260*a1e26a70SApple OSS Distributions int id, 2261*a1e26a70SApple OSS Distributions struct ipc_port *port 2262*a1e26a70SApple OSS Distributions ); 2263*a1e26a70SApple OSS Distributions /** 2264*a1e26a70SApple OSS Distributions * @brief Access control check for setting host exception ports. 2265*a1e26a70SApple OSS Distributions * @param cred Subject credential 2266*a1e26a70SApple OSS Distributions * @param exception Exception port to set 2267*a1e26a70SApple OSS Distributions * 2268*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2269*a1e26a70SApple OSS Distributions * errno should be returned. 2270*a1e26a70SApple OSS Distributions */ 2271*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_set_host_exception_port_t( 2272*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2273*a1e26a70SApple OSS Distributions unsigned int exception 2274*a1e26a70SApple OSS Distributions ); 2275*a1e26a70SApple OSS Distributions /** 2276*a1e26a70SApple OSS Distributions * @brief Access control check for getting task special ports. 2277*a1e26a70SApple OSS Distributions * @param cred Subject credential 2278*a1e26a70SApple OSS Distributions * @param pident Object unique process identifier, NULL if target is a corpse task 2279*a1e26a70SApple OSS Distributions * @param which The task special port to get 2280*a1e26a70SApple OSS Distributions * 2281*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2282*a1e26a70SApple OSS Distributions * errno should be returned. 2283*a1e26a70SApple OSS Distributions */ 2284*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_get_task_special_port_t( 2285*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2286*a1e26a70SApple OSS Distributions struct proc_ident *pident, 2287*a1e26a70SApple OSS Distributions int which 2288*a1e26a70SApple OSS Distributions ); 2289*a1e26a70SApple OSS Distributions /** 2290*a1e26a70SApple OSS Distributions * @brief Access control check for setting task special ports. 2291*a1e26a70SApple OSS Distributions * @param cred Subject credential 2292*a1e26a70SApple OSS Distributions * @param pident Object unique process identifier 2293*a1e26a70SApple OSS Distributions * @param which The task special port to set 2294*a1e26a70SApple OSS Distributions * @param port The new value to set for the special port 2295*a1e26a70SApple OSS Distributions * 2296*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2297*a1e26a70SApple OSS Distributions * errno should be returned. 2298*a1e26a70SApple OSS Distributions */ 2299*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_set_task_special_port_t( 2300*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2301*a1e26a70SApple OSS Distributions struct proc_ident *pident, 2302*a1e26a70SApple OSS Distributions int which, 2303*a1e26a70SApple OSS Distributions struct ipc_port *port 2304*a1e26a70SApple OSS Distributions ); 2305*a1e26a70SApple OSS Distributions /** 2306*a1e26a70SApple OSS Distributions * @brief Access control check for setting task exception ports for current task. 2307*a1e26a70SApple OSS Distributions * @param cred Subject credential 2308*a1e26a70SApple OSS Distributions * @param pident Object unique process identifier 2309*a1e26a70SApple OSS Distributions * @param exception Exception port to set 2310*a1e26a70SApple OSS Distributions * @param new_behavior exception_behavior_t value 2311*a1e26a70SApple OSS Distributions * 2312*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2313*a1e26a70SApple OSS Distributions * errno should be returned. 2314*a1e26a70SApple OSS Distributions */ 2315*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_set_task_exception_port_t( 2316*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2317*a1e26a70SApple OSS Distributions struct proc_ident *pident, 2318*a1e26a70SApple OSS Distributions unsigned int exception, 2319*a1e26a70SApple OSS Distributions int new_behavior 2320*a1e26a70SApple OSS Distributions ); 2321*a1e26a70SApple OSS Distributions /** 2322*a1e26a70SApple OSS Distributions * @brief Access control check for setting thread exception ports. 2323*a1e26a70SApple OSS Distributions * @param cred Subject credential 2324*a1e26a70SApple OSS Distributions * @param pident Object unique process identifier 2325*a1e26a70SApple OSS Distributions * @param exception Exception port to set 2326*a1e26a70SApple OSS Distributions * @param new_behavior exception_behavior_t value 2327*a1e26a70SApple OSS Distributions * 2328*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2329*a1e26a70SApple OSS Distributions * errno should be returned. 2330*a1e26a70SApple OSS Distributions */ 2331*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_set_thread_exception_port_t( 2332*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2333*a1e26a70SApple OSS Distributions struct proc_ident *pident, 2334*a1e26a70SApple OSS Distributions unsigned int exception, 2335*a1e26a70SApple OSS Distributions int new_behavior 2336*a1e26a70SApple OSS Distributions ); 2337*a1e26a70SApple OSS Distributions /** 2338*a1e26a70SApple OSS Distributions * @brief Access control check for getting movable task/thread control port for current task. 2339*a1e26a70SApple OSS Distributions * @param cred Subject credential 2340*a1e26a70SApple OSS Distributions * 2341*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2342*a1e26a70SApple OSS Distributions * errno should be returned. 2343*a1e26a70SApple OSS Distributions */ 2344*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_get_movable_control_port_t( 2345*a1e26a70SApple OSS Distributions kauth_cred_t cred 2346*a1e26a70SApple OSS Distributions ); 2347*a1e26a70SApple OSS Distributions /** 2348*a1e26a70SApple OSS Distributions * @brief Access control check for calling task_dyld_process_info_notify_register 2349*a1e26a70SApple OSS Distributions * and task_dyld_process_info_notify_deregister. 2350*a1e26a70SApple OSS Distributions * @param cred Subject credential 2351*a1e26a70SApple OSS Distributions * 2352*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2353*a1e26a70SApple OSS Distributions * errno should be returned. 2354*a1e26a70SApple OSS Distributions */ 2355*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_dyld_process_info_notify_register_t( 2356*a1e26a70SApple OSS Distributions kauth_cred_t cred 2357*a1e26a70SApple OSS Distributions ); 2358*a1e26a70SApple OSS Distributions /** 2359*a1e26a70SApple OSS Distributions * @brief Access control over pid_suspend, pid_resume and family 2360*a1e26a70SApple OSS Distributions * @param cred Subject credential 2361*a1e26a70SApple OSS Distributions * @param proc Object process 2362*a1e26a70SApple OSS Distributions * @param sr Type of call; one of MAC_PROC_CHECK_SUSPEND, 2363*a1e26a70SApple OSS Distributions * MAC_PROC_CHECK_RESUME, MAC_PROC_CHECK_HIBERNATE, 2364*a1e26a70SApple OSS Distributions * MAC_PROC_CHECK_SHUTDOWN_SOCKETS or MAC_PROC_CHECK_PIDBIND. 2365*a1e26a70SApple OSS Distributions * 2366*a1e26a70SApple OSS Distributions * Determine whether the subject identified is allowed to call pid_suspend, 2367*a1e26a70SApple OSS Distributions * pid_resume, pid_hibernate, pid_shutdown_sockets, 2368*a1e26a70SApple OSS Distributions * process_policy(PROC_POLICY_APP_LIFECYCLE, PROC_POLICY_APPLIFE_DEVSTATUS) or 2369*a1e26a70SApple OSS Distributions * process_policy(PROC_POLICY_APP_LIFECYCLE, PROC_POLICY_APPLIFE_PIDBIND) on 2370*a1e26a70SApple OSS Distributions * the object process. 2371*a1e26a70SApple OSS Distributions * 2372*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2373*a1e26a70SApple OSS Distributions * errno should be returned. 2374*a1e26a70SApple OSS Distributions */ 2375*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_suspend_resume_t( 2376*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2377*a1e26a70SApple OSS Distributions struct proc *proc, 2378*a1e26a70SApple OSS Distributions int sr 2379*a1e26a70SApple OSS Distributions ); 2380*a1e26a70SApple OSS Distributions /** 2381*a1e26a70SApple OSS Distributions * @brief Access control check for retrieving audit information 2382*a1e26a70SApple OSS Distributions * @param cred Subject credential 2383*a1e26a70SApple OSS Distributions * 2384*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can get 2385*a1e26a70SApple OSS Distributions * audit information such as the audit user ID, the preselection mask, 2386*a1e26a70SApple OSS Distributions * the terminal ID and the audit session ID, using the getaudit() system call. 2387*a1e26a70SApple OSS Distributions * 2388*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2389*a1e26a70SApple OSS Distributions * errno should be returned. 2390*a1e26a70SApple OSS Distributions */ 2391*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_getaudit_t( 2392*a1e26a70SApple OSS Distributions kauth_cred_t cred 2393*a1e26a70SApple OSS Distributions ); 2394*a1e26a70SApple OSS Distributions /** 2395*a1e26a70SApple OSS Distributions * @brief Access control check for retrieving audit user ID 2396*a1e26a70SApple OSS Distributions * @param cred Subject credential 2397*a1e26a70SApple OSS Distributions * 2398*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can get 2399*a1e26a70SApple OSS Distributions * the user identity being used by the auditing system, using the getauid() 2400*a1e26a70SApple OSS Distributions * system call. 2401*a1e26a70SApple OSS Distributions * 2402*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2403*a1e26a70SApple OSS Distributions * errno should be returned. 2404*a1e26a70SApple OSS Distributions */ 2405*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_getauid_t( 2406*a1e26a70SApple OSS Distributions kauth_cred_t cred 2407*a1e26a70SApple OSS Distributions ); 2408*a1e26a70SApple OSS Distributions /** 2409*a1e26a70SApple OSS Distributions * @brief Access control check for retrieving ledger information 2410*a1e26a70SApple OSS Distributions * @param cred Subject credential 2411*a1e26a70SApple OSS Distributions * @param target Object process 2412*a1e26a70SApple OSS Distributions * @param op ledger operation 2413*a1e26a70SApple OSS Distributions * 2414*a1e26a70SApple OSS Distributions * Determine if ledger(2) system call is permitted. 2415*a1e26a70SApple OSS Distributions * 2416*a1e26a70SApple OSS Distributions * Information returned by this system call is similar to that returned via 2417*a1e26a70SApple OSS Distributions * process listings etc. 2418*a1e26a70SApple OSS Distributions * 2419*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2420*a1e26a70SApple OSS Distributions * errno should be returned. 2421*a1e26a70SApple OSS Distributions */ 2422*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_ledger_t( 2423*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2424*a1e26a70SApple OSS Distributions struct proc *target, 2425*a1e26a70SApple OSS Distributions int op 2426*a1e26a70SApple OSS Distributions ); 2427*a1e26a70SApple OSS Distributions /** 2428*a1e26a70SApple OSS Distributions * @brief Access control check for retrieving process information. 2429*a1e26a70SApple OSS Distributions * @param cred Subject credential 2430*a1e26a70SApple OSS Distributions * @param target Target process (may be null, may be zombie) 2431*a1e26a70SApple OSS Distributions * 2432*a1e26a70SApple OSS Distributions * Determine if a credential has permission to access process information as defined 2433*a1e26a70SApple OSS Distributions * by call number and flavor on target process 2434*a1e26a70SApple OSS Distributions * 2435*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2436*a1e26a70SApple OSS Distributions * errno should be returned. 2437*a1e26a70SApple OSS Distributions */ 2438*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_proc_info_t( 2439*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2440*a1e26a70SApple OSS Distributions struct proc *target, 2441*a1e26a70SApple OSS Distributions int callnum, 2442*a1e26a70SApple OSS Distributions int flavor 2443*a1e26a70SApple OSS Distributions ); 2444*a1e26a70SApple OSS Distributions /** 2445*a1e26a70SApple OSS Distributions * @brief Access control check for retrieving code signing information. 2446*a1e26a70SApple OSS Distributions * @param cred Subject credential 2447*a1e26a70SApple OSS Distributions * @param target Target process 2448*a1e26a70SApple OSS Distributions * @param op Code signing operation being performed 2449*a1e26a70SApple OSS Distributions * 2450*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 2451*a1e26a70SApple OSS Distributions * allowed to get code signing information about the target process. 2452*a1e26a70SApple OSS Distributions * 2453*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2454*a1e26a70SApple OSS Distributions * errno should be returned. 2455*a1e26a70SApple OSS Distributions */ 2456*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_get_cs_info_t( 2457*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2458*a1e26a70SApple OSS Distributions struct proc *target, 2459*a1e26a70SApple OSS Distributions unsigned int op 2460*a1e26a70SApple OSS Distributions ); 2461*a1e26a70SApple OSS Distributions /** 2462*a1e26a70SApple OSS Distributions * @brief Access control check for setting code signing information. 2463*a1e26a70SApple OSS Distributions * @param cred Subject credential 2464*a1e26a70SApple OSS Distributions * @param target Target process 2465*a1e26a70SApple OSS Distributions * @param op Code signing operation being performed. 2466*a1e26a70SApple OSS Distributions * 2467*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 2468*a1e26a70SApple OSS Distributions * allowed to set code signing information about the target process. 2469*a1e26a70SApple OSS Distributions * 2470*a1e26a70SApple OSS Distributions * @return Return 0 if permission is granted, otherwise an appropriate 2471*a1e26a70SApple OSS Distributions * value of errno should be returned. 2472*a1e26a70SApple OSS Distributions */ 2473*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_set_cs_info_t( 2474*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2475*a1e26a70SApple OSS Distributions struct proc *target, 2476*a1e26a70SApple OSS Distributions unsigned int op 2477*a1e26a70SApple OSS Distributions ); 2478*a1e26a70SApple OSS Distributions /** 2479*a1e26a70SApple OSS Distributions * @brief Access control check for mmap MAP_ANON 2480*a1e26a70SApple OSS Distributions * @param proc User process requesting the memory 2481*a1e26a70SApple OSS Distributions * @param cred Subject credential 2482*a1e26a70SApple OSS Distributions * @param u_addr Start address of the memory range 2483*a1e26a70SApple OSS Distributions * @param u_size Length address of the memory range 2484*a1e26a70SApple OSS Distributions * @param prot mmap protections; see mmap(2) 2485*a1e26a70SApple OSS Distributions * @param flags Type of mapped object; see mmap(2) 2486*a1e26a70SApple OSS Distributions * @param maxprot Maximum rights 2487*a1e26a70SApple OSS Distributions * 2488*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 2489*a1e26a70SApple OSS Distributions * allowed to obtain anonymous memory using the specified flags and 2490*a1e26a70SApple OSS Distributions * protections on the new mapping. MAP_ANON will always be present in the 2491*a1e26a70SApple OSS Distributions * flags. Certain combinations of flags with a non-NULL addr may 2492*a1e26a70SApple OSS Distributions * cause a mapping to be rejected before this hook is called. The maxprot field 2493*a1e26a70SApple OSS Distributions * holds the maximum permissions on the new mapping, a combination of 2494*a1e26a70SApple OSS Distributions * VM_PROT_READ, VM_PROT_WRITE and VM_PROT_EXECUTE. To avoid overriding prior 2495*a1e26a70SApple OSS Distributions * access control checks, a policy should only remove flags from maxprot. 2496*a1e26a70SApple OSS Distributions * 2497*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2498*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EPERM for lack of privilege. 2499*a1e26a70SApple OSS Distributions */ 2500*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_map_anon_t( 2501*a1e26a70SApple OSS Distributions struct proc *proc, 2502*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2503*a1e26a70SApple OSS Distributions user_addr_t u_addr, 2504*a1e26a70SApple OSS Distributions user_size_t u_size, 2505*a1e26a70SApple OSS Distributions int prot, 2506*a1e26a70SApple OSS Distributions int flags, 2507*a1e26a70SApple OSS Distributions int *maxprot 2508*a1e26a70SApple OSS Distributions ); 2509*a1e26a70SApple OSS Distributions /** 2510*a1e26a70SApple OSS Distributions * @brief Access control check for memorystatus_control(2) 2511*a1e26a70SApple OSS Distributions * @param cred Subject credential 2512*a1e26a70SApple OSS Distributions * @param command Memory status control command 2513*a1e26a70SApple OSS Distributions * @param pid Target process id, or 0 2514*a1e26a70SApple OSS Distributions * 2515*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should 2516*a1e26a70SApple OSS Distributions * be allowed to issue the specified memorystatus control command. 2517*a1e26a70SApple OSS Distributions * 2518*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2519*a1e26a70SApple OSS Distributions * errno should be returned. 2520*a1e26a70SApple OSS Distributions */ 2521*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_memorystatus_control_t( 2522*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2523*a1e26a70SApple OSS Distributions int32_t command, 2524*a1e26a70SApple OSS Distributions pid_t pid 2525*a1e26a70SApple OSS Distributions ); 2526*a1e26a70SApple OSS Distributions /** 2527*a1e26a70SApple OSS Distributions * @brief Access control check for setting memory protections 2528*a1e26a70SApple OSS Distributions * @param cred Subject credential 2529*a1e26a70SApple OSS Distributions * @param proc User process requesting the change 2530*a1e26a70SApple OSS Distributions * @param addr Start address of the memory range 2531*a1e26a70SApple OSS Distributions * @param size Length address of the memory range 2532*a1e26a70SApple OSS Distributions * @param prot Memory protections, see mmap(2) 2533*a1e26a70SApple OSS Distributions * 2534*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should 2535*a1e26a70SApple OSS Distributions * be allowed to set the specified memory protections on memory mapped 2536*a1e26a70SApple OSS Distributions * in the process proc. 2537*a1e26a70SApple OSS Distributions * 2538*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2539*a1e26a70SApple OSS Distributions * errno should be returned. 2540*a1e26a70SApple OSS Distributions */ 2541*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_mprotect_t( 2542*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2543*a1e26a70SApple OSS Distributions struct proc *proc, 2544*a1e26a70SApple OSS Distributions user_addr_t addr, 2545*a1e26a70SApple OSS Distributions user_size_t size, 2546*a1e26a70SApple OSS Distributions int prot 2547*a1e26a70SApple OSS Distributions ); 2548*a1e26a70SApple OSS Distributions /** 2549*a1e26a70SApple OSS Distributions * @brief Access control check for changing scheduling parameters 2550*a1e26a70SApple OSS Distributions * @param cred Subject credential 2551*a1e26a70SApple OSS Distributions * @param proc Object process 2552*a1e26a70SApple OSS Distributions * 2553*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can change 2554*a1e26a70SApple OSS Distributions * the scheduling parameters of the passed process. 2555*a1e26a70SApple OSS Distributions * 2556*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2557*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch, 2558*a1e26a70SApple OSS Distributions * EPERM for lack of privilege, or ESRCH to limit visibility. 2559*a1e26a70SApple OSS Distributions */ 2560*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_sched_t( 2561*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2562*a1e26a70SApple OSS Distributions struct proc *proc 2563*a1e26a70SApple OSS Distributions ); 2564*a1e26a70SApple OSS Distributions /** 2565*a1e26a70SApple OSS Distributions * @brief Access control check for setting audit information 2566*a1e26a70SApple OSS Distributions * @param cred Subject credential 2567*a1e26a70SApple OSS Distributions * @param ai Audit information 2568*a1e26a70SApple OSS Distributions * 2569*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can set 2570*a1e26a70SApple OSS Distributions * audit information such as the the preselection mask, the terminal ID 2571*a1e26a70SApple OSS Distributions * and the audit session ID, using the setaudit() system call. 2572*a1e26a70SApple OSS Distributions * 2573*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2574*a1e26a70SApple OSS Distributions * errno should be returned. 2575*a1e26a70SApple OSS Distributions */ 2576*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_setaudit_t( 2577*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2578*a1e26a70SApple OSS Distributions struct auditinfo_addr *ai 2579*a1e26a70SApple OSS Distributions ); 2580*a1e26a70SApple OSS Distributions /** 2581*a1e26a70SApple OSS Distributions * @brief Access control check for setting audit user ID 2582*a1e26a70SApple OSS Distributions * @param cred Subject credential 2583*a1e26a70SApple OSS Distributions * @param auid Audit user ID 2584*a1e26a70SApple OSS Distributions * 2585*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can set 2586*a1e26a70SApple OSS Distributions * the user identity used by the auditing system, using the setauid() 2587*a1e26a70SApple OSS Distributions * system call. 2588*a1e26a70SApple OSS Distributions * 2589*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2590*a1e26a70SApple OSS Distributions * errno should be returned. 2591*a1e26a70SApple OSS Distributions */ 2592*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_setauid_t( 2593*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2594*a1e26a70SApple OSS Distributions uid_t auid 2595*a1e26a70SApple OSS Distributions ); 2596*a1e26a70SApple OSS Distributions /** 2597*a1e26a70SApple OSS Distributions * @brief Access control check for delivering signal 2598*a1e26a70SApple OSS Distributions * @param cred Subject credential 2599*a1e26a70SApple OSS Distributions * @param instigator Process which instigated the signal (optional) 2600*a1e26a70SApple OSS Distributions * @param target Object process 2601*a1e26a70SApple OSS Distributions * @param signum Signal number; see kill(2) 2602*a1e26a70SApple OSS Distributions * 2603*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can deliver 2604*a1e26a70SApple OSS Distributions * the passed signal to the passed process. 2605*a1e26a70SApple OSS Distributions * 2606*a1e26a70SApple OSS Distributions * @warning Programs typically expect to be able to send and receive 2607*a1e26a70SApple OSS Distributions * signals as part or their normal process lifecycle; caution should be 2608*a1e26a70SApple OSS Distributions * exercised when implementing access controls over signal events. 2609*a1e26a70SApple OSS Distributions * 2610*a1e26a70SApple OSS Distributions * @note Caller will always be current_proc(). But the instigator may be NULL, 2611*a1e26a70SApple OSS Distributions * may not be the current proc, and may no longer be running. 2612*a1e26a70SApple OSS Distributions * 2613*a1e26a70SApple OSS Distributions * @warning Policy implementations must avoid obtaining proc refs of 2614*a1e26a70SApple OSS Distributions * two different processes simultaneously. 2615*a1e26a70SApple OSS Distributions * 2616*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2617*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch, 2618*a1e26a70SApple OSS Distributions * EPERM for lack of privilege, or ESRCH to limit visibility. 2619*a1e26a70SApple OSS Distributions */ 2620*a1e26a70SApple OSS Distributions #define NEEDS_RDAR_132584934 1 // Required until both EndpointSecurity & Sandbox are updated 2621*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_signal_t( 2622*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2623*a1e26a70SApple OSS Distributions proc_ident_t instigator, 2624*a1e26a70SApple OSS Distributions proc_ident_t target, 2625*a1e26a70SApple OSS Distributions int signum 2626*a1e26a70SApple OSS Distributions ); 2627*a1e26a70SApple OSS Distributions /** 2628*a1e26a70SApple OSS Distributions * @brief Access control check for MAC syscalls. 2629*a1e26a70SApple OSS Distributions * @param proc Subject process 2630*a1e26a70SApple OSS Distributions * @param policy MAC policy name 2631*a1e26a70SApple OSS Distributions * @param callnum MAC policy-specific syscall number 2632*a1e26a70SApple OSS Distributions * 2633*a1e26a70SApple OSS Distributions * Determine whether the subject process can perform the passed MAC syscall. 2634*a1e26a70SApple OSS Distributions * 2635*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2636*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EPERM for lack of privilege. 2637*a1e26a70SApple OSS Distributions */ 2638*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_syscall_mac_t( 2639*a1e26a70SApple OSS Distributions struct proc *proc, 2640*a1e26a70SApple OSS Distributions const char *policy, 2641*a1e26a70SApple OSS Distributions int callnum 2642*a1e26a70SApple OSS Distributions ); 2643*a1e26a70SApple OSS Distributions /** 2644*a1e26a70SApple OSS Distributions * @brief Access control check for Unix syscalls. 2645*a1e26a70SApple OSS Distributions * @param proc Subject process 2646*a1e26a70SApple OSS Distributions * @param scnum Syscall number; see bsd/kern/syscalls.master. 2647*a1e26a70SApple OSS Distributions * 2648*a1e26a70SApple OSS Distributions * Determine whether the subject process can perform the passed syscall (number). 2649*a1e26a70SApple OSS Distributions * 2650*a1e26a70SApple OSS Distributions * @warning Programs typically expect to be able to make syscalls as part of 2651*a1e26a70SApple OSS Distributions * their normal process lifecycle; caution should be exercised when restricting 2652*a1e26a70SApple OSS Distributions * which syscalls a process can perform. 2653*a1e26a70SApple OSS Distributions * 2654*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2655*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EPERM for lack of privilege. 2656*a1e26a70SApple OSS Distributions */ 2657*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_syscall_unix_t( 2658*a1e26a70SApple OSS Distributions struct proc *proc, 2659*a1e26a70SApple OSS Distributions int scnum 2660*a1e26a70SApple OSS Distributions ); 2661*a1e26a70SApple OSS Distributions /** 2662*a1e26a70SApple OSS Distributions * @brief Access control check for wait 2663*a1e26a70SApple OSS Distributions * @param cred Subject credential 2664*a1e26a70SApple OSS Distributions * @param proc Object process 2665*a1e26a70SApple OSS Distributions * 2666*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can wait 2667*a1e26a70SApple OSS Distributions * for process termination. 2668*a1e26a70SApple OSS Distributions * 2669*a1e26a70SApple OSS Distributions * @warning Caution should be exercised when implementing access 2670*a1e26a70SApple OSS Distributions * controls for wait, since programs often wait for child processes to 2671*a1e26a70SApple OSS Distributions * exit. Failure to be notified of a child process terminating may 2672*a1e26a70SApple OSS Distributions * cause the parent process to hang, or may produce zombie processes. 2673*a1e26a70SApple OSS Distributions * 2674*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2675*a1e26a70SApple OSS Distributions * errno should be returned. 2676*a1e26a70SApple OSS Distributions */ 2677*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_wait_t( 2678*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2679*a1e26a70SApple OSS Distributions struct proc *proc 2680*a1e26a70SApple OSS Distributions ); 2681*a1e26a70SApple OSS Distributions /** 2682*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that a process has exited. 2683*a1e26a70SApple OSS Distributions * @param proc Object process 2684*a1e26a70SApple OSS Distributions * 2685*a1e26a70SApple OSS Distributions * Called after all of the process's threads have terminated and 2686*a1e26a70SApple OSS Distributions * it has been removed from the process list. KPI that identifies 2687*a1e26a70SApple OSS Distributions * the process by pid will fail to find the process; KPI that 2688*a1e26a70SApple OSS Distributions * identifies the process by the object process pointer functions 2689*a1e26a70SApple OSS Distributions * normally. proc_exiting() returns true for the object process. 2690*a1e26a70SApple OSS Distributions */ 2691*a1e26a70SApple OSS Distributions typedef void mpo_proc_notify_exit_t( 2692*a1e26a70SApple OSS Distributions struct proc *proc 2693*a1e26a70SApple OSS Distributions ); 2694*a1e26a70SApple OSS Distributions /** 2695*a1e26a70SApple OSS Distributions * @brief Access control check for skywalk flow connect 2696*a1e26a70SApple OSS Distributions * @param cred Subject credential 2697*a1e26a70SApple OSS Distributions * @param flow Flow object 2698*a1e26a70SApple OSS Distributions * @param addr Remote address for flow to send data to 2699*a1e26a70SApple OSS Distributions * @param type Flow type (e.g. SOCK_STREAM or SOCK_DGRAM) 2700*a1e26a70SApple OSS Distributions * @param protocol Network protocol (e.g. IPPROTO_TCP) 2701*a1e26a70SApple OSS Distributions * 2702*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 2703*a1e26a70SApple OSS Distributions * create a flow for sending data to the remote host specified by 2704*a1e26a70SApple OSS Distributions * addr. 2705*a1e26a70SApple OSS Distributions * 2706*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 2707*a1e26a70SApple OSS Distributions * value for errno should be returned. 2708*a1e26a70SApple OSS Distributions */ 2709*a1e26a70SApple OSS Distributions typedef int mpo_skywalk_flow_check_connect_t( 2710*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2711*a1e26a70SApple OSS Distributions void *flow, 2712*a1e26a70SApple OSS Distributions const struct sockaddr *addr, 2713*a1e26a70SApple OSS Distributions int type, 2714*a1e26a70SApple OSS Distributions int protocol 2715*a1e26a70SApple OSS Distributions ); 2716*a1e26a70SApple OSS Distributions /** 2717*a1e26a70SApple OSS Distributions * @brief Access control check for skywalk flow listen 2718*a1e26a70SApple OSS Distributions * @param cred Subject credential 2719*a1e26a70SApple OSS Distributions * @param flow Flow object 2720*a1e26a70SApple OSS Distributions * @param addr Local address for flow to listen on 2721*a1e26a70SApple OSS Distributions * @param type Flow type (e.g. SOCK_STREAM or SOCK_DGRAM) 2722*a1e26a70SApple OSS Distributions * @param protocol Network protocol (e.g. IPPROTO_TCP) 2723*a1e26a70SApple OSS Distributions * 2724*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 2725*a1e26a70SApple OSS Distributions * create a flow for receiving data on the local address specified 2726*a1e26a70SApple OSS Distributions * by addr. 2727*a1e26a70SApple OSS Distributions * 2728*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 2729*a1e26a70SApple OSS Distributions * value for errno should be returned. 2730*a1e26a70SApple OSS Distributions */ 2731*a1e26a70SApple OSS Distributions typedef int mpo_skywalk_flow_check_listen_t( 2732*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2733*a1e26a70SApple OSS Distributions void *flow, 2734*a1e26a70SApple OSS Distributions const struct sockaddr *addr, 2735*a1e26a70SApple OSS Distributions int type, 2736*a1e26a70SApple OSS Distributions int protocol 2737*a1e26a70SApple OSS Distributions ); 2738*a1e26a70SApple OSS Distributions /** 2739*a1e26a70SApple OSS Distributions * @brief Access control check for socket accept 2740*a1e26a70SApple OSS Distributions * @param cred Subject credential 2741*a1e26a70SApple OSS Distributions * @param so Object socket 2742*a1e26a70SApple OSS Distributions * @param socklabel Policy label for socket 2743*a1e26a70SApple OSS Distributions * 2744*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can accept() 2745*a1e26a70SApple OSS Distributions * a new connection on the socket from the host specified by addr. 2746*a1e26a70SApple OSS Distributions * 2747*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 2748*a1e26a70SApple OSS Distributions * value for errno should be returned. 2749*a1e26a70SApple OSS Distributions */ 2750*a1e26a70SApple OSS Distributions typedef int mpo_socket_check_accept_t( 2751*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2752*a1e26a70SApple OSS Distributions socket_t so, 2753*a1e26a70SApple OSS Distributions struct label *socklabel 2754*a1e26a70SApple OSS Distributions ); 2755*a1e26a70SApple OSS Distributions /** 2756*a1e26a70SApple OSS Distributions * @brief Access control check for a pending socket accept 2757*a1e26a70SApple OSS Distributions * @param cred Subject credential 2758*a1e26a70SApple OSS Distributions * @param so Object socket 2759*a1e26a70SApple OSS Distributions * @param socklabel Policy label for socket 2760*a1e26a70SApple OSS Distributions * @param addr Address of the listening socket (coming soon) 2761*a1e26a70SApple OSS Distributions * 2762*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can accept() 2763*a1e26a70SApple OSS Distributions * a pending connection on the socket from the host specified by addr. 2764*a1e26a70SApple OSS Distributions * 2765*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 2766*a1e26a70SApple OSS Distributions * value for errno should be returned. 2767*a1e26a70SApple OSS Distributions */ 2768*a1e26a70SApple OSS Distributions typedef int mpo_socket_check_accepted_t( 2769*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2770*a1e26a70SApple OSS Distributions socket_t so, 2771*a1e26a70SApple OSS Distributions struct label *socklabel, 2772*a1e26a70SApple OSS Distributions struct sockaddr *addr 2773*a1e26a70SApple OSS Distributions ); 2774*a1e26a70SApple OSS Distributions /** 2775*a1e26a70SApple OSS Distributions * @brief Access control check for socket bind 2776*a1e26a70SApple OSS Distributions * @param cred Subject credential 2777*a1e26a70SApple OSS Distributions * @param so Object socket 2778*a1e26a70SApple OSS Distributions * @param socklabel Policy label for socket 2779*a1e26a70SApple OSS Distributions * @param addr Name to assign to the socket 2780*a1e26a70SApple OSS Distributions * 2781*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can bind() 2782*a1e26a70SApple OSS Distributions * the name (addr) to the socket. 2783*a1e26a70SApple OSS Distributions * 2784*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 2785*a1e26a70SApple OSS Distributions * value for errno should be returned. 2786*a1e26a70SApple OSS Distributions */ 2787*a1e26a70SApple OSS Distributions typedef int mpo_socket_check_bind_t( 2788*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2789*a1e26a70SApple OSS Distributions socket_t so, 2790*a1e26a70SApple OSS Distributions struct label *socklabel, 2791*a1e26a70SApple OSS Distributions struct sockaddr *addr 2792*a1e26a70SApple OSS Distributions ); 2793*a1e26a70SApple OSS Distributions /** 2794*a1e26a70SApple OSS Distributions * @brief Access control check for socket connect 2795*a1e26a70SApple OSS Distributions * @param cred Subject credential 2796*a1e26a70SApple OSS Distributions * @param so Object socket 2797*a1e26a70SApple OSS Distributions * @param socklabel Policy label for socket 2798*a1e26a70SApple OSS Distributions * @param addr Name to assign to the socket 2799*a1e26a70SApple OSS Distributions * 2800*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 2801*a1e26a70SApple OSS Distributions * connect() the passed socket to the remote host specified by addr. 2802*a1e26a70SApple OSS Distributions * 2803*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 2804*a1e26a70SApple OSS Distributions * value for errno should be returned. 2805*a1e26a70SApple OSS Distributions */ 2806*a1e26a70SApple OSS Distributions typedef int mpo_socket_check_connect_t( 2807*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2808*a1e26a70SApple OSS Distributions socket_t so, 2809*a1e26a70SApple OSS Distributions struct label *socklabel, 2810*a1e26a70SApple OSS Distributions struct sockaddr *addr 2811*a1e26a70SApple OSS Distributions ); 2812*a1e26a70SApple OSS Distributions /** 2813*a1e26a70SApple OSS Distributions * @brief Access control check for socket() system call. 2814*a1e26a70SApple OSS Distributions * @param cred Subject credential 2815*a1e26a70SApple OSS Distributions * @param domain communication domain 2816*a1e26a70SApple OSS Distributions * @param type socket type 2817*a1e26a70SApple OSS Distributions * @param protocol socket protocol 2818*a1e26a70SApple OSS Distributions * 2819*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 2820*a1e26a70SApple OSS Distributions * make the socket() call. 2821*a1e26a70SApple OSS Distributions * 2822*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 2823*a1e26a70SApple OSS Distributions * value for errno should be returned. 2824*a1e26a70SApple OSS Distributions */ 2825*a1e26a70SApple OSS Distributions typedef int mpo_socket_check_create_t( 2826*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2827*a1e26a70SApple OSS Distributions int domain, 2828*a1e26a70SApple OSS Distributions int type, 2829*a1e26a70SApple OSS Distributions int protocol 2830*a1e26a70SApple OSS Distributions ); 2831*a1e26a70SApple OSS Distributions /** 2832*a1e26a70SApple OSS Distributions * @brief Access control check for socket ioctl. 2833*a1e26a70SApple OSS Distributions * @param cred Subject credential 2834*a1e26a70SApple OSS Distributions * @param so Object socket 2835*a1e26a70SApple OSS Distributions * @param cmd The ioctl command; see ioctl(2) 2836*a1e26a70SApple OSS Distributions * @param socklabel Policy label for socket 2837*a1e26a70SApple OSS Distributions * 2838*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 2839*a1e26a70SApple OSS Distributions * the ioctl operation indicated by cmd on the given socket. 2840*a1e26a70SApple OSS Distributions * 2841*a1e26a70SApple OSS Distributions * @warning Since ioctl data is opaque from the standpoint of the MAC 2842*a1e26a70SApple OSS Distributions * framework, and since ioctls can affect many aspects of system 2843*a1e26a70SApple OSS Distributions * operation, policies must exercise extreme care when implementing 2844*a1e26a70SApple OSS Distributions * access control checks. 2845*a1e26a70SApple OSS Distributions * 2846*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2847*a1e26a70SApple OSS Distributions * errno should be returned. 2848*a1e26a70SApple OSS Distributions */ 2849*a1e26a70SApple OSS Distributions typedef int mpo_socket_check_ioctl_t( 2850*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2851*a1e26a70SApple OSS Distributions socket_t so, 2852*a1e26a70SApple OSS Distributions unsigned long cmd, 2853*a1e26a70SApple OSS Distributions struct label *socklabel 2854*a1e26a70SApple OSS Distributions ); 2855*a1e26a70SApple OSS Distributions /** 2856*a1e26a70SApple OSS Distributions * @brief Access control check for socket listen 2857*a1e26a70SApple OSS Distributions * @param cred Subject credential 2858*a1e26a70SApple OSS Distributions * @param so Object socket 2859*a1e26a70SApple OSS Distributions * @param socklabel Policy label for socket 2860*a1e26a70SApple OSS Distributions * 2861*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 2862*a1e26a70SApple OSS Distributions * listen() on the passed socket. 2863*a1e26a70SApple OSS Distributions * 2864*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 2865*a1e26a70SApple OSS Distributions * value for errno should be returned. 2866*a1e26a70SApple OSS Distributions */ 2867*a1e26a70SApple OSS Distributions typedef int mpo_socket_check_listen_t( 2868*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2869*a1e26a70SApple OSS Distributions socket_t so, 2870*a1e26a70SApple OSS Distributions struct label *socklabel 2871*a1e26a70SApple OSS Distributions ); 2872*a1e26a70SApple OSS Distributions /** 2873*a1e26a70SApple OSS Distributions * @brief Access control check for socket receive 2874*a1e26a70SApple OSS Distributions * @param cred Subject credential 2875*a1e26a70SApple OSS Distributions * @param so Object socket 2876*a1e26a70SApple OSS Distributions * @param socklabel Policy label for socket 2877*a1e26a70SApple OSS Distributions * 2878*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 2879*a1e26a70SApple OSS Distributions * receive data from the socket. 2880*a1e26a70SApple OSS Distributions * 2881*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 2882*a1e26a70SApple OSS Distributions * value for errno should be returned. 2883*a1e26a70SApple OSS Distributions */ 2884*a1e26a70SApple OSS Distributions typedef int mpo_socket_check_receive_t( 2885*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2886*a1e26a70SApple OSS Distributions socket_t so, 2887*a1e26a70SApple OSS Distributions struct label *socklabel 2888*a1e26a70SApple OSS Distributions ); 2889*a1e26a70SApple OSS Distributions 2890*a1e26a70SApple OSS Distributions /** 2891*a1e26a70SApple OSS Distributions * @brief Access control check for socket receive 2892*a1e26a70SApple OSS Distributions * @param cred Subject credential 2893*a1e26a70SApple OSS Distributions * @param sock Object socket 2894*a1e26a70SApple OSS Distributions * @param socklabel Policy label for socket 2895*a1e26a70SApple OSS Distributions * @param saddr Name of the remote socket 2896*a1e26a70SApple OSS Distributions * 2897*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 2898*a1e26a70SApple OSS Distributions * receive data from the remote host specified by addr. 2899*a1e26a70SApple OSS Distributions * 2900*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 2901*a1e26a70SApple OSS Distributions * value for errno should be returned. 2902*a1e26a70SApple OSS Distributions */ 2903*a1e26a70SApple OSS Distributions typedef int mpo_socket_check_received_t( 2904*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2905*a1e26a70SApple OSS Distributions struct socket *sock, 2906*a1e26a70SApple OSS Distributions struct label *socklabel, 2907*a1e26a70SApple OSS Distributions struct sockaddr *saddr 2908*a1e26a70SApple OSS Distributions ); 2909*a1e26a70SApple OSS Distributions 2910*a1e26a70SApple OSS Distributions /** 2911*a1e26a70SApple OSS Distributions * @brief Access control check for socket send 2912*a1e26a70SApple OSS Distributions * @param cred Subject credential 2913*a1e26a70SApple OSS Distributions * @param so Object socket 2914*a1e26a70SApple OSS Distributions * @param socklabel Policy label for socket 2915*a1e26a70SApple OSS Distributions * @param addr Address being sent to 2916*a1e26a70SApple OSS Distributions * 2917*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can send 2918*a1e26a70SApple OSS Distributions * data to the socket. 2919*a1e26a70SApple OSS Distributions * 2920*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 2921*a1e26a70SApple OSS Distributions * value for errno should be returned. 2922*a1e26a70SApple OSS Distributions */ 2923*a1e26a70SApple OSS Distributions typedef int mpo_socket_check_send_t( 2924*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2925*a1e26a70SApple OSS Distributions socket_t so, 2926*a1e26a70SApple OSS Distributions struct label *socklabel, 2927*a1e26a70SApple OSS Distributions struct sockaddr *addr 2928*a1e26a70SApple OSS Distributions ); 2929*a1e26a70SApple OSS Distributions /** 2930*a1e26a70SApple OSS Distributions * @brief Access control check for retrieving socket status 2931*a1e26a70SApple OSS Distributions * @param cred Subject credential 2932*a1e26a70SApple OSS Distributions * @param so Object socket 2933*a1e26a70SApple OSS Distributions * @param socklabel Policy label for so 2934*a1e26a70SApple OSS Distributions * 2935*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 2936*a1e26a70SApple OSS Distributions * execute the stat() system call on the given socket. 2937*a1e26a70SApple OSS Distributions * 2938*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 2939*a1e26a70SApple OSS Distributions * value for errno should be returned. 2940*a1e26a70SApple OSS Distributions */ 2941*a1e26a70SApple OSS Distributions typedef int mpo_socket_check_stat_t( 2942*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2943*a1e26a70SApple OSS Distributions socket_t so, 2944*a1e26a70SApple OSS Distributions struct label *socklabel 2945*a1e26a70SApple OSS Distributions ); 2946*a1e26a70SApple OSS Distributions /** 2947*a1e26a70SApple OSS Distributions * @brief Access control check for setting socket options 2948*a1e26a70SApple OSS Distributions * @param cred Subject credential 2949*a1e26a70SApple OSS Distributions * @param so Object socket 2950*a1e26a70SApple OSS Distributions * @param socklabel Policy label for so 2951*a1e26a70SApple OSS Distributions * @param sopt The options being set 2952*a1e26a70SApple OSS Distributions * 2953*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 2954*a1e26a70SApple OSS Distributions * execute the setsockopt system call on the given socket. 2955*a1e26a70SApple OSS Distributions * 2956*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 2957*a1e26a70SApple OSS Distributions * value for errno should be returned. 2958*a1e26a70SApple OSS Distributions */ 2959*a1e26a70SApple OSS Distributions typedef int mpo_socket_check_setsockopt_t( 2960*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2961*a1e26a70SApple OSS Distributions socket_t so, 2962*a1e26a70SApple OSS Distributions struct label *socklabel, 2963*a1e26a70SApple OSS Distributions struct sockopt *sopt 2964*a1e26a70SApple OSS Distributions ); 2965*a1e26a70SApple OSS Distributions /** 2966*a1e26a70SApple OSS Distributions * @brief Access control check for getting socket options 2967*a1e26a70SApple OSS Distributions * @param cred Subject credential 2968*a1e26a70SApple OSS Distributions * @param so Object socket 2969*a1e26a70SApple OSS Distributions * @param socklabel Policy label for so 2970*a1e26a70SApple OSS Distributions * @param sopt The options to get 2971*a1e26a70SApple OSS Distributions * 2972*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 2973*a1e26a70SApple OSS Distributions * execute the getsockopt system call on the given socket. 2974*a1e26a70SApple OSS Distributions * 2975*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 2976*a1e26a70SApple OSS Distributions * value for errno should be returned. 2977*a1e26a70SApple OSS Distributions */ 2978*a1e26a70SApple OSS Distributions typedef int mpo_socket_check_getsockopt_t( 2979*a1e26a70SApple OSS Distributions kauth_cred_t cred, 2980*a1e26a70SApple OSS Distributions socket_t so, 2981*a1e26a70SApple OSS Distributions struct label *socklabel, 2982*a1e26a70SApple OSS Distributions struct sockopt *sopt 2983*a1e26a70SApple OSS Distributions ); 2984*a1e26a70SApple OSS Distributions /** 2985*a1e26a70SApple OSS Distributions * @brief Access control check for enabling accounting 2986*a1e26a70SApple OSS Distributions * @param cred Subject credential 2987*a1e26a70SApple OSS Distributions * @param vp Accounting file 2988*a1e26a70SApple OSS Distributions * @param vlabel Label associated with vp 2989*a1e26a70SApple OSS Distributions * 2990*a1e26a70SApple OSS Distributions * Determine whether the subject should be allowed to enable accounting, 2991*a1e26a70SApple OSS Distributions * based on its label and the label of the accounting log file. See 2992*a1e26a70SApple OSS Distributions * acct(5) for more information. 2993*a1e26a70SApple OSS Distributions * 2994*a1e26a70SApple OSS Distributions * As accounting is disabled by passing NULL to the acct(2) system call, 2995*a1e26a70SApple OSS Distributions * the policy should be prepared for both 'vp' and 'vlabel' to be NULL. 2996*a1e26a70SApple OSS Distributions * 2997*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 2998*a1e26a70SApple OSS Distributions * errno should be returned. 2999*a1e26a70SApple OSS Distributions */ 3000*a1e26a70SApple OSS Distributions typedef int mpo_system_check_acct_t( 3001*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3002*a1e26a70SApple OSS Distributions struct vnode *vp, 3003*a1e26a70SApple OSS Distributions struct label *vlabel 3004*a1e26a70SApple OSS Distributions ); 3005*a1e26a70SApple OSS Distributions /** 3006*a1e26a70SApple OSS Distributions * @brief Access control check for audit 3007*a1e26a70SApple OSS Distributions * @param cred Subject credential 3008*a1e26a70SApple OSS Distributions * @param record Audit record 3009*a1e26a70SApple OSS Distributions * @param length Audit record length 3010*a1e26a70SApple OSS Distributions * 3011*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can submit 3012*a1e26a70SApple OSS Distributions * an audit record for inclusion in the audit log via the audit() system call. 3013*a1e26a70SApple OSS Distributions * 3014*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3015*a1e26a70SApple OSS Distributions * errno should be returned. 3016*a1e26a70SApple OSS Distributions */ 3017*a1e26a70SApple OSS Distributions typedef int mpo_system_check_audit_t( 3018*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3019*a1e26a70SApple OSS Distributions void *record, 3020*a1e26a70SApple OSS Distributions int length 3021*a1e26a70SApple OSS Distributions ); 3022*a1e26a70SApple OSS Distributions /** 3023*a1e26a70SApple OSS Distributions * @brief Access control check for controlling audit 3024*a1e26a70SApple OSS Distributions * @param cred Subject credential 3025*a1e26a70SApple OSS Distributions * @param vp Audit file 3026*a1e26a70SApple OSS Distributions * @param vl Label associated with vp 3027*a1e26a70SApple OSS Distributions * 3028*a1e26a70SApple OSS Distributions * Determine whether the subject should be allowed to enable auditing using 3029*a1e26a70SApple OSS Distributions * the auditctl() system call, based on its label and the label of the proposed 3030*a1e26a70SApple OSS Distributions * audit file. 3031*a1e26a70SApple OSS Distributions * 3032*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3033*a1e26a70SApple OSS Distributions * errno should be returned. 3034*a1e26a70SApple OSS Distributions */ 3035*a1e26a70SApple OSS Distributions typedef int mpo_system_check_auditctl_t( 3036*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3037*a1e26a70SApple OSS Distributions struct vnode *vp, 3038*a1e26a70SApple OSS Distributions struct label *vl 3039*a1e26a70SApple OSS Distributions ); 3040*a1e26a70SApple OSS Distributions /** 3041*a1e26a70SApple OSS Distributions * @brief Access control check for manipulating auditing 3042*a1e26a70SApple OSS Distributions * @param cred Subject credential 3043*a1e26a70SApple OSS Distributions * @param cmd Audit control command 3044*a1e26a70SApple OSS Distributions * 3045*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 3046*a1e26a70SApple OSS Distributions * the audit subsystem control operation cmd via the auditon() system call. 3047*a1e26a70SApple OSS Distributions * 3048*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3049*a1e26a70SApple OSS Distributions * errno should be returned. 3050*a1e26a70SApple OSS Distributions */ 3051*a1e26a70SApple OSS Distributions typedef int mpo_system_check_auditon_t( 3052*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3053*a1e26a70SApple OSS Distributions int cmd 3054*a1e26a70SApple OSS Distributions ); 3055*a1e26a70SApple OSS Distributions /** 3056*a1e26a70SApple OSS Distributions * @brief Access control check for obtaining the host control port 3057*a1e26a70SApple OSS Distributions * @param cred Subject credential 3058*a1e26a70SApple OSS Distributions * 3059*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 3060*a1e26a70SApple OSS Distributions * obtain the host control port. 3061*a1e26a70SApple OSS Distributions * 3062*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, or non-zero otherwise. 3063*a1e26a70SApple OSS Distributions */ 3064*a1e26a70SApple OSS Distributions typedef int mpo_system_check_host_priv_t( 3065*a1e26a70SApple OSS Distributions kauth_cred_t cred 3066*a1e26a70SApple OSS Distributions ); 3067*a1e26a70SApple OSS Distributions /** 3068*a1e26a70SApple OSS Distributions * @brief Access control check for obtaining system information 3069*a1e26a70SApple OSS Distributions * @param cred Subject credential 3070*a1e26a70SApple OSS Distributions * @param info_type A description of the information requested 3071*a1e26a70SApple OSS Distributions * 3072*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 3073*a1e26a70SApple OSS Distributions * allowed to obtain information about the system. 3074*a1e26a70SApple OSS Distributions * 3075*a1e26a70SApple OSS Distributions * This is a generic hook that can be used in a variety of situations where 3076*a1e26a70SApple OSS Distributions * information is being returned that might be considered sensitive. 3077*a1e26a70SApple OSS Distributions * Rather than adding a new MAC hook for every such interface, this hook can 3078*a1e26a70SApple OSS Distributions * be called with a string identifying the type of information requested. 3079*a1e26a70SApple OSS Distributions * 3080*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3081*a1e26a70SApple OSS Distributions * errno should be returned. 3082*a1e26a70SApple OSS Distributions */ 3083*a1e26a70SApple OSS Distributions typedef int mpo_system_check_info_t( 3084*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3085*a1e26a70SApple OSS Distributions const char *info_type 3086*a1e26a70SApple OSS Distributions ); 3087*a1e26a70SApple OSS Distributions /** 3088*a1e26a70SApple OSS Distributions * @brief Access control check for calling NFS services 3089*a1e26a70SApple OSS Distributions * @param cred Subject credential 3090*a1e26a70SApple OSS Distributions * 3091*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 3092*a1e26a70SApple OSS Distributions * allowed to call nfssrv(2). 3093*a1e26a70SApple OSS Distributions * 3094*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3095*a1e26a70SApple OSS Distributions * errno should be returned. 3096*a1e26a70SApple OSS Distributions */ 3097*a1e26a70SApple OSS Distributions typedef int mpo_system_check_nfsd_t( 3098*a1e26a70SApple OSS Distributions kauth_cred_t cred 3099*a1e26a70SApple OSS Distributions ); 3100*a1e26a70SApple OSS Distributions /** 3101*a1e26a70SApple OSS Distributions * @brief Access control check for reboot 3102*a1e26a70SApple OSS Distributions * @param cred Subject credential 3103*a1e26a70SApple OSS Distributions * @param howto howto parameter from reboot(2) 3104*a1e26a70SApple OSS Distributions * 3105*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 3106*a1e26a70SApple OSS Distributions * allowed to reboot the system in the specified manner. 3107*a1e26a70SApple OSS Distributions * 3108*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3109*a1e26a70SApple OSS Distributions * errno should be returned. 3110*a1e26a70SApple OSS Distributions */ 3111*a1e26a70SApple OSS Distributions typedef int mpo_system_check_reboot_t( 3112*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3113*a1e26a70SApple OSS Distributions int howto 3114*a1e26a70SApple OSS Distributions ); 3115*a1e26a70SApple OSS Distributions /** 3116*a1e26a70SApple OSS Distributions * @brief Access control check for setting system clock 3117*a1e26a70SApple OSS Distributions * @param cred Subject credential 3118*a1e26a70SApple OSS Distributions * 3119*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 3120*a1e26a70SApple OSS Distributions * allowed to set the system clock. 3121*a1e26a70SApple OSS Distributions * 3122*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3123*a1e26a70SApple OSS Distributions * errno should be returned. 3124*a1e26a70SApple OSS Distributions */ 3125*a1e26a70SApple OSS Distributions typedef int mpo_system_check_settime_t( 3126*a1e26a70SApple OSS Distributions kauth_cred_t cred 3127*a1e26a70SApple OSS Distributions ); 3128*a1e26a70SApple OSS Distributions /** 3129*a1e26a70SApple OSS Distributions * @brief Access control check for removing swap devices 3130*a1e26a70SApple OSS Distributions * @param cred Subject credential 3131*a1e26a70SApple OSS Distributions * @param vp Swap device 3132*a1e26a70SApple OSS Distributions * @param label Label associated with vp 3133*a1e26a70SApple OSS Distributions * 3134*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 3135*a1e26a70SApple OSS Distributions * allowed to remove vp as a swap device. 3136*a1e26a70SApple OSS Distributions * 3137*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3138*a1e26a70SApple OSS Distributions * errno should be returned. 3139*a1e26a70SApple OSS Distributions */ 3140*a1e26a70SApple OSS Distributions typedef int mpo_system_check_swapoff_t( 3141*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3142*a1e26a70SApple OSS Distributions struct vnode *vp, 3143*a1e26a70SApple OSS Distributions struct label *label 3144*a1e26a70SApple OSS Distributions ); 3145*a1e26a70SApple OSS Distributions /** 3146*a1e26a70SApple OSS Distributions * @brief Access control check for adding swap devices 3147*a1e26a70SApple OSS Distributions * @param cred Subject credential 3148*a1e26a70SApple OSS Distributions * @param vp Swap device 3149*a1e26a70SApple OSS Distributions * @param label Label associated with vp 3150*a1e26a70SApple OSS Distributions * 3151*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 3152*a1e26a70SApple OSS Distributions * allowed to add vp as a swap device. 3153*a1e26a70SApple OSS Distributions * 3154*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3155*a1e26a70SApple OSS Distributions * errno should be returned. 3156*a1e26a70SApple OSS Distributions */ 3157*a1e26a70SApple OSS Distributions typedef int mpo_system_check_swapon_t( 3158*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3159*a1e26a70SApple OSS Distributions struct vnode *vp, 3160*a1e26a70SApple OSS Distributions struct label *label 3161*a1e26a70SApple OSS Distributions ); 3162*a1e26a70SApple OSS Distributions /** 3163*a1e26a70SApple OSS Distributions * @brief Access control check for sysctl 3164*a1e26a70SApple OSS Distributions * @param cred Subject credential 3165*a1e26a70SApple OSS Distributions * @param namestring String representation of sysctl name. 3166*a1e26a70SApple OSS Distributions * @param name Integer name; see sysctl(3) 3167*a1e26a70SApple OSS Distributions * @param namelen Length of name array of integers; see sysctl(3) 3168*a1e26a70SApple OSS Distributions * @param old 0 or address where to store old value; see sysctl(3) 3169*a1e26a70SApple OSS Distributions * @param oldlen Length of old buffer; see sysctl(3) 3170*a1e26a70SApple OSS Distributions * @param newvalue 0 or address of new value; see sysctl(3) 3171*a1e26a70SApple OSS Distributions * @param newlen Length of new buffer; see sysctl(3) 3172*a1e26a70SApple OSS Distributions * 3173*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 3174*a1e26a70SApple OSS Distributions * allowed to make the specified sysctl(3) transaction. 3175*a1e26a70SApple OSS Distributions * 3176*a1e26a70SApple OSS Distributions * The sysctl(3) call specifies that if the old value is not desired, 3177*a1e26a70SApple OSS Distributions * oldp and oldlenp should be set to NULL. Likewise, if a new value is 3178*a1e26a70SApple OSS Distributions * not to be set, newp should be set to NULL and newlen set to 0. 3179*a1e26a70SApple OSS Distributions * 3180*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3181*a1e26a70SApple OSS Distributions * errno should be returned. 3182*a1e26a70SApple OSS Distributions */ 3183*a1e26a70SApple OSS Distributions typedef int mpo_system_check_sysctlbyname_t( 3184*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3185*a1e26a70SApple OSS Distributions const char *namestring, 3186*a1e26a70SApple OSS Distributions int *name, 3187*a1e26a70SApple OSS Distributions size_t namelen, 3188*a1e26a70SApple OSS Distributions user_addr_t old, /* NULLOK */ 3189*a1e26a70SApple OSS Distributions size_t oldlen, 3190*a1e26a70SApple OSS Distributions user_addr_t newvalue, /* NULLOK */ 3191*a1e26a70SApple OSS Distributions size_t newlen 3192*a1e26a70SApple OSS Distributions ); 3193*a1e26a70SApple OSS Distributions /** 3194*a1e26a70SApple OSS Distributions * @brief Access control check for kas_info 3195*a1e26a70SApple OSS Distributions * @param cred Subject credential 3196*a1e26a70SApple OSS Distributions * @param selector Category of information to return. See kas_info.h 3197*a1e26a70SApple OSS Distributions * 3198*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 3199*a1e26a70SApple OSS Distributions * introspection of the kernel address space layout for 3200*a1e26a70SApple OSS Distributions * debugging/performance analysis. 3201*a1e26a70SApple OSS Distributions * 3202*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3203*a1e26a70SApple OSS Distributions * errno should be returned. 3204*a1e26a70SApple OSS Distributions */ 3205*a1e26a70SApple OSS Distributions typedef int mpo_system_check_kas_info_t( 3206*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3207*a1e26a70SApple OSS Distributions int selector 3208*a1e26a70SApple OSS Distributions ); 3209*a1e26a70SApple OSS Distributions /** 3210*a1e26a70SApple OSS Distributions * @brief Create a System V message label 3211*a1e26a70SApple OSS Distributions * @param cred Subject credential 3212*a1e26a70SApple OSS Distributions * @param msqptr The message queue the message will be placed in 3213*a1e26a70SApple OSS Distributions * @param msqlabel The label of the message queue 3214*a1e26a70SApple OSS Distributions * @param msgptr The message 3215*a1e26a70SApple OSS Distributions * @param msglabel The label of the message 3216*a1e26a70SApple OSS Distributions * 3217*a1e26a70SApple OSS Distributions * Label the message as its placed in the message queue. 3218*a1e26a70SApple OSS Distributions */ 3219*a1e26a70SApple OSS Distributions typedef void mpo_sysvmsg_label_associate_t( 3220*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3221*a1e26a70SApple OSS Distributions struct msqid_kernel *msqptr, 3222*a1e26a70SApple OSS Distributions struct label *msqlabel, 3223*a1e26a70SApple OSS Distributions struct msg *msgptr, 3224*a1e26a70SApple OSS Distributions struct label *msglabel 3225*a1e26a70SApple OSS Distributions ); 3226*a1e26a70SApple OSS Distributions /** 3227*a1e26a70SApple OSS Distributions * @brief Destroy System V message label 3228*a1e26a70SApple OSS Distributions * @param label The label to be destroyed 3229*a1e26a70SApple OSS Distributions * 3230*a1e26a70SApple OSS Distributions * Destroy a System V message label. Since the object is 3231*a1e26a70SApple OSS Distributions * going out of scope, policy modules should free any internal storage 3232*a1e26a70SApple OSS Distributions * associated with the label so that it may be destroyed. 3233*a1e26a70SApple OSS Distributions */ 3234*a1e26a70SApple OSS Distributions typedef void mpo_sysvmsg_label_destroy_t( 3235*a1e26a70SApple OSS Distributions struct label *label 3236*a1e26a70SApple OSS Distributions ); 3237*a1e26a70SApple OSS Distributions /** 3238*a1e26a70SApple OSS Distributions * @brief Initialize System V message label 3239*a1e26a70SApple OSS Distributions * @param label New label to initialize 3240*a1e26a70SApple OSS Distributions * 3241*a1e26a70SApple OSS Distributions * Initialize the label for a newly instantiated System V message. 3242*a1e26a70SApple OSS Distributions */ 3243*a1e26a70SApple OSS Distributions typedef void mpo_sysvmsg_label_init_t( 3244*a1e26a70SApple OSS Distributions struct label *label 3245*a1e26a70SApple OSS Distributions ); 3246*a1e26a70SApple OSS Distributions /** 3247*a1e26a70SApple OSS Distributions * @brief Clean up a System V message label 3248*a1e26a70SApple OSS Distributions * @param label The label to be destroyed 3249*a1e26a70SApple OSS Distributions * 3250*a1e26a70SApple OSS Distributions * Clean up a System V message label. Darwin pre-allocates 3251*a1e26a70SApple OSS Distributions * messages at system boot time and re-uses them rather than 3252*a1e26a70SApple OSS Distributions * allocating new ones. Before messages are returned to the "free 3253*a1e26a70SApple OSS Distributions * pool", policies can cleanup or overwrite any information present in 3254*a1e26a70SApple OSS Distributions * the label. 3255*a1e26a70SApple OSS Distributions */ 3256*a1e26a70SApple OSS Distributions typedef void mpo_sysvmsg_label_recycle_t( 3257*a1e26a70SApple OSS Distributions struct label *label 3258*a1e26a70SApple OSS Distributions ); 3259*a1e26a70SApple OSS Distributions /** 3260*a1e26a70SApple OSS Distributions * @brief Access control check for System V message enqueuing 3261*a1e26a70SApple OSS Distributions * @param cred Subject credential 3262*a1e26a70SApple OSS Distributions * @param msgptr The message 3263*a1e26a70SApple OSS Distributions * @param msglabel The message's label 3264*a1e26a70SApple OSS Distributions * @param msqptr The message queue 3265*a1e26a70SApple OSS Distributions * @param msqlabel The message queue's label 3266*a1e26a70SApple OSS Distributions * 3267*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can add the 3268*a1e26a70SApple OSS Distributions * given message to the given message queue. 3269*a1e26a70SApple OSS Distributions * 3270*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3271*a1e26a70SApple OSS Distributions * errno should be returned. 3272*a1e26a70SApple OSS Distributions */ 3273*a1e26a70SApple OSS Distributions typedef int mpo_sysvmsq_check_enqueue_t( 3274*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3275*a1e26a70SApple OSS Distributions struct msg *msgptr, 3276*a1e26a70SApple OSS Distributions struct label *msglabel, 3277*a1e26a70SApple OSS Distributions struct msqid_kernel *msqptr, 3278*a1e26a70SApple OSS Distributions struct label *msqlabel 3279*a1e26a70SApple OSS Distributions ); 3280*a1e26a70SApple OSS Distributions /** 3281*a1e26a70SApple OSS Distributions * @brief Access control check for System V message reception 3282*a1e26a70SApple OSS Distributions * @param cred The credential of the intended recipient 3283*a1e26a70SApple OSS Distributions * @param msgptr The message 3284*a1e26a70SApple OSS Distributions * @param msglabel The message's label 3285*a1e26a70SApple OSS Distributions * 3286*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can receive 3287*a1e26a70SApple OSS Distributions * the given message. 3288*a1e26a70SApple OSS Distributions * 3289*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3290*a1e26a70SApple OSS Distributions * errno should be returned. 3291*a1e26a70SApple OSS Distributions */ 3292*a1e26a70SApple OSS Distributions typedef int mpo_sysvmsq_check_msgrcv_t( 3293*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3294*a1e26a70SApple OSS Distributions struct msg *msgptr, 3295*a1e26a70SApple OSS Distributions struct label *msglabel 3296*a1e26a70SApple OSS Distributions ); 3297*a1e26a70SApple OSS Distributions /** 3298*a1e26a70SApple OSS Distributions * @brief Access control check for System V message queue removal 3299*a1e26a70SApple OSS Distributions * @param cred The credential of the caller 3300*a1e26a70SApple OSS Distributions * @param msgptr The message 3301*a1e26a70SApple OSS Distributions * @param msglabel The message's label 3302*a1e26a70SApple OSS Distributions * 3303*a1e26a70SApple OSS Distributions * System V message queues are removed using the msgctl() system call. 3304*a1e26a70SApple OSS Distributions * The system will iterate over each message in the queue, calling this 3305*a1e26a70SApple OSS Distributions * function for each, to determine whether the caller has the appropriate 3306*a1e26a70SApple OSS Distributions * credentials. 3307*a1e26a70SApple OSS Distributions * 3308*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3309*a1e26a70SApple OSS Distributions * errno should be returned. 3310*a1e26a70SApple OSS Distributions */ 3311*a1e26a70SApple OSS Distributions typedef int mpo_sysvmsq_check_msgrmid_t( 3312*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3313*a1e26a70SApple OSS Distributions struct msg *msgptr, 3314*a1e26a70SApple OSS Distributions struct label *msglabel 3315*a1e26a70SApple OSS Distributions ); 3316*a1e26a70SApple OSS Distributions /** 3317*a1e26a70SApple OSS Distributions * @brief Access control check for msgctl() 3318*a1e26a70SApple OSS Distributions * @param cred The credential of the caller 3319*a1e26a70SApple OSS Distributions * @param msqptr The message queue 3320*a1e26a70SApple OSS Distributions * @param msqlabel The message queue's label 3321*a1e26a70SApple OSS Distributions * 3322*a1e26a70SApple OSS Distributions * This access check is performed to validate calls to msgctl(). 3323*a1e26a70SApple OSS Distributions * 3324*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3325*a1e26a70SApple OSS Distributions * errno should be returned. 3326*a1e26a70SApple OSS Distributions */ 3327*a1e26a70SApple OSS Distributions typedef int mpo_sysvmsq_check_msqctl_t( 3328*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3329*a1e26a70SApple OSS Distributions struct msqid_kernel *msqptr, 3330*a1e26a70SApple OSS Distributions struct label *msqlabel, 3331*a1e26a70SApple OSS Distributions int cmd 3332*a1e26a70SApple OSS Distributions ); 3333*a1e26a70SApple OSS Distributions /** 3334*a1e26a70SApple OSS Distributions * @brief Access control check to get a System V message queue 3335*a1e26a70SApple OSS Distributions * @param cred The credential of the caller 3336*a1e26a70SApple OSS Distributions * @param msqptr The message queue requested 3337*a1e26a70SApple OSS Distributions * @param msqlabel The message queue's label 3338*a1e26a70SApple OSS Distributions * 3339*a1e26a70SApple OSS Distributions * On a call to msgget(), if the queue requested already exists, 3340*a1e26a70SApple OSS Distributions * and it is a public queue, this check will be performed before the 3341*a1e26a70SApple OSS Distributions * queue's ID is returned to the user. 3342*a1e26a70SApple OSS Distributions * 3343*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3344*a1e26a70SApple OSS Distributions * errno should be returned. 3345*a1e26a70SApple OSS Distributions */ 3346*a1e26a70SApple OSS Distributions typedef int mpo_sysvmsq_check_msqget_t( 3347*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3348*a1e26a70SApple OSS Distributions struct msqid_kernel *msqptr, 3349*a1e26a70SApple OSS Distributions struct label *msqlabel 3350*a1e26a70SApple OSS Distributions ); 3351*a1e26a70SApple OSS Distributions /** 3352*a1e26a70SApple OSS Distributions * @brief Access control check to receive a System V message from the given queue 3353*a1e26a70SApple OSS Distributions * @param cred The credential of the caller 3354*a1e26a70SApple OSS Distributions * @param msqptr The message queue to receive from 3355*a1e26a70SApple OSS Distributions * @param msqlabel The message queue's label 3356*a1e26a70SApple OSS Distributions * 3357*a1e26a70SApple OSS Distributions * On a call to msgrcv(), this check is performed to determine whether the 3358*a1e26a70SApple OSS Distributions * caller has receive rights on the given queue. 3359*a1e26a70SApple OSS Distributions * 3360*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3361*a1e26a70SApple OSS Distributions * errno should be returned. 3362*a1e26a70SApple OSS Distributions */ 3363*a1e26a70SApple OSS Distributions typedef int mpo_sysvmsq_check_msqrcv_t( 3364*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3365*a1e26a70SApple OSS Distributions struct msqid_kernel *msqptr, 3366*a1e26a70SApple OSS Distributions struct label *msqlabel 3367*a1e26a70SApple OSS Distributions ); 3368*a1e26a70SApple OSS Distributions /** 3369*a1e26a70SApple OSS Distributions * @brief Access control check to send a System V message to the given queue 3370*a1e26a70SApple OSS Distributions * @param cred The credential of the caller 3371*a1e26a70SApple OSS Distributions * @param msqptr The message queue to send to 3372*a1e26a70SApple OSS Distributions * @param msqlabel The message queue's label 3373*a1e26a70SApple OSS Distributions * 3374*a1e26a70SApple OSS Distributions * On a call to msgsnd(), this check is performed to determine whether the 3375*a1e26a70SApple OSS Distributions * caller has send rights on the given queue. 3376*a1e26a70SApple OSS Distributions * 3377*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3378*a1e26a70SApple OSS Distributions * errno should be returned. 3379*a1e26a70SApple OSS Distributions */ 3380*a1e26a70SApple OSS Distributions typedef int mpo_sysvmsq_check_msqsnd_t( 3381*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3382*a1e26a70SApple OSS Distributions struct msqid_kernel *msqptr, 3383*a1e26a70SApple OSS Distributions struct label *msqlabel 3384*a1e26a70SApple OSS Distributions ); 3385*a1e26a70SApple OSS Distributions /** 3386*a1e26a70SApple OSS Distributions * @brief Create a System V message queue label 3387*a1e26a70SApple OSS Distributions * @param cred Subject credential 3388*a1e26a70SApple OSS Distributions * @param msqptr The message queue 3389*a1e26a70SApple OSS Distributions * @param msqlabel The label of the message queue 3390*a1e26a70SApple OSS Distributions * 3391*a1e26a70SApple OSS Distributions */ 3392*a1e26a70SApple OSS Distributions typedef void mpo_sysvmsq_label_associate_t( 3393*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3394*a1e26a70SApple OSS Distributions struct msqid_kernel *msqptr, 3395*a1e26a70SApple OSS Distributions struct label *msqlabel 3396*a1e26a70SApple OSS Distributions ); 3397*a1e26a70SApple OSS Distributions /** 3398*a1e26a70SApple OSS Distributions * @brief Destroy System V message queue label 3399*a1e26a70SApple OSS Distributions * @param label The label to be destroyed 3400*a1e26a70SApple OSS Distributions * 3401*a1e26a70SApple OSS Distributions * Destroy a System V message queue label. Since the object is 3402*a1e26a70SApple OSS Distributions * going out of scope, policy modules should free any internal storage 3403*a1e26a70SApple OSS Distributions * associated with the label so that it may be destroyed. 3404*a1e26a70SApple OSS Distributions */ 3405*a1e26a70SApple OSS Distributions typedef void mpo_sysvmsq_label_destroy_t( 3406*a1e26a70SApple OSS Distributions struct label *label 3407*a1e26a70SApple OSS Distributions ); 3408*a1e26a70SApple OSS Distributions /** 3409*a1e26a70SApple OSS Distributions * @brief Initialize System V message queue label 3410*a1e26a70SApple OSS Distributions * @param label New label to initialize 3411*a1e26a70SApple OSS Distributions * 3412*a1e26a70SApple OSS Distributions * Initialize the label for a newly instantiated System V message queue. 3413*a1e26a70SApple OSS Distributions */ 3414*a1e26a70SApple OSS Distributions typedef void mpo_sysvmsq_label_init_t( 3415*a1e26a70SApple OSS Distributions struct label *label 3416*a1e26a70SApple OSS Distributions ); 3417*a1e26a70SApple OSS Distributions /** 3418*a1e26a70SApple OSS Distributions * @brief Clean up a System V message queue label 3419*a1e26a70SApple OSS Distributions * @param label The label to be destroyed 3420*a1e26a70SApple OSS Distributions * 3421*a1e26a70SApple OSS Distributions * Clean up a System V message queue label. Darwin pre-allocates 3422*a1e26a70SApple OSS Distributions * message queues at system boot time and re-uses them rather than 3423*a1e26a70SApple OSS Distributions * allocating new ones. Before message queues are returned to the "free 3424*a1e26a70SApple OSS Distributions * pool", policies can cleanup or overwrite any information present in 3425*a1e26a70SApple OSS Distributions * the label. 3426*a1e26a70SApple OSS Distributions */ 3427*a1e26a70SApple OSS Distributions typedef void mpo_sysvmsq_label_recycle_t( 3428*a1e26a70SApple OSS Distributions struct label *label 3429*a1e26a70SApple OSS Distributions ); 3430*a1e26a70SApple OSS Distributions /** 3431*a1e26a70SApple OSS Distributions * @brief Access control check for System V semaphore control operation 3432*a1e26a70SApple OSS Distributions * @param cred Subject credential 3433*a1e26a70SApple OSS Distributions * @param semakptr Pointer to semaphore identifier 3434*a1e26a70SApple OSS Distributions * @param semaklabel Label associated with semaphore 3435*a1e26a70SApple OSS Distributions * @param cmd Control operation to be performed; see semctl(2) 3436*a1e26a70SApple OSS Distributions * 3437*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 3438*a1e26a70SApple OSS Distributions * the operation indicated by cmd on the System V semaphore semakptr. 3439*a1e26a70SApple OSS Distributions * 3440*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3441*a1e26a70SApple OSS Distributions * errno should be returned. 3442*a1e26a70SApple OSS Distributions */ 3443*a1e26a70SApple OSS Distributions typedef int mpo_sysvsem_check_semctl_t( 3444*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3445*a1e26a70SApple OSS Distributions struct semid_kernel *semakptr, 3446*a1e26a70SApple OSS Distributions struct label *semaklabel, 3447*a1e26a70SApple OSS Distributions int cmd 3448*a1e26a70SApple OSS Distributions ); 3449*a1e26a70SApple OSS Distributions /** 3450*a1e26a70SApple OSS Distributions * @brief Access control check for obtaining a System V semaphore 3451*a1e26a70SApple OSS Distributions * @param cred Subject credential 3452*a1e26a70SApple OSS Distributions * @param semakptr Pointer to semaphore identifier 3453*a1e26a70SApple OSS Distributions * @param semaklabel Label to associate with the semaphore 3454*a1e26a70SApple OSS Distributions * 3455*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 3456*a1e26a70SApple OSS Distributions * obtain a System V semaphore. 3457*a1e26a70SApple OSS Distributions * 3458*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3459*a1e26a70SApple OSS Distributions * errno should be returned. 3460*a1e26a70SApple OSS Distributions */ 3461*a1e26a70SApple OSS Distributions typedef int mpo_sysvsem_check_semget_t( 3462*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3463*a1e26a70SApple OSS Distributions struct semid_kernel *semakptr, 3464*a1e26a70SApple OSS Distributions struct label *semaklabel 3465*a1e26a70SApple OSS Distributions ); 3466*a1e26a70SApple OSS Distributions /** 3467*a1e26a70SApple OSS Distributions * @brief Access control check for System V semaphore operations 3468*a1e26a70SApple OSS Distributions * @param cred Subject credential 3469*a1e26a70SApple OSS Distributions * @param semakptr Pointer to semaphore identifier 3470*a1e26a70SApple OSS Distributions * @param semaklabel Label associated with the semaphore 3471*a1e26a70SApple OSS Distributions * @param accesstype Flags to indicate access (read and/or write) 3472*a1e26a70SApple OSS Distributions * 3473*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 3474*a1e26a70SApple OSS Distributions * perform the operations on the System V semaphore indicated by 3475*a1e26a70SApple OSS Distributions * semakptr. The accesstype flags hold the maximum set of permissions 3476*a1e26a70SApple OSS Distributions * from the sem_op array passed to the semop system call. It may 3477*a1e26a70SApple OSS Distributions * contain SEM_R for read-only operations or SEM_A for read/write 3478*a1e26a70SApple OSS Distributions * operations. 3479*a1e26a70SApple OSS Distributions * 3480*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3481*a1e26a70SApple OSS Distributions * errno should be returned. 3482*a1e26a70SApple OSS Distributions */ 3483*a1e26a70SApple OSS Distributions typedef int mpo_sysvsem_check_semop_t( 3484*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3485*a1e26a70SApple OSS Distributions struct semid_kernel *semakptr, 3486*a1e26a70SApple OSS Distributions struct label *semaklabel, 3487*a1e26a70SApple OSS Distributions size_t accesstype 3488*a1e26a70SApple OSS Distributions ); 3489*a1e26a70SApple OSS Distributions /** 3490*a1e26a70SApple OSS Distributions * @brief Create a System V semaphore label 3491*a1e26a70SApple OSS Distributions * @param cred Subject credential 3492*a1e26a70SApple OSS Distributions * @param semakptr The semaphore being created 3493*a1e26a70SApple OSS Distributions * @param semalabel Label to associate with the new semaphore 3494*a1e26a70SApple OSS Distributions * 3495*a1e26a70SApple OSS Distributions * Label a new System V semaphore. The label was previously 3496*a1e26a70SApple OSS Distributions * initialized and associated with the semaphore. At this time, an 3497*a1e26a70SApple OSS Distributions * appropriate initial label value should be assigned to the object and 3498*a1e26a70SApple OSS Distributions * stored in semalabel. 3499*a1e26a70SApple OSS Distributions */ 3500*a1e26a70SApple OSS Distributions typedef void mpo_sysvsem_label_associate_t( 3501*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3502*a1e26a70SApple OSS Distributions struct semid_kernel *semakptr, 3503*a1e26a70SApple OSS Distributions struct label *semalabel 3504*a1e26a70SApple OSS Distributions ); 3505*a1e26a70SApple OSS Distributions /** 3506*a1e26a70SApple OSS Distributions * @brief Destroy System V semaphore label 3507*a1e26a70SApple OSS Distributions * @param label The label to be destroyed 3508*a1e26a70SApple OSS Distributions * 3509*a1e26a70SApple OSS Distributions * Destroy a System V semaphore label. Since the object is 3510*a1e26a70SApple OSS Distributions * going out of scope, policy modules should free any internal storage 3511*a1e26a70SApple OSS Distributions * associated with the label so that it may be destroyed. 3512*a1e26a70SApple OSS Distributions */ 3513*a1e26a70SApple OSS Distributions typedef void mpo_sysvsem_label_destroy_t( 3514*a1e26a70SApple OSS Distributions struct label *label 3515*a1e26a70SApple OSS Distributions ); 3516*a1e26a70SApple OSS Distributions /** 3517*a1e26a70SApple OSS Distributions * @brief Initialize System V semaphore label 3518*a1e26a70SApple OSS Distributions * @param label New label to initialize 3519*a1e26a70SApple OSS Distributions * 3520*a1e26a70SApple OSS Distributions * Initialize the label for a newly instantiated System V semaphore. Sleeping 3521*a1e26a70SApple OSS Distributions * is permitted. 3522*a1e26a70SApple OSS Distributions */ 3523*a1e26a70SApple OSS Distributions typedef void mpo_sysvsem_label_init_t( 3524*a1e26a70SApple OSS Distributions struct label *label 3525*a1e26a70SApple OSS Distributions ); 3526*a1e26a70SApple OSS Distributions /** 3527*a1e26a70SApple OSS Distributions * @brief Clean up a System V semaphore label 3528*a1e26a70SApple OSS Distributions * @param label The label to be cleaned 3529*a1e26a70SApple OSS Distributions * 3530*a1e26a70SApple OSS Distributions * Clean up a System V semaphore label. Darwin pre-allocates 3531*a1e26a70SApple OSS Distributions * semaphores at system boot time and re-uses them rather than 3532*a1e26a70SApple OSS Distributions * allocating new ones. Before semaphores are returned to the "free 3533*a1e26a70SApple OSS Distributions * pool", policies can cleanup or overwrite any information present in 3534*a1e26a70SApple OSS Distributions * the label. 3535*a1e26a70SApple OSS Distributions */ 3536*a1e26a70SApple OSS Distributions typedef void mpo_sysvsem_label_recycle_t( 3537*a1e26a70SApple OSS Distributions struct label *label 3538*a1e26a70SApple OSS Distributions ); 3539*a1e26a70SApple OSS Distributions /** 3540*a1e26a70SApple OSS Distributions * @brief Access control check for mapping System V shared memory 3541*a1e26a70SApple OSS Distributions * @param cred Subject credential 3542*a1e26a70SApple OSS Distributions * @param shmsegptr Pointer to shared memory segment identifier 3543*a1e26a70SApple OSS Distributions * @param shmseglabel Label associated with the shared memory segment 3544*a1e26a70SApple OSS Distributions * @param shmflg shmat flags; see shmat(2) 3545*a1e26a70SApple OSS Distributions * 3546*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can map 3547*a1e26a70SApple OSS Distributions * the System V shared memory segment associated with shmsegptr. 3548*a1e26a70SApple OSS Distributions * 3549*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3550*a1e26a70SApple OSS Distributions * errno should be returned. 3551*a1e26a70SApple OSS Distributions */ 3552*a1e26a70SApple OSS Distributions typedef int mpo_sysvshm_check_shmat_t( 3553*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3554*a1e26a70SApple OSS Distributions struct shmid_kernel *shmsegptr, 3555*a1e26a70SApple OSS Distributions struct label *shmseglabel, 3556*a1e26a70SApple OSS Distributions int shmflg 3557*a1e26a70SApple OSS Distributions ); 3558*a1e26a70SApple OSS Distributions /** 3559*a1e26a70SApple OSS Distributions * @brief Access control check for System V shared memory control operation 3560*a1e26a70SApple OSS Distributions * @param cred Subject credential 3561*a1e26a70SApple OSS Distributions * @param shmsegptr Pointer to shared memory segment identifier 3562*a1e26a70SApple OSS Distributions * @param shmseglabel Label associated with the shared memory segment 3563*a1e26a70SApple OSS Distributions * @param cmd Control operation to be performed; see shmctl(2) 3564*a1e26a70SApple OSS Distributions * 3565*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 3566*a1e26a70SApple OSS Distributions * the operation indicated by cmd on the System V shared memory segment 3567*a1e26a70SApple OSS Distributions * shmsegptr. 3568*a1e26a70SApple OSS Distributions * 3569*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3570*a1e26a70SApple OSS Distributions * errno should be returned. 3571*a1e26a70SApple OSS Distributions */ 3572*a1e26a70SApple OSS Distributions typedef int mpo_sysvshm_check_shmctl_t( 3573*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3574*a1e26a70SApple OSS Distributions struct shmid_kernel *shmsegptr, 3575*a1e26a70SApple OSS Distributions struct label *shmseglabel, 3576*a1e26a70SApple OSS Distributions int cmd 3577*a1e26a70SApple OSS Distributions ); 3578*a1e26a70SApple OSS Distributions /** 3579*a1e26a70SApple OSS Distributions * @brief Access control check for unmapping System V shared memory 3580*a1e26a70SApple OSS Distributions * @param cred Subject credential 3581*a1e26a70SApple OSS Distributions * @param shmsegptr Pointer to shared memory segment identifier 3582*a1e26a70SApple OSS Distributions * @param shmseglabel Label associated with the shared memory segment 3583*a1e26a70SApple OSS Distributions * 3584*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can unmap 3585*a1e26a70SApple OSS Distributions * the System V shared memory segment associated with shmsegptr. 3586*a1e26a70SApple OSS Distributions * 3587*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3588*a1e26a70SApple OSS Distributions * errno should be returned. 3589*a1e26a70SApple OSS Distributions */ 3590*a1e26a70SApple OSS Distributions typedef int mpo_sysvshm_check_shmdt_t( 3591*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3592*a1e26a70SApple OSS Distributions struct shmid_kernel *shmsegptr, 3593*a1e26a70SApple OSS Distributions struct label *shmseglabel 3594*a1e26a70SApple OSS Distributions ); 3595*a1e26a70SApple OSS Distributions /** 3596*a1e26a70SApple OSS Distributions * @brief Access control check obtaining System V shared memory identifier 3597*a1e26a70SApple OSS Distributions * @param cred Subject credential 3598*a1e26a70SApple OSS Distributions * @param shmsegptr Pointer to shared memory segment identifier 3599*a1e26a70SApple OSS Distributions * @param shmseglabel Label associated with the shared memory segment 3600*a1e26a70SApple OSS Distributions * @param shmflg shmget flags; see shmget(2) 3601*a1e26a70SApple OSS Distributions * 3602*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can get 3603*a1e26a70SApple OSS Distributions * the System V shared memory segment address. 3604*a1e26a70SApple OSS Distributions * 3605*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3606*a1e26a70SApple OSS Distributions * errno should be returned. 3607*a1e26a70SApple OSS Distributions */ 3608*a1e26a70SApple OSS Distributions typedef int mpo_sysvshm_check_shmget_t( 3609*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3610*a1e26a70SApple OSS Distributions struct shmid_kernel *shmsegptr, 3611*a1e26a70SApple OSS Distributions struct label *shmseglabel, 3612*a1e26a70SApple OSS Distributions int shmflg 3613*a1e26a70SApple OSS Distributions ); 3614*a1e26a70SApple OSS Distributions /** 3615*a1e26a70SApple OSS Distributions * @brief Create a System V shared memory region label 3616*a1e26a70SApple OSS Distributions * @param cred Subject credential 3617*a1e26a70SApple OSS Distributions * @param shmsegptr The shared memory region being created 3618*a1e26a70SApple OSS Distributions * @param shmlabel Label to associate with the new shared memory region 3619*a1e26a70SApple OSS Distributions * 3620*a1e26a70SApple OSS Distributions * Label a new System V shared memory region. The label was previously 3621*a1e26a70SApple OSS Distributions * initialized and associated with the shared memory region. At this 3622*a1e26a70SApple OSS Distributions * time, an appropriate initial label value should be assigned to the 3623*a1e26a70SApple OSS Distributions * object and stored in shmlabel. 3624*a1e26a70SApple OSS Distributions */ 3625*a1e26a70SApple OSS Distributions typedef void mpo_sysvshm_label_associate_t( 3626*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3627*a1e26a70SApple OSS Distributions struct shmid_kernel *shmsegptr, 3628*a1e26a70SApple OSS Distributions struct label *shmlabel 3629*a1e26a70SApple OSS Distributions ); 3630*a1e26a70SApple OSS Distributions /** 3631*a1e26a70SApple OSS Distributions * @brief Destroy System V shared memory label 3632*a1e26a70SApple OSS Distributions * @param label The label to be destroyed 3633*a1e26a70SApple OSS Distributions * 3634*a1e26a70SApple OSS Distributions * Destroy a System V shared memory region label. Since the 3635*a1e26a70SApple OSS Distributions * object is going out of scope, policy modules should free any 3636*a1e26a70SApple OSS Distributions * internal storage associated with the label so that it may be 3637*a1e26a70SApple OSS Distributions * destroyed. 3638*a1e26a70SApple OSS Distributions */ 3639*a1e26a70SApple OSS Distributions typedef void mpo_sysvshm_label_destroy_t( 3640*a1e26a70SApple OSS Distributions struct label *label 3641*a1e26a70SApple OSS Distributions ); 3642*a1e26a70SApple OSS Distributions /** 3643*a1e26a70SApple OSS Distributions * @brief Initialize System V Shared Memory region label 3644*a1e26a70SApple OSS Distributions * @param label New label to initialize 3645*a1e26a70SApple OSS Distributions * 3646*a1e26a70SApple OSS Distributions * Initialize the label for a newly instantiated System V Shared Memory 3647*a1e26a70SApple OSS Distributions * region. Sleeping is permitted. 3648*a1e26a70SApple OSS Distributions */ 3649*a1e26a70SApple OSS Distributions typedef void mpo_sysvshm_label_init_t( 3650*a1e26a70SApple OSS Distributions struct label *label 3651*a1e26a70SApple OSS Distributions ); 3652*a1e26a70SApple OSS Distributions /** 3653*a1e26a70SApple OSS Distributions * @brief Clean up a System V Share Memory Region label 3654*a1e26a70SApple OSS Distributions * @param shmlabel The label to be cleaned 3655*a1e26a70SApple OSS Distributions * 3656*a1e26a70SApple OSS Distributions * Clean up a System V Shared Memory Region label. Darwin 3657*a1e26a70SApple OSS Distributions * pre-allocates these objects at system boot time and re-uses them 3658*a1e26a70SApple OSS Distributions * rather than allocating new ones. Before the memory regions are 3659*a1e26a70SApple OSS Distributions * returned to the "free pool", policies can cleanup or overwrite any 3660*a1e26a70SApple OSS Distributions * information present in the label. 3661*a1e26a70SApple OSS Distributions */ 3662*a1e26a70SApple OSS Distributions typedef void mpo_sysvshm_label_recycle_t( 3663*a1e26a70SApple OSS Distributions struct label *shmlabel 3664*a1e26a70SApple OSS Distributions ); 3665*a1e26a70SApple OSS Distributions 3666*a1e26a70SApple OSS Distributions /** 3667*a1e26a70SApple OSS Distributions * @brief Access control check for getting a process's task ports of different flavors 3668*a1e26a70SApple OSS Distributions * @param cred Subject credential 3669*a1e26a70SApple OSS Distributions * @param pident Object unique process identifier 3670*a1e26a70SApple OSS Distributions * @param flavor Requested task port flavor 3671*a1e26a70SApple OSS Distributions * 3672*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can get 3673*a1e26a70SApple OSS Distributions * the passed process's task port of given flavor. 3674*a1e26a70SApple OSS Distributions * This call is used by the task_{,read,inspect,name}_for_pid(2) API. 3675*a1e26a70SApple OSS Distributions * 3676*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3677*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch, 3678*a1e26a70SApple OSS Distributions * EPERM for lack of privilege, or ESRCH to hide visibility of the target. 3679*a1e26a70SApple OSS Distributions */ 3680*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_get_task_with_flavor_t( 3681*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3682*a1e26a70SApple OSS Distributions struct proc_ident *pident, 3683*a1e26a70SApple OSS Distributions mach_task_flavor_t flavor 3684*a1e26a70SApple OSS Distributions ); 3685*a1e26a70SApple OSS Distributions 3686*a1e26a70SApple OSS Distributions /** 3687*a1e26a70SApple OSS Distributions * @brief Access control check for exposing a process's task ports of different flavors 3688*a1e26a70SApple OSS Distributions * @param cred Subject credential 3689*a1e26a70SApple OSS Distributions * @param pident Object unique process identifier 3690*a1e26a70SApple OSS Distributions * @param flavor Requested task port flavor 3691*a1e26a70SApple OSS Distributions * 3692*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can expose 3693*a1e26a70SApple OSS Distributions * the passed process's task port of given flavor. 3694*a1e26a70SApple OSS Distributions * This call is used by the accessor APIs like processor_set_tasks() and 3695*a1e26a70SApple OSS Distributions * processor_set_threads(). 3696*a1e26a70SApple OSS Distributions * 3697*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3698*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch, 3699*a1e26a70SApple OSS Distributions * EPERM for lack of privilege, or ESRCH to hide visibility of the target. 3700*a1e26a70SApple OSS Distributions */ 3701*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_expose_task_with_flavor_t( 3702*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3703*a1e26a70SApple OSS Distributions struct proc_ident *pident, 3704*a1e26a70SApple OSS Distributions mach_task_flavor_t flavor 3705*a1e26a70SApple OSS Distributions ); 3706*a1e26a70SApple OSS Distributions 3707*a1e26a70SApple OSS Distributions /** 3708*a1e26a70SApple OSS Distributions * @brief Access control check for upgrading to task port with a task identity token 3709*a1e26a70SApple OSS Distributions * @param cred Subject credential 3710*a1e26a70SApple OSS Distributions * @param pident Object unique process identifier, NULL if token represents a corpse task 3711*a1e26a70SApple OSS Distributions * @param flavor Requested task port flavor 3712*a1e26a70SApple OSS Distributions * 3713*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can upgrade to task port 3714*a1e26a70SApple OSS Distributions * of given flavor with a task identity token of the passed process. 3715*a1e26a70SApple OSS Distributions * This call is used by task_identity_token_get_task_port(). 3716*a1e26a70SApple OSS Distributions * 3717*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3718*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch, 3719*a1e26a70SApple OSS Distributions * EPERM for lack of privilege, or ESRCH to hide visibility of the target. 3720*a1e26a70SApple OSS Distributions */ 3721*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_task_id_token_get_task_t( 3722*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3723*a1e26a70SApple OSS Distributions struct proc_ident *pident, /* Nullable */ 3724*a1e26a70SApple OSS Distributions mach_task_flavor_t flavor 3725*a1e26a70SApple OSS Distributions ); 3726*a1e26a70SApple OSS Distributions 3727*a1e26a70SApple OSS Distributions /** 3728*a1e26a70SApple OSS Distributions * @brief Check whether task's IPC may inherit across process exec 3729*a1e26a70SApple OSS Distributions * @param p current process instance 3730*a1e26a70SApple OSS Distributions * @param cur_vp vnode pointer to current instance 3731*a1e26a70SApple OSS Distributions * @param cur_offset offset of binary of currently executing image 3732*a1e26a70SApple OSS Distributions * @param img_vp vnode pointer to to be exec'ed image 3733*a1e26a70SApple OSS Distributions * @param img_offset offset into file which is selected for execution 3734*a1e26a70SApple OSS Distributions * @param scriptvp vnode pointer of script file if any. 3735*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted. 3736*a1e26a70SApple OSS Distributions * EPERM if parent does not have any entitlements. 3737*a1e26a70SApple OSS Distributions * EACCESS if mismatch in entitlements 3738*a1e26a70SApple OSS Distributions */ 3739*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_inherit_ipc_ports_t( 3740*a1e26a70SApple OSS Distributions struct proc *p, 3741*a1e26a70SApple OSS Distributions struct vnode *cur_vp, 3742*a1e26a70SApple OSS Distributions off_t cur_offset, 3743*a1e26a70SApple OSS Distributions struct vnode *img_vp, 3744*a1e26a70SApple OSS Distributions off_t img_offset, 3745*a1e26a70SApple OSS Distributions struct vnode *scriptvp 3746*a1e26a70SApple OSS Distributions ); 3747*a1e26a70SApple OSS Distributions 3748*a1e26a70SApple OSS Distributions /** 3749*a1e26a70SApple OSS Distributions * @brief Privilege check for a process to run invalid 3750*a1e26a70SApple OSS Distributions * @param p Object process 3751*a1e26a70SApple OSS Distributions * 3752*a1e26a70SApple OSS Distributions * Determine whether the process may execute even though the system determined 3753*a1e26a70SApple OSS Distributions * that it is untrusted (eg unidentified / modified code). 3754*a1e26a70SApple OSS Distributions * 3755*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3756*a1e26a70SApple OSS Distributions * errno should be returned. 3757*a1e26a70SApple OSS Distributions */ 3758*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_run_cs_invalid_t( 3759*a1e26a70SApple OSS Distributions struct proc *p 3760*a1e26a70SApple OSS Distributions ); 3761*a1e26a70SApple OSS Distributions 3762*a1e26a70SApple OSS Distributions /** 3763*a1e26a70SApple OSS Distributions * @brief Notification a process was invalidated 3764*a1e26a70SApple OSS Distributions * @param p Object process 3765*a1e26a70SApple OSS Distributions * 3766*a1e26a70SApple OSS Distributions * Notifies that the CS_VALID bit was removed from a process' csflags. This 3767*a1e26a70SApple OSS Distributions * either indicates that a validly code-signed process has encountered an 3768*a1e26a70SApple OSS Distributions * invalidly code-signed page for the first time, or that it was explicitly 3769*a1e26a70SApple OSS Distributions * marked invalid via a csops(CS_OPS_MARKINVALID) syscall. 3770*a1e26a70SApple OSS Distributions * 3771*a1e26a70SApple OSS Distributions * @warning This hook can be called from the page fault handler; it should not 3772*a1e26a70SApple OSS Distributions * perform any operations that may result in paging, and stack space is extremely 3773*a1e26a70SApple OSS Distributions * limited. Furthermore, the hook is called with proc lock held, and if called 3774*a1e26a70SApple OSS Distributions * from the fault handler, with vm object lock held. Consumers reacting to this 3775*a1e26a70SApple OSS Distributions * hook being called are expected to defer processing to a userret, possibly 3776*a1e26a70SApple OSS Distributions * after suspending the task. 3777*a1e26a70SApple OSS Distributions */ 3778*a1e26a70SApple OSS Distributions typedef void mpo_proc_notify_cs_invalidated_t( 3779*a1e26a70SApple OSS Distributions struct proc *p 3780*a1e26a70SApple OSS Distributions ); 3781*a1e26a70SApple OSS Distributions 3782*a1e26a70SApple OSS Distributions /** 3783*a1e26a70SApple OSS Distributions * @brief Notification a process is finished with exec and will jump to userspace 3784*a1e26a70SApple OSS Distributions * @param p Object process 3785*a1e26a70SApple OSS Distributions * 3786*a1e26a70SApple OSS Distributions * Notifies all MAC policies that a process has completed an exec and is about to 3787*a1e26a70SApple OSS Distributions * jump to userspace to continue execution. This may result in process termination 3788*a1e26a70SApple OSS Distributions * via signals. Hook is designed to hold no/minimal locks so it can be used for any 3789*a1e26a70SApple OSS Distributions * necessary upcalls. 3790*a1e26a70SApple OSS Distributions */ 3791*a1e26a70SApple OSS Distributions typedef void mpo_proc_notify_exec_complete_t( 3792*a1e26a70SApple OSS Distributions struct proc *p 3793*a1e26a70SApple OSS Distributions ); 3794*a1e26a70SApple OSS Distributions 3795*a1e26a70SApple OSS Distributions /** 3796*a1e26a70SApple OSS Distributions * @brief Access control check for setting user ID 3797*a1e26a70SApple OSS Distributions * @param cred Subject credential 3798*a1e26a70SApple OSS Distributions * @param uid Requested user ID 3799*a1e26a70SApple OSS Distributions * 3800*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can set the 3801*a1e26a70SApple OSS Distributions * real and effective user ID and the saved set-user-ID of the current 3802*a1e26a70SApple OSS Distributions * process, using the setuid() system call. 3803*a1e26a70SApple OSS Distributions * 3804*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3805*a1e26a70SApple OSS Distributions * errno should be returned. 3806*a1e26a70SApple OSS Distributions */ 3807*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_setuid_t( 3808*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3809*a1e26a70SApple OSS Distributions uid_t uid 3810*a1e26a70SApple OSS Distributions ); 3811*a1e26a70SApple OSS Distributions 3812*a1e26a70SApple OSS Distributions /** 3813*a1e26a70SApple OSS Distributions * @brief Access control check for setting effective user ID 3814*a1e26a70SApple OSS Distributions * @param cred Subject credential 3815*a1e26a70SApple OSS Distributions * @param euid Requested effective user ID 3816*a1e26a70SApple OSS Distributions * 3817*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can set the 3818*a1e26a70SApple OSS Distributions * effective user ID of the current process, using the seteuid() system call. 3819*a1e26a70SApple OSS Distributions * 3820*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3821*a1e26a70SApple OSS Distributions * errno should be returned. 3822*a1e26a70SApple OSS Distributions */ 3823*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_seteuid_t( 3824*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3825*a1e26a70SApple OSS Distributions uid_t euid 3826*a1e26a70SApple OSS Distributions ); 3827*a1e26a70SApple OSS Distributions 3828*a1e26a70SApple OSS Distributions /** 3829*a1e26a70SApple OSS Distributions * @brief Access control check for setting real and effective user ID 3830*a1e26a70SApple OSS Distributions * @param cred Subject credential 3831*a1e26a70SApple OSS Distributions * @param ruid Requested real user ID 3832*a1e26a70SApple OSS Distributions * @param euid Requested effective user ID 3833*a1e26a70SApple OSS Distributions * 3834*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can set the 3835*a1e26a70SApple OSS Distributions * real and effective user ID of the current process, using the setreuid() 3836*a1e26a70SApple OSS Distributions * system call. 3837*a1e26a70SApple OSS Distributions * 3838*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3839*a1e26a70SApple OSS Distributions * errno should be returned. 3840*a1e26a70SApple OSS Distributions */ 3841*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_setreuid_t( 3842*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3843*a1e26a70SApple OSS Distributions uid_t ruid, 3844*a1e26a70SApple OSS Distributions uid_t euid 3845*a1e26a70SApple OSS Distributions ); 3846*a1e26a70SApple OSS Distributions 3847*a1e26a70SApple OSS Distributions /** 3848*a1e26a70SApple OSS Distributions * @brief Access control check for setting group ID 3849*a1e26a70SApple OSS Distributions * @param cred Subject credential 3850*a1e26a70SApple OSS Distributions * @param gid Requested group ID 3851*a1e26a70SApple OSS Distributions * 3852*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can set the 3853*a1e26a70SApple OSS Distributions * real and effective group IDs and the saved set-group-ID of the current 3854*a1e26a70SApple OSS Distributions * process, using the setgid() system call. 3855*a1e26a70SApple OSS Distributions * 3856*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3857*a1e26a70SApple OSS Distributions * errno should be returned. 3858*a1e26a70SApple OSS Distributions */ 3859*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_setgid_t( 3860*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3861*a1e26a70SApple OSS Distributions gid_t gid 3862*a1e26a70SApple OSS Distributions ); 3863*a1e26a70SApple OSS Distributions 3864*a1e26a70SApple OSS Distributions /** 3865*a1e26a70SApple OSS Distributions * @brief Access control check for setting effective group ID 3866*a1e26a70SApple OSS Distributions * @param cred Subject credential 3867*a1e26a70SApple OSS Distributions * @param egid Requested effective group ID 3868*a1e26a70SApple OSS Distributions * 3869*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can set the 3870*a1e26a70SApple OSS Distributions * effective group ID of the current process, using the setegid() system call. 3871*a1e26a70SApple OSS Distributions * 3872*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3873*a1e26a70SApple OSS Distributions * errno should be returned. 3874*a1e26a70SApple OSS Distributions */ 3875*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_setegid_t( 3876*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3877*a1e26a70SApple OSS Distributions gid_t egid 3878*a1e26a70SApple OSS Distributions ); 3879*a1e26a70SApple OSS Distributions 3880*a1e26a70SApple OSS Distributions /** 3881*a1e26a70SApple OSS Distributions * @brief Access control check for setting real and effective group ID 3882*a1e26a70SApple OSS Distributions * @param cred Subject credential 3883*a1e26a70SApple OSS Distributions * @param rgid Requested real group ID or KAUTH_UID_NONE for none 3884*a1e26a70SApple OSS Distributions * @param egid Requested effective group ID or KAUTH_GID_NONE for none 3885*a1e26a70SApple OSS Distributions * 3886*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can set the 3887*a1e26a70SApple OSS Distributions * real and effective group ID of the current process, using the setregid() 3888*a1e26a70SApple OSS Distributions * system call. 3889*a1e26a70SApple OSS Distributions * 3890*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3891*a1e26a70SApple OSS Distributions * errno should be returned. 3892*a1e26a70SApple OSS Distributions */ 3893*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_setregid_t( 3894*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3895*a1e26a70SApple OSS Distributions gid_t rgid, 3896*a1e26a70SApple OSS Distributions gid_t egid 3897*a1e26a70SApple OSS Distributions ); 3898*a1e26a70SApple OSS Distributions 3899*a1e26a70SApple OSS Distributions /** 3900*a1e26a70SApple OSS Distributions * @brief Access control check for setting thread assumed identity 3901*a1e26a70SApple OSS Distributions * @param pcred Subject process credential 3902*a1e26a70SApple OSS Distributions * @param tcred Subject thread credential 3903*a1e26a70SApple OSS Distributions * @param uid Requested user ID or KAUTH_UID_NONE for none 3904*a1e26a70SApple OSS Distributions * @param gid Requested group ID or KAUTH_GID_NONE for none 3905*a1e26a70SApple OSS Distributions * 3906*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can set the 3907*a1e26a70SApple OSS Distributions * user and group ID of the current thread, using the settid() or 3908*a1e26a70SApple OSS Distributions * settid_with_pid() system call. 3909*a1e26a70SApple OSS Distributions * 3910*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3911*a1e26a70SApple OSS Distributions * errno should be returned. 3912*a1e26a70SApple OSS Distributions */ 3913*a1e26a70SApple OSS Distributions typedef int mpo_proc_check_settid_t( 3914*a1e26a70SApple OSS Distributions kauth_cred_t pcred, 3915*a1e26a70SApple OSS Distributions kauth_cred_t tcred, 3916*a1e26a70SApple OSS Distributions uid_t uid, 3917*a1e26a70SApple OSS Distributions gid_t gid 3918*a1e26a70SApple OSS Distributions ); 3919*a1e26a70SApple OSS Distributions 3920*a1e26a70SApple OSS Distributions /** 3921*a1e26a70SApple OSS Distributions * @brief Notification of connection port derivation from service port 3922*a1e26a70SApple OSS Distributions * @param cred Subject process credential 3923*a1e26a70SApple OSS Distributions * @param sp_info Service port info 3924*a1e26a70SApple OSS Distributions * 3925*a1e26a70SApple OSS Distributions * Called when a process derives a connection port from a service port. 3926*a1e26a70SApple OSS Distributions * 3927*a1e26a70SApple OSS Distributions * Notes: 3928*a1e26a70SApple OSS Distributions * - Port derivation is only mandatory if the receiving end of the 3929*a1e26a70SApple OSS Distributions * connection performs validation of that fact. 3930*a1e26a70SApple OSS Distributions * - MAC policies should not perform upcalls or expensive operations in 3931*a1e26a70SApple OSS Distributions * this hook. 3932*a1e26a70SApple OSS Distributions * - Only called on macOS. 3933*a1e26a70SApple OSS Distributions */ 3934*a1e26a70SApple OSS Distributions typedef void mpo_proc_notify_service_port_derive_t( 3935*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3936*a1e26a70SApple OSS Distributions struct mach_service_port_info *sp_info 3937*a1e26a70SApple OSS Distributions ); 3938*a1e26a70SApple OSS Distributions 3939*a1e26a70SApple OSS Distributions /** 3940*a1e26a70SApple OSS Distributions * @brief Perform MAC-related analysis of telemetry data. 3941*a1e26a70SApple OSS Distributions * @param thread The Mach thread that was sampled. 3942*a1e26a70SApple OSS Distributions * 3943*a1e26a70SApple OSS Distributions * Notifies MAC policies that telemetry data was just collected from a 3944*a1e26a70SApple OSS Distributions * process's user thread and that it is ready to be analyzed. The analysis is 3945*a1e26a70SApple OSS Distributions * performed shortly before a thread is about to return to userspace via a 3946*a1e26a70SApple OSS Distributions * syscall or mach trap. 3947*a1e26a70SApple OSS Distributions * 3948*a1e26a70SApple OSS Distributions * Note that sometimes the scheduled telemetry can fail. In the case of 3949*a1e26a70SApple OSS Distributions * failure, the function will be called with a non-zero `err` value, in which 3950*a1e26a70SApple OSS Distributions * case it is expected that the client will cleanup any necessary state 3951*a1e26a70SApple OSS Distributions * recorded back when the telemetry was first scheduled. 3952*a1e26a70SApple OSS Distributions */ 3953*a1e26a70SApple OSS Distributions typedef void mpo_thread_telemetry_t( 3954*a1e26a70SApple OSS Distributions struct thread *thread, 3955*a1e26a70SApple OSS Distributions int err, 3956*a1e26a70SApple OSS Distributions const void *data, 3957*a1e26a70SApple OSS Distributions size_t length 3958*a1e26a70SApple OSS Distributions ); 3959*a1e26a70SApple OSS Distributions 3960*a1e26a70SApple OSS Distributions /** 3961*a1e26a70SApple OSS Distributions * @brief Perform MAC-related events when a thread returns to user space 3962*a1e26a70SApple OSS Distributions * @param thread Mach (not BSD) thread that is returning 3963*a1e26a70SApple OSS Distributions * 3964*a1e26a70SApple OSS Distributions * This entry point permits policy modules to perform MAC-related 3965*a1e26a70SApple OSS Distributions * events when a thread returns to user space, via a system call 3966*a1e26a70SApple OSS Distributions * return or trap return. 3967*a1e26a70SApple OSS Distributions */ 3968*a1e26a70SApple OSS Distributions typedef void mpo_thread_userret_t( 3969*a1e26a70SApple OSS Distributions struct thread *thread 3970*a1e26a70SApple OSS Distributions ); 3971*a1e26a70SApple OSS Distributions 3972*a1e26a70SApple OSS Distributions /** 3973*a1e26a70SApple OSS Distributions * @brief Check vnode access 3974*a1e26a70SApple OSS Distributions * @param cred Subject credential 3975*a1e26a70SApple OSS Distributions * @param vp Object vnode 3976*a1e26a70SApple OSS Distributions * @param label Label for vp 3977*a1e26a70SApple OSS Distributions * @param acc_mode access(2) flags 3978*a1e26a70SApple OSS Distributions * 3979*a1e26a70SApple OSS Distributions * Determine how invocations of access(2) and related calls by the 3980*a1e26a70SApple OSS Distributions * subject identified by the credential should return when performed 3981*a1e26a70SApple OSS Distributions * on the passed vnode using the passed access flags. This should 3982*a1e26a70SApple OSS Distributions * generally be implemented using the same semantics used in 3983*a1e26a70SApple OSS Distributions * mpo_vnode_check_open. 3984*a1e26a70SApple OSS Distributions * 3985*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 3986*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 3987*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 3988*a1e26a70SApple OSS Distributions */ 3989*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_access_t( 3990*a1e26a70SApple OSS Distributions kauth_cred_t cred, 3991*a1e26a70SApple OSS Distributions struct vnode *vp, 3992*a1e26a70SApple OSS Distributions struct label *label, 3993*a1e26a70SApple OSS Distributions int acc_mode 3994*a1e26a70SApple OSS Distributions ); 3995*a1e26a70SApple OSS Distributions /** 3996*a1e26a70SApple OSS Distributions * @brief Access control check for changing working directory 3997*a1e26a70SApple OSS Distributions * @param cred Subject credential 3998*a1e26a70SApple OSS Distributions * @param dvp Object; vnode to chdir(2) into 3999*a1e26a70SApple OSS Distributions * @param dlabel Policy label for dvp 4000*a1e26a70SApple OSS Distributions * 4001*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can change 4002*a1e26a70SApple OSS Distributions * the process working directory to the passed vnode. 4003*a1e26a70SApple OSS Distributions * 4004*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4005*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4006*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4007*a1e26a70SApple OSS Distributions */ 4008*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_chdir_t( 4009*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4010*a1e26a70SApple OSS Distributions struct vnode *dvp, 4011*a1e26a70SApple OSS Distributions struct label *dlabel 4012*a1e26a70SApple OSS Distributions ); 4013*a1e26a70SApple OSS Distributions /** 4014*a1e26a70SApple OSS Distributions * @brief Access control check for changing root directory 4015*a1e26a70SApple OSS Distributions * @param cred Subject credential 4016*a1e26a70SApple OSS Distributions * @param dvp Directory vnode 4017*a1e26a70SApple OSS Distributions * @param dlabel Policy label associated with dvp 4018*a1e26a70SApple OSS Distributions * @param cnp Component name for dvp 4019*a1e26a70SApple OSS Distributions * 4020*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 4021*a1e26a70SApple OSS Distributions * allowed to chroot(2) into the specified directory (dvp). 4022*a1e26a70SApple OSS Distributions * 4023*a1e26a70SApple OSS Distributions * @return In the event of an error, an appropriate value for errno 4024*a1e26a70SApple OSS Distributions * should be returned, otherwise return 0 upon success. 4025*a1e26a70SApple OSS Distributions */ 4026*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_chroot_t( 4027*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4028*a1e26a70SApple OSS Distributions struct vnode *dvp, 4029*a1e26a70SApple OSS Distributions struct label *dlabel, 4030*a1e26a70SApple OSS Distributions struct componentname *cnp 4031*a1e26a70SApple OSS Distributions ); 4032*a1e26a70SApple OSS Distributions /** 4033*a1e26a70SApple OSS Distributions * @brief Access control check for creating clone 4034*a1e26a70SApple OSS Distributions * @param cred Subject credential 4035*a1e26a70SApple OSS Distributions * @param dvp Vnode of directory to create the clone in 4036*a1e26a70SApple OSS Distributions * @param dlabel Policy label associated with dvp 4037*a1e26a70SApple OSS Distributions * @param vp Vnode of the file to clone from 4038*a1e26a70SApple OSS Distributions * @param label Policy label associated with vp 4039*a1e26a70SApple OSS Distributions * @param cnp Component name for the clone being created 4040*a1e26a70SApple OSS Distributions * 4041*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 4042*a1e26a70SApple OSS Distributions * allowed to create a clone of the vnode vp with the name specified by cnp. 4043*a1e26a70SApple OSS Distributions * 4044*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4045*a1e26a70SApple OSS Distributions * errno should be returned. 4046*a1e26a70SApple OSS Distributions */ 4047*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_clone_t( 4048*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4049*a1e26a70SApple OSS Distributions struct vnode *dvp, 4050*a1e26a70SApple OSS Distributions struct label *dlabel, 4051*a1e26a70SApple OSS Distributions struct vnode *vp, 4052*a1e26a70SApple OSS Distributions struct label *label, 4053*a1e26a70SApple OSS Distributions struct componentname *cnp 4054*a1e26a70SApple OSS Distributions ); 4055*a1e26a70SApple OSS Distributions /** 4056*a1e26a70SApple OSS Distributions * @brief Access control check for creating vnode 4057*a1e26a70SApple OSS Distributions * @param cred Subject credential 4058*a1e26a70SApple OSS Distributions * @param dvp Directory vnode 4059*a1e26a70SApple OSS Distributions * @param dlabel Policy label for dvp 4060*a1e26a70SApple OSS Distributions * @param cnp Component name for dvp 4061*a1e26a70SApple OSS Distributions * @param vap vnode attributes for vap 4062*a1e26a70SApple OSS Distributions * 4063*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can create 4064*a1e26a70SApple OSS Distributions * a vnode with the passed parent directory, passed name information, 4065*a1e26a70SApple OSS Distributions * and passed attribute information. This call may be made in a number of 4066*a1e26a70SApple OSS Distributions * situations, including as a result of calls to open(2) with O_CREAT, 4067*a1e26a70SApple OSS Distributions * mknod(2), mkfifo(2), and others. 4068*a1e26a70SApple OSS Distributions * 4069*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4070*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4071*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4072*a1e26a70SApple OSS Distributions */ 4073*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_create_t( 4074*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4075*a1e26a70SApple OSS Distributions struct vnode *dvp, 4076*a1e26a70SApple OSS Distributions struct label *dlabel, 4077*a1e26a70SApple OSS Distributions struct componentname *cnp, 4078*a1e26a70SApple OSS Distributions struct vnode_attr *vap 4079*a1e26a70SApple OSS Distributions ); 4080*a1e26a70SApple OSS Distributions /** 4081*a1e26a70SApple OSS Distributions * @brief Access control check for deleting extended attribute 4082*a1e26a70SApple OSS Distributions * @param cred Subject credential 4083*a1e26a70SApple OSS Distributions * @param vp Object vnode 4084*a1e26a70SApple OSS Distributions * @param vlabel Label associated with vp 4085*a1e26a70SApple OSS Distributions * @param name Extended attribute name 4086*a1e26a70SApple OSS Distributions * 4087*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can delete 4088*a1e26a70SApple OSS Distributions * the extended attribute from the passed vnode. 4089*a1e26a70SApple OSS Distributions * 4090*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4091*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4092*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4093*a1e26a70SApple OSS Distributions */ 4094*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_deleteextattr_t( 4095*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4096*a1e26a70SApple OSS Distributions struct vnode *vp, 4097*a1e26a70SApple OSS Distributions struct label *vlabel, 4098*a1e26a70SApple OSS Distributions const char *name 4099*a1e26a70SApple OSS Distributions ); 4100*a1e26a70SApple OSS Distributions /** 4101*a1e26a70SApple OSS Distributions * @brief Access control check for exchanging file data 4102*a1e26a70SApple OSS Distributions * @param cred Subject credential 4103*a1e26a70SApple OSS Distributions * @param v1 vnode 1 to swap 4104*a1e26a70SApple OSS Distributions * @param vl1 Policy label for v1 4105*a1e26a70SApple OSS Distributions * @param v2 vnode 2 to swap 4106*a1e26a70SApple OSS Distributions * @param vl2 Policy label for v2 4107*a1e26a70SApple OSS Distributions * 4108*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can swap the data 4109*a1e26a70SApple OSS Distributions * in the two supplied vnodes. 4110*a1e26a70SApple OSS Distributions * 4111*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4112*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4113*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4114*a1e26a70SApple OSS Distributions */ 4115*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_exchangedata_t( 4116*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4117*a1e26a70SApple OSS Distributions struct vnode *v1, 4118*a1e26a70SApple OSS Distributions struct label *vl1, 4119*a1e26a70SApple OSS Distributions struct vnode *v2, 4120*a1e26a70SApple OSS Distributions struct label *vl2 4121*a1e26a70SApple OSS Distributions ); 4122*a1e26a70SApple OSS Distributions /** 4123*a1e26a70SApple OSS Distributions * @brief Access control check for executing the vnode 4124*a1e26a70SApple OSS Distributions * @param cred Subject credential 4125*a1e26a70SApple OSS Distributions * @param vp Object vnode to execute 4126*a1e26a70SApple OSS Distributions * @param scriptvp Script being executed by interpreter, if any. 4127*a1e26a70SApple OSS Distributions * @param vnodelabel Label corresponding to vp 4128*a1e26a70SApple OSS Distributions * @param scriptlabel Script vnode label 4129*a1e26a70SApple OSS Distributions * @param execlabel Userspace provided execution label 4130*a1e26a70SApple OSS Distributions * @param cnp Component name for file being executed 4131*a1e26a70SApple OSS Distributions * @param macpolicyattr MAC policy-specific spawn attribute data. 4132*a1e26a70SApple OSS Distributions * @param macpolicyattrlen Length of policy-specific spawn attribute data. 4133*a1e26a70SApple OSS Distributions * 4134*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can execute 4135*a1e26a70SApple OSS Distributions * the passed vnode. Determination of execute privilege is made separately 4136*a1e26a70SApple OSS Distributions * from decisions about any process label transitioning event. 4137*a1e26a70SApple OSS Distributions * 4138*a1e26a70SApple OSS Distributions * The final label, execlabel, corresponds to a label supplied by a 4139*a1e26a70SApple OSS Distributions * user space application through the use of the mac_execve system call. 4140*a1e26a70SApple OSS Distributions * This label will be NULL if the user application uses the the vendor 4141*a1e26a70SApple OSS Distributions * execve(2) call instead of the MAC Framework mac_execve() call. 4142*a1e26a70SApple OSS Distributions * 4143*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4144*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4145*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4146*a1e26a70SApple OSS Distributions */ 4147*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_exec_t( 4148*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4149*a1e26a70SApple OSS Distributions struct vnode *vp, 4150*a1e26a70SApple OSS Distributions struct vnode *scriptvp, 4151*a1e26a70SApple OSS Distributions struct label *vnodelabel, 4152*a1e26a70SApple OSS Distributions struct label *scriptlabel, 4153*a1e26a70SApple OSS Distributions struct label *execlabel, /* NULLOK */ 4154*a1e26a70SApple OSS Distributions struct componentname *cnp, 4155*a1e26a70SApple OSS Distributions u_int *csflags, 4156*a1e26a70SApple OSS Distributions void *macpolicyattr, 4157*a1e26a70SApple OSS Distributions size_t macpolicyattrlen 4158*a1e26a70SApple OSS Distributions ); 4159*a1e26a70SApple OSS Distributions /** 4160*a1e26a70SApple OSS Distributions * @brief Access control check for fsgetpath 4161*a1e26a70SApple OSS Distributions * @param cred Subject credential 4162*a1e26a70SApple OSS Distributions * @param vp Vnode for which a path will be returned 4163*a1e26a70SApple OSS Distributions * @param label Label associated with the vnode 4164*a1e26a70SApple OSS Distributions * 4165*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can get the path 4166*a1e26a70SApple OSS Distributions * of the given vnode with fsgetpath. 4167*a1e26a70SApple OSS Distributions * 4168*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4169*a1e26a70SApple OSS Distributions * errno should be returned. 4170*a1e26a70SApple OSS Distributions */ 4171*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_fsgetpath_t( 4172*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4173*a1e26a70SApple OSS Distributions struct vnode *vp, 4174*a1e26a70SApple OSS Distributions struct label *label 4175*a1e26a70SApple OSS Distributions ); 4176*a1e26a70SApple OSS Distributions /** 4177*a1e26a70SApple OSS Distributions * @brief Access control check for retrieving file attributes 4178*a1e26a70SApple OSS Distributions * @param active_cred Subject credential 4179*a1e26a70SApple OSS Distributions * @param file_cred Credential associated with the struct fileproc 4180*a1e26a70SApple OSS Distributions * @param vp Object vnode 4181*a1e26a70SApple OSS Distributions * @param vlabel Policy label for vp 4182*a1e26a70SApple OSS Distributions * @param va Vnode attributes to retrieve 4183*a1e26a70SApple OSS Distributions * 4184*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 4185*a1e26a70SApple OSS Distributions * get information about the passed vnode. The active_cred hold 4186*a1e26a70SApple OSS Distributions * the credentials of the subject performing the operation, and 4187*a1e26a70SApple OSS Distributions * file_cred holds the credentials of the subject that originally 4188*a1e26a70SApple OSS Distributions * opened the file. This check happens during stat(), lstat(), 4189*a1e26a70SApple OSS Distributions * fstat(), and getattrlist() syscalls. See <sys/vnode.h> for 4190*a1e26a70SApple OSS Distributions * definitions of the attributes. 4191*a1e26a70SApple OSS Distributions * 4192*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4193*a1e26a70SApple OSS Distributions * errno should be returned. 4194*a1e26a70SApple OSS Distributions * 4195*a1e26a70SApple OSS Distributions * @note Policies may change the contents of va to alter the list of 4196*a1e26a70SApple OSS Distributions * file attributes returned. 4197*a1e26a70SApple OSS Distributions */ 4198*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_getattr_t( 4199*a1e26a70SApple OSS Distributions kauth_cred_t active_cred, 4200*a1e26a70SApple OSS Distributions kauth_cred_t file_cred, /* NULLOK */ 4201*a1e26a70SApple OSS Distributions struct vnode *vp, 4202*a1e26a70SApple OSS Distributions struct label *vlabel, 4203*a1e26a70SApple OSS Distributions struct vnode_attr *va 4204*a1e26a70SApple OSS Distributions ); 4205*a1e26a70SApple OSS Distributions /** 4206*a1e26a70SApple OSS Distributions * @brief Access control check for retrieving file attributes 4207*a1e26a70SApple OSS Distributions * @param cred Subject credential 4208*a1e26a70SApple OSS Distributions * @param vp Object vnode 4209*a1e26a70SApple OSS Distributions * @param vlabel Policy label for vp 4210*a1e26a70SApple OSS Distributions * @param alist List of attributes to retrieve 4211*a1e26a70SApple OSS Distributions * @param options Option flags for alist 4212*a1e26a70SApple OSS Distributions * 4213*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can read 4214*a1e26a70SApple OSS Distributions * various attributes of the specified vnode, or the filesystem or volume on 4215*a1e26a70SApple OSS Distributions * which that vnode resides. See <sys/attr.h> for definitions of the 4216*a1e26a70SApple OSS Distributions * attributes and flags. 4217*a1e26a70SApple OSS Distributions * 4218*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4219*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4220*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. Access control covers all attributes requested 4221*a1e26a70SApple OSS Distributions * with this call; the security policy is not permitted to change the set of 4222*a1e26a70SApple OSS Distributions * attributes requested. 4223*a1e26a70SApple OSS Distributions */ 4224*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_getattrlist_t( 4225*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4226*a1e26a70SApple OSS Distributions struct vnode *vp, 4227*a1e26a70SApple OSS Distributions struct label *vlabel, 4228*a1e26a70SApple OSS Distributions struct attrlist *alist, 4229*a1e26a70SApple OSS Distributions uint64_t options 4230*a1e26a70SApple OSS Distributions ); 4231*a1e26a70SApple OSS Distributions /** 4232*a1e26a70SApple OSS Distributions * @brief Access control check for retrieving file attributes for multiple directory entries 4233*a1e26a70SApple OSS Distributions * @param cred Subject credential 4234*a1e26a70SApple OSS Distributions * @param dvp Directory vnode 4235*a1e26a70SApple OSS Distributions * @param alist List of attributes to retrieve 4236*a1e26a70SApple OSS Distributions * @param options Option flags for alist 4237*a1e26a70SApple OSS Distributions * 4238*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can read 4239*a1e26a70SApple OSS Distributions * various attributes of the specified vnode, or the filesystem or volume on 4240*a1e26a70SApple OSS Distributions * which that vnode resides. See <sys/attr.h> for definitions of the 4241*a1e26a70SApple OSS Distributions * attributes and flags. 4242*a1e26a70SApple OSS Distributions * 4243*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4244*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4245*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. Access control covers all attributes requested 4246*a1e26a70SApple OSS Distributions * with this call; the security policy is not permitted to change the set of 4247*a1e26a70SApple OSS Distributions * attributes requested. 4248*a1e26a70SApple OSS Distributions */ 4249*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_getattrlistbulk_t( 4250*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4251*a1e26a70SApple OSS Distributions struct vnode *dvp, 4252*a1e26a70SApple OSS Distributions struct attrlist *alist, 4253*a1e26a70SApple OSS Distributions uint64_t options 4254*a1e26a70SApple OSS Distributions ); 4255*a1e26a70SApple OSS Distributions /** 4256*a1e26a70SApple OSS Distributions * @brief Access control check for retrieving an extended attribute 4257*a1e26a70SApple OSS Distributions * @param cred Subject credential 4258*a1e26a70SApple OSS Distributions * @param vp Object vnode 4259*a1e26a70SApple OSS Distributions * @param label Policy label for vp 4260*a1e26a70SApple OSS Distributions * @param name Extended attribute name 4261*a1e26a70SApple OSS Distributions * @param uio I/O structure pointer 4262*a1e26a70SApple OSS Distributions * 4263*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can retrieve 4264*a1e26a70SApple OSS Distributions * the extended attribute from the passed vnode. The uio parameter 4265*a1e26a70SApple OSS Distributions * will be NULL when the getxattr(2) call has been made with a NULL data 4266*a1e26a70SApple OSS Distributions * value; this is done to request the size of the data only. 4267*a1e26a70SApple OSS Distributions * 4268*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4269*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4270*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4271*a1e26a70SApple OSS Distributions */ 4272*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_getextattr_t( 4273*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4274*a1e26a70SApple OSS Distributions struct vnode *vp, 4275*a1e26a70SApple OSS Distributions struct label *label, /* NULLOK */ 4276*a1e26a70SApple OSS Distributions const char *name, 4277*a1e26a70SApple OSS Distributions struct uio *uio /* NULLOK */ 4278*a1e26a70SApple OSS Distributions ); 4279*a1e26a70SApple OSS Distributions /** 4280*a1e26a70SApple OSS Distributions * @brief Access control check for ioctl 4281*a1e26a70SApple OSS Distributions * @param cred Subject credential 4282*a1e26a70SApple OSS Distributions * @param vp Object vnode 4283*a1e26a70SApple OSS Distributions * @param label Policy label for vp 4284*a1e26a70SApple OSS Distributions * @param cmd Device-dependent request code; see ioctl(2) 4285*a1e26a70SApple OSS Distributions * 4286*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 4287*a1e26a70SApple OSS Distributions * the ioctl operation indicated by com. 4288*a1e26a70SApple OSS Distributions * 4289*a1e26a70SApple OSS Distributions * @warning Since ioctl data is opaque from the standpoint of the MAC 4290*a1e26a70SApple OSS Distributions * framework, and since ioctls can affect many aspects of system 4291*a1e26a70SApple OSS Distributions * operation, policies must exercise extreme care when implementing 4292*a1e26a70SApple OSS Distributions * access control checks. 4293*a1e26a70SApple OSS Distributions * 4294*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4295*a1e26a70SApple OSS Distributions * errno should be returned. 4296*a1e26a70SApple OSS Distributions */ 4297*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_ioctl_t( 4298*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4299*a1e26a70SApple OSS Distributions struct vnode *vp, 4300*a1e26a70SApple OSS Distributions struct label *label, 4301*a1e26a70SApple OSS Distributions unsigned long cmd 4302*a1e26a70SApple OSS Distributions ); 4303*a1e26a70SApple OSS Distributions /** 4304*a1e26a70SApple OSS Distributions * @brief Access control check for vnode kqfilter 4305*a1e26a70SApple OSS Distributions * @param active_cred Subject credential 4306*a1e26a70SApple OSS Distributions * @param kn Object knote 4307*a1e26a70SApple OSS Distributions * @param vp Object vnode 4308*a1e26a70SApple OSS Distributions * @param label Policy label for vp 4309*a1e26a70SApple OSS Distributions * 4310*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 4311*a1e26a70SApple OSS Distributions * receive the knote on the passed vnode. 4312*a1e26a70SApple OSS Distributions * 4313*a1e26a70SApple OSS Distributions * @return Return 0 if access if granted, otherwise an appropriate 4314*a1e26a70SApple OSS Distributions * value for errno should be returned. 4315*a1e26a70SApple OSS Distributions */ 4316*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_kqfilter_t( 4317*a1e26a70SApple OSS Distributions kauth_cred_t active_cred, 4318*a1e26a70SApple OSS Distributions kauth_cred_t file_cred, /* NULLOK */ 4319*a1e26a70SApple OSS Distributions struct knote *kn, 4320*a1e26a70SApple OSS Distributions struct vnode *vp, 4321*a1e26a70SApple OSS Distributions struct label *label 4322*a1e26a70SApple OSS Distributions ); 4323*a1e26a70SApple OSS Distributions /** 4324*a1e26a70SApple OSS Distributions * @brief Access control check for relabel 4325*a1e26a70SApple OSS Distributions * @param cred Subject credential 4326*a1e26a70SApple OSS Distributions * @param vp Object vnode 4327*a1e26a70SApple OSS Distributions * @param vnodelabel Existing policy label for vp 4328*a1e26a70SApple OSS Distributions * @param newlabel Policy label update to later be applied to vp 4329*a1e26a70SApple OSS Distributions * @see mpo_relable_vnode_t 4330*a1e26a70SApple OSS Distributions * 4331*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can relabel 4332*a1e26a70SApple OSS Distributions * the passed vnode to the passed label update. If all policies permit 4333*a1e26a70SApple OSS Distributions * the label change, the actual relabel entry point (mpo_vnode_label_update) 4334*a1e26a70SApple OSS Distributions * will follow. 4335*a1e26a70SApple OSS Distributions * 4336*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4337*a1e26a70SApple OSS Distributions * errno should be returned. 4338*a1e26a70SApple OSS Distributions */ 4339*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_label_update_t( 4340*a1e26a70SApple OSS Distributions struct ucred *cred, 4341*a1e26a70SApple OSS Distributions struct vnode *vp, 4342*a1e26a70SApple OSS Distributions struct label *vnodelabel, 4343*a1e26a70SApple OSS Distributions struct label *newlabel 4344*a1e26a70SApple OSS Distributions ); 4345*a1e26a70SApple OSS Distributions /** 4346*a1e26a70SApple OSS Distributions * @brief Access control check for creating link 4347*a1e26a70SApple OSS Distributions * @param cred Subject credential 4348*a1e26a70SApple OSS Distributions * @param dvp Directory vnode 4349*a1e26a70SApple OSS Distributions * @param dlabel Policy label associated with dvp 4350*a1e26a70SApple OSS Distributions * @param vp Link destination vnode 4351*a1e26a70SApple OSS Distributions * @param label Policy label associated with vp 4352*a1e26a70SApple OSS Distributions * @param cnp Component name for the link being created 4353*a1e26a70SApple OSS Distributions * 4354*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 4355*a1e26a70SApple OSS Distributions * allowed to create a link to the vnode vp with the name specified by cnp. 4356*a1e26a70SApple OSS Distributions * 4357*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4358*a1e26a70SApple OSS Distributions * errno should be returned. 4359*a1e26a70SApple OSS Distributions */ 4360*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_link_t( 4361*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4362*a1e26a70SApple OSS Distributions struct vnode *dvp, 4363*a1e26a70SApple OSS Distributions struct label *dlabel, 4364*a1e26a70SApple OSS Distributions struct vnode *vp, 4365*a1e26a70SApple OSS Distributions struct label *label, 4366*a1e26a70SApple OSS Distributions struct componentname *cnp 4367*a1e26a70SApple OSS Distributions ); 4368*a1e26a70SApple OSS Distributions /** 4369*a1e26a70SApple OSS Distributions * @brief Access control check for listing extended attributes 4370*a1e26a70SApple OSS Distributions * @param cred Subject credential 4371*a1e26a70SApple OSS Distributions * @param vp Object vnode 4372*a1e26a70SApple OSS Distributions * @param vlabel Policy label associated with vp 4373*a1e26a70SApple OSS Distributions * 4374*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can retrieve 4375*a1e26a70SApple OSS Distributions * a list of named extended attributes from a vnode. 4376*a1e26a70SApple OSS Distributions * 4377*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4378*a1e26a70SApple OSS Distributions * errno should be returned. 4379*a1e26a70SApple OSS Distributions */ 4380*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_listextattr_t( 4381*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4382*a1e26a70SApple OSS Distributions struct vnode *vp, 4383*a1e26a70SApple OSS Distributions struct label *vlabel 4384*a1e26a70SApple OSS Distributions ); 4385*a1e26a70SApple OSS Distributions /** 4386*a1e26a70SApple OSS Distributions * @brief Access control check for lookup 4387*a1e26a70SApple OSS Distributions * @param cred Subject credential 4388*a1e26a70SApple OSS Distributions * @param dvp Directory vnode 4389*a1e26a70SApple OSS Distributions * @param dlabel Policy label for dvp 4390*a1e26a70SApple OSS Distributions * @param path Path being looked up 4391*a1e26a70SApple OSS Distributions * @param pathlen Length of path in bytes 4392*a1e26a70SApple OSS Distributions * 4393*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 4394*a1e26a70SApple OSS Distributions * a lookup of the passed path relative to the passed directory vnode. 4395*a1e26a70SApple OSS Distributions * 4396*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4397*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4398*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4399*a1e26a70SApple OSS Distributions * 4400*a1e26a70SApple OSS Distributions * @note The path may contain untrusted input. If approved, lookup proceeds 4401*a1e26a70SApple OSS Distributions * on the path; if a component is found to be a symlink then this hook is 4402*a1e26a70SApple OSS Distributions * called again with the updated path. 4403*a1e26a70SApple OSS Distributions */ 4404*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_lookup_preflight_t( 4405*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4406*a1e26a70SApple OSS Distributions struct vnode *dvp, 4407*a1e26a70SApple OSS Distributions struct label *dlabel, 4408*a1e26a70SApple OSS Distributions const char *path, 4409*a1e26a70SApple OSS Distributions size_t pathlen 4410*a1e26a70SApple OSS Distributions ); 4411*a1e26a70SApple OSS Distributions /** 4412*a1e26a70SApple OSS Distributions * @brief Access control check for lookup 4413*a1e26a70SApple OSS Distributions * @param cred Subject credential 4414*a1e26a70SApple OSS Distributions * @param dvp Object vnode 4415*a1e26a70SApple OSS Distributions * @param dlabel Policy label for dvp 4416*a1e26a70SApple OSS Distributions * @param cnp Component name being looked up 4417*a1e26a70SApple OSS Distributions * 4418*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 4419*a1e26a70SApple OSS Distributions * a lookup in the passed directory vnode for the passed name (cnp). 4420*a1e26a70SApple OSS Distributions * 4421*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4422*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4423*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4424*a1e26a70SApple OSS Distributions */ 4425*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_lookup_t( 4426*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4427*a1e26a70SApple OSS Distributions struct vnode *dvp, 4428*a1e26a70SApple OSS Distributions struct label *dlabel, 4429*a1e26a70SApple OSS Distributions struct componentname *cnp 4430*a1e26a70SApple OSS Distributions ); 4431*a1e26a70SApple OSS Distributions /** 4432*a1e26a70SApple OSS Distributions * @brief Access control check for open 4433*a1e26a70SApple OSS Distributions * @param cred Subject credential 4434*a1e26a70SApple OSS Distributions * @param vp Object vnode 4435*a1e26a70SApple OSS Distributions * @param label Policy label associated with vp 4436*a1e26a70SApple OSS Distributions * @param acc_mode open(2) access mode 4437*a1e26a70SApple OSS Distributions * 4438*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 4439*a1e26a70SApple OSS Distributions * an open operation on the passed vnode with the passed access mode. 4440*a1e26a70SApple OSS Distributions * 4441*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4442*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4443*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4444*a1e26a70SApple OSS Distributions */ 4445*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_open_t( 4446*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4447*a1e26a70SApple OSS Distributions struct vnode *vp, 4448*a1e26a70SApple OSS Distributions struct label *label, 4449*a1e26a70SApple OSS Distributions int acc_mode 4450*a1e26a70SApple OSS Distributions ); 4451*a1e26a70SApple OSS Distributions /** 4452*a1e26a70SApple OSS Distributions * @brief Access control check for read 4453*a1e26a70SApple OSS Distributions * @param active_cred Subject credential 4454*a1e26a70SApple OSS Distributions * @param file_cred Credential associated with the struct fileproc 4455*a1e26a70SApple OSS Distributions * @param vp Object vnode 4456*a1e26a70SApple OSS Distributions * @param label Policy label for vp 4457*a1e26a70SApple OSS Distributions * 4458*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 4459*a1e26a70SApple OSS Distributions * a read operation on the passed vnode. The active_cred hold the credentials 4460*a1e26a70SApple OSS Distributions * of the subject performing the operation, and file_cred holds the 4461*a1e26a70SApple OSS Distributions * credentials of the subject that originally opened the file. 4462*a1e26a70SApple OSS Distributions * 4463*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4464*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4465*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4466*a1e26a70SApple OSS Distributions */ 4467*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_read_t( 4468*a1e26a70SApple OSS Distributions kauth_cred_t active_cred, /* SUBJECT */ 4469*a1e26a70SApple OSS Distributions kauth_cred_t file_cred, /* NULLOK */ 4470*a1e26a70SApple OSS Distributions struct vnode *vp, /* OBJECT */ 4471*a1e26a70SApple OSS Distributions struct label *label /* LABEL */ 4472*a1e26a70SApple OSS Distributions ); 4473*a1e26a70SApple OSS Distributions /** 4474*a1e26a70SApple OSS Distributions * @brief Access control check for read directory 4475*a1e26a70SApple OSS Distributions * @param cred Subject credential 4476*a1e26a70SApple OSS Distributions * @param dvp Object directory vnode 4477*a1e26a70SApple OSS Distributions * @param dlabel Policy label for dvp 4478*a1e26a70SApple OSS Distributions * 4479*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 4480*a1e26a70SApple OSS Distributions * perform a readdir operation on the passed directory vnode. 4481*a1e26a70SApple OSS Distributions * 4482*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4483*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4484*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4485*a1e26a70SApple OSS Distributions */ 4486*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_readdir_t( 4487*a1e26a70SApple OSS Distributions kauth_cred_t cred, /* SUBJECT */ 4488*a1e26a70SApple OSS Distributions struct vnode *dvp, /* OBJECT */ 4489*a1e26a70SApple OSS Distributions struct label *dlabel /* LABEL */ 4490*a1e26a70SApple OSS Distributions ); 4491*a1e26a70SApple OSS Distributions /** 4492*a1e26a70SApple OSS Distributions * @brief Access control check for read link 4493*a1e26a70SApple OSS Distributions * @param cred Subject credential 4494*a1e26a70SApple OSS Distributions * @param vp Object vnode 4495*a1e26a70SApple OSS Distributions * @param label Policy label for vp 4496*a1e26a70SApple OSS Distributions * 4497*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform 4498*a1e26a70SApple OSS Distributions * a readlink operation on the passed symlink vnode. This call can be made 4499*a1e26a70SApple OSS Distributions * in a number of situations, including an explicit readlink call by the 4500*a1e26a70SApple OSS Distributions * user process, or as a result of an implicit readlink during a name 4501*a1e26a70SApple OSS Distributions * lookup by the process. 4502*a1e26a70SApple OSS Distributions * 4503*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4504*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4505*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4506*a1e26a70SApple OSS Distributions */ 4507*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_readlink_t( 4508*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4509*a1e26a70SApple OSS Distributions struct vnode *vp, 4510*a1e26a70SApple OSS Distributions struct label *label 4511*a1e26a70SApple OSS Distributions ); 4512*a1e26a70SApple OSS Distributions /** 4513*a1e26a70SApple OSS Distributions * @brief Access control check for rename 4514*a1e26a70SApple OSS Distributions * @param cred Subject credential 4515*a1e26a70SApple OSS Distributions * @param fdvp Directory vnode 4516*a1e26a70SApple OSS Distributions * @param fdlabel Policy label associated with dvp 4517*a1e26a70SApple OSS Distributions * @param fvp vnode to be renamed 4518*a1e26a70SApple OSS Distributions * @param flabel Policy label associated with vp 4519*a1e26a70SApple OSS Distributions * @param fcnp Component name for vp 4520*a1e26a70SApple OSS Distributions * @param tdvp Destination directory vnode 4521*a1e26a70SApple OSS Distributions * @param tdlabel Policy label associated with tdvp 4522*a1e26a70SApple OSS Distributions * @param tvp Overwritten vnode 4523*a1e26a70SApple OSS Distributions * @param tlabel Policy label associated with tvp 4524*a1e26a70SApple OSS Distributions * @param tcnp Destination component name 4525*a1e26a70SApple OSS Distributions * 4526*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be allowed 4527*a1e26a70SApple OSS Distributions * to rename the vnode vp to something else. 4528*a1e26a70SApple OSS Distributions * 4529*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4530*a1e26a70SApple OSS Distributions * errno should be returned. 4531*a1e26a70SApple OSS Distributions */ 4532*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_rename_t( 4533*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4534*a1e26a70SApple OSS Distributions struct vnode *fdvp, 4535*a1e26a70SApple OSS Distributions struct label *fdlabel, 4536*a1e26a70SApple OSS Distributions struct vnode *fvp, 4537*a1e26a70SApple OSS Distributions struct label *flabel, 4538*a1e26a70SApple OSS Distributions struct componentname *fcnp, 4539*a1e26a70SApple OSS Distributions struct vnode *tdvp, 4540*a1e26a70SApple OSS Distributions struct label *tdlabel, 4541*a1e26a70SApple OSS Distributions struct vnode *tvp, 4542*a1e26a70SApple OSS Distributions struct label *tlabel, 4543*a1e26a70SApple OSS Distributions struct componentname *tcnp 4544*a1e26a70SApple OSS Distributions ); 4545*a1e26a70SApple OSS Distributions /** 4546*a1e26a70SApple OSS Distributions * @brief Access control check for rename from 4547*a1e26a70SApple OSS Distributions * @param cred Subject credential 4548*a1e26a70SApple OSS Distributions * @param dvp Directory vnode 4549*a1e26a70SApple OSS Distributions * @param dlabel Policy label associated with dvp 4550*a1e26a70SApple OSS Distributions * @param vp vnode to be renamed 4551*a1e26a70SApple OSS Distributions * @param label Policy label associated with vp 4552*a1e26a70SApple OSS Distributions * @param cnp Component name for vp 4553*a1e26a70SApple OSS Distributions * @see mpo_vnode_check_rename_t 4554*a1e26a70SApple OSS Distributions * @see mpo_vnode_check_rename_to_t 4555*a1e26a70SApple OSS Distributions * 4556*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 4557*a1e26a70SApple OSS Distributions * allowed to rename the vnode vp to something else. 4558*a1e26a70SApple OSS Distributions * 4559*a1e26a70SApple OSS Distributions * Due to VFS locking constraints (to make sure proper vnode locks are 4560*a1e26a70SApple OSS Distributions * held during this entry point), the vnode relabel checks had to be 4561*a1e26a70SApple OSS Distributions * split into two parts: relabel_from and relabel to. 4562*a1e26a70SApple OSS Distributions * 4563*a1e26a70SApple OSS Distributions * This hook is deprecated, mpo_vnode_check_rename_t should be used instead. 4564*a1e26a70SApple OSS Distributions * 4565*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4566*a1e26a70SApple OSS Distributions * errno should be returned. 4567*a1e26a70SApple OSS Distributions */ 4568*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_rename_from_t( 4569*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4570*a1e26a70SApple OSS Distributions struct vnode *dvp, 4571*a1e26a70SApple OSS Distributions struct label *dlabel, 4572*a1e26a70SApple OSS Distributions struct vnode *vp, 4573*a1e26a70SApple OSS Distributions struct label *label, 4574*a1e26a70SApple OSS Distributions struct componentname *cnp 4575*a1e26a70SApple OSS Distributions ); 4576*a1e26a70SApple OSS Distributions /** 4577*a1e26a70SApple OSS Distributions * @brief Access control check for rename to 4578*a1e26a70SApple OSS Distributions * @param cred Subject credential 4579*a1e26a70SApple OSS Distributions * @param dvp Directory vnode 4580*a1e26a70SApple OSS Distributions * @param dlabel Policy label associated with dvp 4581*a1e26a70SApple OSS Distributions * @param vp Overwritten vnode 4582*a1e26a70SApple OSS Distributions * @param label Policy label associated with vp 4583*a1e26a70SApple OSS Distributions * @param samedir Boolean; 1 if the source and destination directories are the same 4584*a1e26a70SApple OSS Distributions * @param cnp Destination component name 4585*a1e26a70SApple OSS Distributions * @see mpo_vnode_check_rename_t 4586*a1e26a70SApple OSS Distributions * @see mpo_vnode_check_rename_from_t 4587*a1e26a70SApple OSS Distributions * 4588*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 4589*a1e26a70SApple OSS Distributions * allowed to rename to the vnode vp, into the directory dvp, or to the 4590*a1e26a70SApple OSS Distributions * name represented by cnp. If there is no existing file to overwrite, 4591*a1e26a70SApple OSS Distributions * vp and label will be NULL. 4592*a1e26a70SApple OSS Distributions * 4593*a1e26a70SApple OSS Distributions * Due to VFS locking constraints (to make sure proper vnode locks are 4594*a1e26a70SApple OSS Distributions * held during this entry point), the vnode relabel checks had to be 4595*a1e26a70SApple OSS Distributions * split into two parts: relabel_from and relabel to. 4596*a1e26a70SApple OSS Distributions * 4597*a1e26a70SApple OSS Distributions * This hook is deprecated, mpo_vnode_check_rename_t should be used instead. 4598*a1e26a70SApple OSS Distributions * 4599*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4600*a1e26a70SApple OSS Distributions * errno should be returned. 4601*a1e26a70SApple OSS Distributions */ 4602*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_rename_to_t( 4603*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4604*a1e26a70SApple OSS Distributions struct vnode *dvp, 4605*a1e26a70SApple OSS Distributions struct label *dlabel, 4606*a1e26a70SApple OSS Distributions struct vnode *vp, /* NULLOK */ 4607*a1e26a70SApple OSS Distributions struct label *label, /* NULLOK */ 4608*a1e26a70SApple OSS Distributions int samedir, 4609*a1e26a70SApple OSS Distributions struct componentname *cnp 4610*a1e26a70SApple OSS Distributions ); 4611*a1e26a70SApple OSS Distributions /** 4612*a1e26a70SApple OSS Distributions * @brief Access control check for revoke 4613*a1e26a70SApple OSS Distributions * @param cred Subject credential 4614*a1e26a70SApple OSS Distributions * @param vp Object vnode 4615*a1e26a70SApple OSS Distributions * @param label Policy label for vp 4616*a1e26a70SApple OSS Distributions * 4617*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can revoke 4618*a1e26a70SApple OSS Distributions * access to the passed vnode. 4619*a1e26a70SApple OSS Distributions * 4620*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4621*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4622*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4623*a1e26a70SApple OSS Distributions */ 4624*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_revoke_t( 4625*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4626*a1e26a70SApple OSS Distributions struct vnode *vp, 4627*a1e26a70SApple OSS Distributions struct label *label 4628*a1e26a70SApple OSS Distributions ); 4629*a1e26a70SApple OSS Distributions /** 4630*a1e26a70SApple OSS Distributions * @brief Access control check for searchfs 4631*a1e26a70SApple OSS Distributions * @param cred Subject credential 4632*a1e26a70SApple OSS Distributions * @param vp Object vnode 4633*a1e26a70SApple OSS Distributions * @param vlabel Policy label for vp 4634*a1e26a70SApple OSS Distributions * @param returnattrs List of attributes to be returned 4635*a1e26a70SApple OSS Distributions * @param searchattrs List of attributes used as search criteria 4636*a1e26a70SApple OSS Distributions * 4637*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can search the 4638*a1e26a70SApple OSS Distributions * vnode using the searchfs system call. 4639*a1e26a70SApple OSS Distributions * 4640*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4641*a1e26a70SApple OSS Distributions * errno should be returned. 4642*a1e26a70SApple OSS Distributions */ 4643*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_searchfs_t( 4644*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4645*a1e26a70SApple OSS Distributions struct vnode *vp, 4646*a1e26a70SApple OSS Distributions struct label *vlabel, 4647*a1e26a70SApple OSS Distributions struct attrlist *returnattrs, 4648*a1e26a70SApple OSS Distributions struct attrlist *searchattrs 4649*a1e26a70SApple OSS Distributions ); 4650*a1e26a70SApple OSS Distributions /** 4651*a1e26a70SApple OSS Distributions * @brief Access control check for select 4652*a1e26a70SApple OSS Distributions * @param cred Subject credential 4653*a1e26a70SApple OSS Distributions * @param vp Object vnode 4654*a1e26a70SApple OSS Distributions * @param label Policy label for vp 4655*a1e26a70SApple OSS Distributions * @param which The operation selected on: FREAD or FWRITE 4656*a1e26a70SApple OSS Distributions * 4657*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can select 4658*a1e26a70SApple OSS Distributions * the vnode. 4659*a1e26a70SApple OSS Distributions * 4660*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4661*a1e26a70SApple OSS Distributions * errno should be returned. 4662*a1e26a70SApple OSS Distributions */ 4663*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_select_t( 4664*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4665*a1e26a70SApple OSS Distributions struct vnode *vp, 4666*a1e26a70SApple OSS Distributions struct label *label, 4667*a1e26a70SApple OSS Distributions int which 4668*a1e26a70SApple OSS Distributions ); 4669*a1e26a70SApple OSS Distributions /** 4670*a1e26a70SApple OSS Distributions * @brief Access control check for setting ACL 4671*a1e26a70SApple OSS Distributions * @param cred Subject credential 4672*a1e26a70SApple OSS Distributions * @param vp Object node 4673*a1e26a70SApple OSS Distributions * @param label Policy label for vp 4674*a1e26a70SApple OSS Distributions * @param acl ACL structure pointer 4675*a1e26a70SApple OSS Distributions * 4676*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can set an ACL 4677*a1e26a70SApple OSS Distributions * on the specified vnode. The ACL pointer will be NULL when removing an ACL. 4678*a1e26a70SApple OSS Distributions * 4679*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4680*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4681*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4682*a1e26a70SApple OSS Distributions */ 4683*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_setacl_t( 4684*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4685*a1e26a70SApple OSS Distributions struct vnode *vp, 4686*a1e26a70SApple OSS Distributions struct label *label, 4687*a1e26a70SApple OSS Distributions struct kauth_acl *acl 4688*a1e26a70SApple OSS Distributions ); 4689*a1e26a70SApple OSS Distributions /** 4690*a1e26a70SApple OSS Distributions * @brief Access control check for setting file attributes 4691*a1e26a70SApple OSS Distributions * @param cred Subject credential 4692*a1e26a70SApple OSS Distributions * @param vp Object vnode 4693*a1e26a70SApple OSS Distributions * @param vlabel Policy label for vp 4694*a1e26a70SApple OSS Distributions * @param alist List of attributes to set 4695*a1e26a70SApple OSS Distributions * 4696*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can set 4697*a1e26a70SApple OSS Distributions * various attributes of the specified vnode, or the filesystem or volume on 4698*a1e26a70SApple OSS Distributions * which that vnode resides. See <sys/attr.h> for definitions of the 4699*a1e26a70SApple OSS Distributions * attributes. 4700*a1e26a70SApple OSS Distributions * 4701*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4702*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4703*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. Access control covers all attributes requested 4704*a1e26a70SApple OSS Distributions * with this call. 4705*a1e26a70SApple OSS Distributions */ 4706*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_setattrlist_t( 4707*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4708*a1e26a70SApple OSS Distributions struct vnode *vp, 4709*a1e26a70SApple OSS Distributions struct label *vlabel, 4710*a1e26a70SApple OSS Distributions struct attrlist *alist 4711*a1e26a70SApple OSS Distributions ); 4712*a1e26a70SApple OSS Distributions /** 4713*a1e26a70SApple OSS Distributions * @brief Access control check for setting extended attribute 4714*a1e26a70SApple OSS Distributions * @param cred Subject credential 4715*a1e26a70SApple OSS Distributions * @param vp Object vnode 4716*a1e26a70SApple OSS Distributions * @param label Policy label for vp 4717*a1e26a70SApple OSS Distributions * @param name Extended attribute name 4718*a1e26a70SApple OSS Distributions * @param uio I/O structure pointer 4719*a1e26a70SApple OSS Distributions * 4720*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can set the 4721*a1e26a70SApple OSS Distributions * extended attribute of passed name and passed namespace on the passed 4722*a1e26a70SApple OSS Distributions * vnode. Policies implementing security labels backed into extended 4723*a1e26a70SApple OSS Distributions * attributes may want to provide additional protections for those 4724*a1e26a70SApple OSS Distributions * attributes. Additionally, policies should avoid making decisions based 4725*a1e26a70SApple OSS Distributions * on the data referenced from uio, as there is a potential race condition 4726*a1e26a70SApple OSS Distributions * between this check and the actual operation. The uio may also be NULL 4727*a1e26a70SApple OSS Distributions * if a delete operation is being performed. 4728*a1e26a70SApple OSS Distributions * 4729*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4730*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4731*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4732*a1e26a70SApple OSS Distributions */ 4733*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_setextattr_t( 4734*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4735*a1e26a70SApple OSS Distributions struct vnode *vp, 4736*a1e26a70SApple OSS Distributions struct label *label, 4737*a1e26a70SApple OSS Distributions const char *name, 4738*a1e26a70SApple OSS Distributions struct uio *uio 4739*a1e26a70SApple OSS Distributions ); 4740*a1e26a70SApple OSS Distributions /** 4741*a1e26a70SApple OSS Distributions * @brief Access control check for setting flags 4742*a1e26a70SApple OSS Distributions * @param cred Subject credential 4743*a1e26a70SApple OSS Distributions * @param vp Object vnode 4744*a1e26a70SApple OSS Distributions * @param label Policy label for vp 4745*a1e26a70SApple OSS Distributions * @param flags File flags; see chflags(2) 4746*a1e26a70SApple OSS Distributions * 4747*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can set 4748*a1e26a70SApple OSS Distributions * the passed flags on the passed vnode. 4749*a1e26a70SApple OSS Distributions * 4750*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4751*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4752*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4753*a1e26a70SApple OSS Distributions */ 4754*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_setflags_t( 4755*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4756*a1e26a70SApple OSS Distributions struct vnode *vp, 4757*a1e26a70SApple OSS Distributions struct label *label, 4758*a1e26a70SApple OSS Distributions u_long flags 4759*a1e26a70SApple OSS Distributions ); 4760*a1e26a70SApple OSS Distributions /** 4761*a1e26a70SApple OSS Distributions * @brief Access control check for setting mode 4762*a1e26a70SApple OSS Distributions * @param cred Subject credential 4763*a1e26a70SApple OSS Distributions * @param vp Object vnode 4764*a1e26a70SApple OSS Distributions * @param label Policy label for vp 4765*a1e26a70SApple OSS Distributions * @param mode File mode; see chmod(2) 4766*a1e26a70SApple OSS Distributions * 4767*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can set 4768*a1e26a70SApple OSS Distributions * the passed mode on the passed vnode. 4769*a1e26a70SApple OSS Distributions * 4770*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4771*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4772*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4773*a1e26a70SApple OSS Distributions */ 4774*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_setmode_t( 4775*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4776*a1e26a70SApple OSS Distributions struct vnode *vp, 4777*a1e26a70SApple OSS Distributions struct label *label, 4778*a1e26a70SApple OSS Distributions mode_t mode 4779*a1e26a70SApple OSS Distributions ); 4780*a1e26a70SApple OSS Distributions /** 4781*a1e26a70SApple OSS Distributions * @brief Access control check for setting uid and gid 4782*a1e26a70SApple OSS Distributions * @param cred Subject credential 4783*a1e26a70SApple OSS Distributions * @param vp Object vnode 4784*a1e26a70SApple OSS Distributions * @param label Policy label for vp 4785*a1e26a70SApple OSS Distributions * @param uid User ID 4786*a1e26a70SApple OSS Distributions * @param gid Group ID 4787*a1e26a70SApple OSS Distributions * 4788*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can set 4789*a1e26a70SApple OSS Distributions * the passed uid and passed gid as file uid and file gid on the passed 4790*a1e26a70SApple OSS Distributions * vnode. The IDs may be set to (-1) to request no update. 4791*a1e26a70SApple OSS Distributions * 4792*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4793*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4794*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4795*a1e26a70SApple OSS Distributions */ 4796*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_setowner_t( 4797*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4798*a1e26a70SApple OSS Distributions struct vnode *vp, 4799*a1e26a70SApple OSS Distributions struct label *label, 4800*a1e26a70SApple OSS Distributions uid_t uid, 4801*a1e26a70SApple OSS Distributions gid_t gid 4802*a1e26a70SApple OSS Distributions ); 4803*a1e26a70SApple OSS Distributions /** 4804*a1e26a70SApple OSS Distributions * @brief Access control check for setting timestamps 4805*a1e26a70SApple OSS Distributions * @param cred Subject credential 4806*a1e26a70SApple OSS Distributions * @param vp Object vnode 4807*a1e26a70SApple OSS Distributions * @param label Policy label for vp 4808*a1e26a70SApple OSS Distributions * @param atime Access time; see utimes(2) 4809*a1e26a70SApple OSS Distributions * @param mtime Modification time; see utimes(2) 4810*a1e26a70SApple OSS Distributions * 4811*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can set 4812*a1e26a70SApple OSS Distributions * the passed access timestamps on the passed vnode. 4813*a1e26a70SApple OSS Distributions * 4814*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4815*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4816*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4817*a1e26a70SApple OSS Distributions */ 4818*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_setutimes_t( 4819*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4820*a1e26a70SApple OSS Distributions struct vnode *vp, 4821*a1e26a70SApple OSS Distributions struct label *label, 4822*a1e26a70SApple OSS Distributions struct timespec atime, 4823*a1e26a70SApple OSS Distributions struct timespec mtime 4824*a1e26a70SApple OSS Distributions ); 4825*a1e26a70SApple OSS Distributions /** 4826*a1e26a70SApple OSS Distributions * @brief Access control check after determining the code directory hash 4827*a1e26a70SApple OSS Distributions * @param vp vnode vnode to combine into proc 4828*a1e26a70SApple OSS Distributions * @param label label associated with the vnode 4829*a1e26a70SApple OSS Distributions * @param cpu_type cpu type of the signature being checked 4830*a1e26a70SApple OSS Distributions * @param cs_blob the code signature to check 4831*a1e26a70SApple OSS Distributions * @param cs_flags update code signing flags if needed 4832*a1e26a70SApple OSS Distributions * @param signer_type output parameter for the code signature's signer type 4833*a1e26a70SApple OSS Distributions * @param flags operational flag to mpo_vnode_check_signature 4834*a1e26a70SApple OSS Distributions * @param platform platform of the signature being checked 4835*a1e26a70SApple OSS Distributions * @param fatal_failure_desc description of fatal failure 4836*a1e26a70SApple OSS Distributions * @param fatal_failure_desc_len failure description len, failure is fatal if non-0 4837*a1e26a70SApple OSS Distributions * 4838*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4839*a1e26a70SApple OSS Distributions * errno should be returned. 4840*a1e26a70SApple OSS Distributions */ 4841*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_signature_t( 4842*a1e26a70SApple OSS Distributions struct vnode *vp, 4843*a1e26a70SApple OSS Distributions struct label *label, 4844*a1e26a70SApple OSS Distributions cpu_type_t cpu_type, 4845*a1e26a70SApple OSS Distributions struct cs_blob *cs_blob, 4846*a1e26a70SApple OSS Distributions unsigned int *cs_flags, 4847*a1e26a70SApple OSS Distributions unsigned int *signer_type, 4848*a1e26a70SApple OSS Distributions int flags, 4849*a1e26a70SApple OSS Distributions unsigned int platform, 4850*a1e26a70SApple OSS Distributions char **fatal_failure_desc, size_t *fatal_failure_desc_len 4851*a1e26a70SApple OSS Distributions ); 4852*a1e26a70SApple OSS Distributions /** 4853*a1e26a70SApple OSS Distributions * @brief Access control check for stat 4854*a1e26a70SApple OSS Distributions * @param active_cred Subject credential 4855*a1e26a70SApple OSS Distributions * @param file_cred Credential associated with the struct fileproc 4856*a1e26a70SApple OSS Distributions * @param vp Object vnode 4857*a1e26a70SApple OSS Distributions * @param label Policy label for vp 4858*a1e26a70SApple OSS Distributions * 4859*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can stat 4860*a1e26a70SApple OSS Distributions * the passed vnode. See stat(2) for more information. The active_cred 4861*a1e26a70SApple OSS Distributions * hold the credentials of the subject performing the operation, and 4862*a1e26a70SApple OSS Distributions * file_cred holds the credentials of the subject that originally 4863*a1e26a70SApple OSS Distributions * opened the file. 4864*a1e26a70SApple OSS Distributions * 4865*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4866*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4867*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4868*a1e26a70SApple OSS Distributions */ 4869*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_stat_t( 4870*a1e26a70SApple OSS Distributions struct ucred *active_cred, 4871*a1e26a70SApple OSS Distributions struct ucred *file_cred, /* NULLOK */ 4872*a1e26a70SApple OSS Distributions struct vnode *vp, 4873*a1e26a70SApple OSS Distributions struct label *label 4874*a1e26a70SApple OSS Distributions ); 4875*a1e26a70SApple OSS Distributions /** 4876*a1e26a70SApple OSS Distributions * @brief Access control check for supplemental signature attachement 4877*a1e26a70SApple OSS Distributions * @param vp the vnode to which the signature will be attached 4878*a1e26a70SApple OSS Distributions * @param label label associated with the vnode 4879*a1e26a70SApple OSS Distributions * @param cs_blob the code signature to check 4880*a1e26a70SApple OSS Distributions * @param linked_vp vnode to which this new vp is related 4881*a1e26a70SApple OSS Distributions * @param linked_cs_blob the code signature of the linked vnode 4882*a1e26a70SApple OSS Distributions * @param signer_type output parameter for the signer type of the code signature being checked. 4883*a1e26a70SApple OSS Distributions * 4884*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4885*a1e26a70SApple OSS Distributions * errno should be returned. 4886*a1e26a70SApple OSS Distributions */ 4887*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_supplemental_signature_t( 4888*a1e26a70SApple OSS Distributions struct vnode *vp, 4889*a1e26a70SApple OSS Distributions struct label *label, 4890*a1e26a70SApple OSS Distributions struct cs_blob *cs_blob, 4891*a1e26a70SApple OSS Distributions struct vnode *linked_vp, 4892*a1e26a70SApple OSS Distributions struct cs_blob *linked_cs_blob, 4893*a1e26a70SApple OSS Distributions unsigned int *signer_type 4894*a1e26a70SApple OSS Distributions ); 4895*a1e26a70SApple OSS Distributions /** 4896*a1e26a70SApple OSS Distributions * @brief Access control check for atomically swapping two vnodes. 4897*a1e26a70SApple OSS Distributions * @param cred User credential for the swapping process 4898*a1e26a70SApple OSS Distributions * @param v1 vnode 1 to swap 4899*a1e26a70SApple OSS Distributions * @param vl1 Policy label for v1 4900*a1e26a70SApple OSS Distributions * @param v2 vnode 2 to swap 4901*a1e26a70SApple OSS Distributions * @param vl2 Policy label for v2 4902*a1e26a70SApple OSS Distributions * 4903*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4904*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4905*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4906*a1e26a70SApple OSS Distributions */ 4907*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_swap_t( 4908*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4909*a1e26a70SApple OSS Distributions struct vnode *v1, 4910*a1e26a70SApple OSS Distributions struct label *vl1, 4911*a1e26a70SApple OSS Distributions struct vnode *v2, 4912*a1e26a70SApple OSS Distributions struct label *vl2 4913*a1e26a70SApple OSS Distributions ); 4914*a1e26a70SApple OSS Distributions /** 4915*a1e26a70SApple OSS Distributions * @brief Access control check for vnode trigger resolution 4916*a1e26a70SApple OSS Distributions * @param cred Subject credential 4917*a1e26a70SApple OSS Distributions * @param dvp Object vnode 4918*a1e26a70SApple OSS Distributions * @param dlabel Policy label for dvp 4919*a1e26a70SApple OSS Distributions * @param cnp Component name that triggered resolution 4920*a1e26a70SApple OSS Distributions * 4921*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can trigger 4922*a1e26a70SApple OSS Distributions * resolution of the passed name (cnp) in the passed directory vnode 4923*a1e26a70SApple OSS Distributions * via an external trigger resolver. 4924*a1e26a70SApple OSS Distributions * 4925*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4926*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4927*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4928*a1e26a70SApple OSS Distributions */ 4929*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_trigger_resolve_t( 4930*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4931*a1e26a70SApple OSS Distributions struct vnode *dvp, 4932*a1e26a70SApple OSS Distributions struct label *dlabel, 4933*a1e26a70SApple OSS Distributions struct componentname *cnp 4934*a1e26a70SApple OSS Distributions ); 4935*a1e26a70SApple OSS Distributions /** 4936*a1e26a70SApple OSS Distributions * @brief Access control check for truncate/ftruncate 4937*a1e26a70SApple OSS Distributions * @param active_cred Subject credential 4938*a1e26a70SApple OSS Distributions * @param file_cred Credential associated with the struct fileproc 4939*a1e26a70SApple OSS Distributions * @param vp Object vnode 4940*a1e26a70SApple OSS Distributions * @param label Policy label for vp 4941*a1e26a70SApple OSS Distributions * 4942*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 4943*a1e26a70SApple OSS Distributions * perform a truncate operation on the passed vnode. The active_cred hold 4944*a1e26a70SApple OSS Distributions * the credentials of the subject performing the operation, and 4945*a1e26a70SApple OSS Distributions * file_cred holds the credentials of the subject that originally 4946*a1e26a70SApple OSS Distributions * opened the file. 4947*a1e26a70SApple OSS Distributions * 4948*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4949*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4950*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4951*a1e26a70SApple OSS Distributions */ 4952*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_truncate_t( 4953*a1e26a70SApple OSS Distributions kauth_cred_t active_cred, 4954*a1e26a70SApple OSS Distributions kauth_cred_t file_cred, /* NULLOK */ 4955*a1e26a70SApple OSS Distributions struct vnode *vp, 4956*a1e26a70SApple OSS Distributions struct label *label 4957*a1e26a70SApple OSS Distributions ); 4958*a1e26a70SApple OSS Distributions /** 4959*a1e26a70SApple OSS Distributions * @brief Access control check for binding UNIX domain socket 4960*a1e26a70SApple OSS Distributions * @param cred Subject credential 4961*a1e26a70SApple OSS Distributions * @param dvp Directory vnode 4962*a1e26a70SApple OSS Distributions * @param dlabel Policy label for dvp 4963*a1e26a70SApple OSS Distributions * @param cnp Component name for dvp 4964*a1e26a70SApple OSS Distributions * @param vap vnode attributes for vap 4965*a1e26a70SApple OSS Distributions * 4966*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform a 4967*a1e26a70SApple OSS Distributions * bind operation on a UNIX domain socket with the passed parent directory, 4968*a1e26a70SApple OSS Distributions * passed name information, and passed attribute information. 4969*a1e26a70SApple OSS Distributions * 4970*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4971*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4972*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4973*a1e26a70SApple OSS Distributions */ 4974*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_uipc_bind_t( 4975*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4976*a1e26a70SApple OSS Distributions struct vnode *dvp, 4977*a1e26a70SApple OSS Distributions struct label *dlabel, 4978*a1e26a70SApple OSS Distributions struct componentname *cnp, 4979*a1e26a70SApple OSS Distributions struct vnode_attr *vap 4980*a1e26a70SApple OSS Distributions ); 4981*a1e26a70SApple OSS Distributions /** 4982*a1e26a70SApple OSS Distributions * @brief Access control check for connecting UNIX domain socket 4983*a1e26a70SApple OSS Distributions * @param cred Subject credential 4984*a1e26a70SApple OSS Distributions * @param vp Object vnode 4985*a1e26a70SApple OSS Distributions * @param label Policy label associated with vp 4986*a1e26a70SApple OSS Distributions * @param so Socket 4987*a1e26a70SApple OSS Distributions * 4988*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can perform a 4989*a1e26a70SApple OSS Distributions * connect operation on the passed UNIX domain socket vnode. 4990*a1e26a70SApple OSS Distributions * 4991*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 4992*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 4993*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 4994*a1e26a70SApple OSS Distributions */ 4995*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_uipc_connect_t( 4996*a1e26a70SApple OSS Distributions kauth_cred_t cred, 4997*a1e26a70SApple OSS Distributions struct vnode *vp, 4998*a1e26a70SApple OSS Distributions struct label *label, 4999*a1e26a70SApple OSS Distributions socket_t so 5000*a1e26a70SApple OSS Distributions ); 5001*a1e26a70SApple OSS Distributions /** 5002*a1e26a70SApple OSS Distributions * @brief Access control check for deleting vnode 5003*a1e26a70SApple OSS Distributions * @param cred Subject credential 5004*a1e26a70SApple OSS Distributions * @param dvp Parent directory vnode 5005*a1e26a70SApple OSS Distributions * @param dlabel Policy label for dvp 5006*a1e26a70SApple OSS Distributions * @param vp Object vnode to delete 5007*a1e26a70SApple OSS Distributions * @param label Policy label for vp 5008*a1e26a70SApple OSS Distributions * @param cnp Component name for vp 5009*a1e26a70SApple OSS Distributions * @see mpo_check_rename_to_t 5010*a1e26a70SApple OSS Distributions * 5011*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can delete 5012*a1e26a70SApple OSS Distributions * a vnode from the passed parent directory and passed name information. 5013*a1e26a70SApple OSS Distributions * This call may be made in a number of situations, including as a 5014*a1e26a70SApple OSS Distributions * results of calls to unlink(2) and rmdir(2). Policies implementing 5015*a1e26a70SApple OSS Distributions * this entry point should also implement mpo_check_rename_to to 5016*a1e26a70SApple OSS Distributions * authorize deletion of objects as a result of being the target of a rename. 5017*a1e26a70SApple OSS Distributions * 5018*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 5019*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 5020*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 5021*a1e26a70SApple OSS Distributions */ 5022*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_unlink_t( 5023*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5024*a1e26a70SApple OSS Distributions struct vnode *dvp, 5025*a1e26a70SApple OSS Distributions struct label *dlabel, 5026*a1e26a70SApple OSS Distributions struct vnode *vp, 5027*a1e26a70SApple OSS Distributions struct label *label, 5028*a1e26a70SApple OSS Distributions struct componentname *cnp 5029*a1e26a70SApple OSS Distributions ); 5030*a1e26a70SApple OSS Distributions /** 5031*a1e26a70SApple OSS Distributions * @brief Access control check for write 5032*a1e26a70SApple OSS Distributions * @param active_cred Subject credential 5033*a1e26a70SApple OSS Distributions * @param file_cred Credential associated with the struct fileproc 5034*a1e26a70SApple OSS Distributions * @param vp Object vnode 5035*a1e26a70SApple OSS Distributions * @param label Policy label for vp 5036*a1e26a70SApple OSS Distributions * 5037*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can 5038*a1e26a70SApple OSS Distributions * perform a write operation on the passed vnode. The active_cred hold 5039*a1e26a70SApple OSS Distributions * the credentials of the subject performing the operation, and 5040*a1e26a70SApple OSS Distributions * file_cred holds the credentials of the subject that originally 5041*a1e26a70SApple OSS Distributions * opened the file. 5042*a1e26a70SApple OSS Distributions * 5043*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 5044*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EACCES for label mismatch or 5045*a1e26a70SApple OSS Distributions * EPERM for lack of privilege. 5046*a1e26a70SApple OSS Distributions */ 5047*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_write_t( 5048*a1e26a70SApple OSS Distributions kauth_cred_t active_cred, 5049*a1e26a70SApple OSS Distributions kauth_cred_t file_cred, /* NULLOK */ 5050*a1e26a70SApple OSS Distributions struct vnode *vp, 5051*a1e26a70SApple OSS Distributions struct label *label 5052*a1e26a70SApple OSS Distributions ); 5053*a1e26a70SApple OSS Distributions /** 5054*a1e26a70SApple OSS Distributions * @brief Access control check for copyfile 5055*a1e26a70SApple OSS Distributions * @param cred Subject credential 5056*a1e26a70SApple OSS Distributions * @param dvp Vnode of directory to create the copy in 5057*a1e26a70SApple OSS Distributions * @param dlabel Policy label associated with dvp 5058*a1e26a70SApple OSS Distributions * @param tvp Vnode of the file at the target path that will be unlinked to 5059*a1e26a70SApple OSS Distributions * make room for the copy being created, if file exists 5060*a1e26a70SApple OSS Distributions * @param tlabel Policy label associated with tvp 5061*a1e26a70SApple OSS Distributions * @param fvp Vnode of the file to copy from 5062*a1e26a70SApple OSS Distributions * @param flabel Policy label associated with fvp 5063*a1e26a70SApple OSS Distributions * @param cnp Component name for the copy being created 5064*a1e26a70SApple OSS Distributions * @param mode Corresponds to mode argument to the copyfile syscall 5065*a1e26a70SApple OSS Distributions * @param flags Corresponds to flags argument to the copyfile syscall 5066*a1e26a70SApple OSS Distributions * 5067*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential should be 5068*a1e26a70SApple OSS Distributions * allowed to create a copy of the vnode fvp with the name specified by cnp. 5069*a1e26a70SApple OSS Distributions * 5070*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 5071*a1e26a70SApple OSS Distributions * errno should be returned. 5072*a1e26a70SApple OSS Distributions */ 5073*a1e26a70SApple OSS Distributions typedef int mpo_vnode_check_copyfile_t( 5074*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5075*a1e26a70SApple OSS Distributions struct vnode *dvp, 5076*a1e26a70SApple OSS Distributions struct label *dlabel, 5077*a1e26a70SApple OSS Distributions struct vnode *tvp, /* NULLOK */ 5078*a1e26a70SApple OSS Distributions struct label *tlabel, /* NULLOK */ 5079*a1e26a70SApple OSS Distributions struct vnode *fvp, 5080*a1e26a70SApple OSS Distributions struct label *flabel, 5081*a1e26a70SApple OSS Distributions struct componentname *cnp, 5082*a1e26a70SApple OSS Distributions mode_t mode, 5083*a1e26a70SApple OSS Distributions int flags 5084*a1e26a70SApple OSS Distributions ); 5085*a1e26a70SApple OSS Distributions /** 5086*a1e26a70SApple OSS Distributions * @brief Associate a vnode with a devfs entry 5087*a1e26a70SApple OSS Distributions * @param mp Devfs mount point 5088*a1e26a70SApple OSS Distributions * @param mntlabel Devfs mount point label 5089*a1e26a70SApple OSS Distributions * @param de Devfs directory entry 5090*a1e26a70SApple OSS Distributions * @param delabel Label associated with de 5091*a1e26a70SApple OSS Distributions * @param vp vnode associated with de 5092*a1e26a70SApple OSS Distributions * @param vlabel Label associated with vp 5093*a1e26a70SApple OSS Distributions * 5094*a1e26a70SApple OSS Distributions * Fill in the label (vlabel) for a newly created devfs vnode. The 5095*a1e26a70SApple OSS Distributions * label is typically derived from the label on the devfs directory 5096*a1e26a70SApple OSS Distributions * entry or the label on the filesystem, supplied as parameters. 5097*a1e26a70SApple OSS Distributions */ 5098*a1e26a70SApple OSS Distributions typedef void mpo_vnode_label_associate_devfs_t( 5099*a1e26a70SApple OSS Distributions struct mount *mp, 5100*a1e26a70SApple OSS Distributions struct label *mntlabel, 5101*a1e26a70SApple OSS Distributions struct devnode *de, 5102*a1e26a70SApple OSS Distributions struct label *delabel, 5103*a1e26a70SApple OSS Distributions struct vnode *vp, 5104*a1e26a70SApple OSS Distributions struct label *vlabel 5105*a1e26a70SApple OSS Distributions ); 5106*a1e26a70SApple OSS Distributions /** 5107*a1e26a70SApple OSS Distributions * @brief Associate a label with a vnode 5108*a1e26a70SApple OSS Distributions * @param mp File system mount point 5109*a1e26a70SApple OSS Distributions * @param mntlabel File system mount point label 5110*a1e26a70SApple OSS Distributions * @param vp Vnode to label 5111*a1e26a70SApple OSS Distributions * @param vlabel Label associated with vp 5112*a1e26a70SApple OSS Distributions * 5113*a1e26a70SApple OSS Distributions * Attempt to retrieve label information for the vnode, vp, from the 5114*a1e26a70SApple OSS Distributions * file system extended attribute store. The label should be stored in 5115*a1e26a70SApple OSS Distributions * the supplied vlabel parameter. If a policy cannot retrieve an 5116*a1e26a70SApple OSS Distributions * extended attribute, sometimes it is acceptible to fallback to using 5117*a1e26a70SApple OSS Distributions * the mntlabel. 5118*a1e26a70SApple OSS Distributions * 5119*a1e26a70SApple OSS Distributions * If the policy requires vnodes to have a valid label elsewhere it 5120*a1e26a70SApple OSS Distributions * MUST NOT return other than temporary errors, and must always provide 5121*a1e26a70SApple OSS Distributions * a valid label of some sort. Returning an error will cause vnode 5122*a1e26a70SApple OSS Distributions * labeling to be retried at a later access. Failure to handle policy 5123*a1e26a70SApple OSS Distributions * centric errors internally (corrupt labels etc.) will result in 5124*a1e26a70SApple OSS Distributions * inaccessible files. 5125*a1e26a70SApple OSS Distributions * 5126*a1e26a70SApple OSS Distributions * @return In the event of an error, an appropriate value for errno 5127*a1e26a70SApple OSS Distributions * should be returned, otherwise return 0 upon success. 5128*a1e26a70SApple OSS Distributions */ 5129*a1e26a70SApple OSS Distributions typedef int mpo_vnode_label_associate_extattr_t( 5130*a1e26a70SApple OSS Distributions struct mount *mp, 5131*a1e26a70SApple OSS Distributions struct label *mntlabel, 5132*a1e26a70SApple OSS Distributions struct vnode *vp, 5133*a1e26a70SApple OSS Distributions struct label *vlabel 5134*a1e26a70SApple OSS Distributions ); 5135*a1e26a70SApple OSS Distributions /** 5136*a1e26a70SApple OSS Distributions * @brief Associate a file label with a vnode 5137*a1e26a70SApple OSS Distributions * @param cred User credential 5138*a1e26a70SApple OSS Distributions * @param mp Fdesc mount point 5139*a1e26a70SApple OSS Distributions * @param mntlabel Fdesc mount point label 5140*a1e26a70SApple OSS Distributions * @param fg Fileglob structure 5141*a1e26a70SApple OSS Distributions * @param label Policy label for fg 5142*a1e26a70SApple OSS Distributions * @param vp Vnode to label 5143*a1e26a70SApple OSS Distributions * @param vlabel Label associated with vp 5144*a1e26a70SApple OSS Distributions * 5145*a1e26a70SApple OSS Distributions * Associate label information for the vnode, vp, with the label of 5146*a1e26a70SApple OSS Distributions * the open file descriptor described by fg. 5147*a1e26a70SApple OSS Distributions * The label should be stored in the supplied vlabel parameter. 5148*a1e26a70SApple OSS Distributions */ 5149*a1e26a70SApple OSS Distributions typedef void mpo_vnode_label_associate_file_t( 5150*a1e26a70SApple OSS Distributions struct ucred *cred, 5151*a1e26a70SApple OSS Distributions struct mount *mp, 5152*a1e26a70SApple OSS Distributions struct label *mntlabel, 5153*a1e26a70SApple OSS Distributions struct fileglob *fg, 5154*a1e26a70SApple OSS Distributions struct label *label, 5155*a1e26a70SApple OSS Distributions struct vnode *vp, 5156*a1e26a70SApple OSS Distributions struct label *vlabel 5157*a1e26a70SApple OSS Distributions ); 5158*a1e26a70SApple OSS Distributions /** 5159*a1e26a70SApple OSS Distributions * @brief Associate a pipe label with a vnode 5160*a1e26a70SApple OSS Distributions * @param cred User credential for the process that opened the pipe 5161*a1e26a70SApple OSS Distributions * @param cpipe Pipe structure 5162*a1e26a70SApple OSS Distributions * @param pipelabel Label associated with pipe 5163*a1e26a70SApple OSS Distributions * @param vp Vnode to label 5164*a1e26a70SApple OSS Distributions * @param vlabel Label associated with vp 5165*a1e26a70SApple OSS Distributions * 5166*a1e26a70SApple OSS Distributions * Associate label information for the vnode, vp, with the label of 5167*a1e26a70SApple OSS Distributions * the pipe described by the pipe structure cpipe. 5168*a1e26a70SApple OSS Distributions * The label should be stored in the supplied vlabel parameter. 5169*a1e26a70SApple OSS Distributions */ 5170*a1e26a70SApple OSS Distributions typedef void mpo_vnode_label_associate_pipe_t( 5171*a1e26a70SApple OSS Distributions struct ucred *cred, 5172*a1e26a70SApple OSS Distributions struct pipe *cpipe, 5173*a1e26a70SApple OSS Distributions struct label *pipelabel, 5174*a1e26a70SApple OSS Distributions struct vnode *vp, 5175*a1e26a70SApple OSS Distributions struct label *vlabel 5176*a1e26a70SApple OSS Distributions ); 5177*a1e26a70SApple OSS Distributions /** 5178*a1e26a70SApple OSS Distributions * @brief Associate a POSIX semaphore label with a vnode 5179*a1e26a70SApple OSS Distributions * @param cred User credential for the process that create psem 5180*a1e26a70SApple OSS Distributions * @param psem POSIX semaphore structure 5181*a1e26a70SApple OSS Distributions * @param psemlabel Label associated with psem 5182*a1e26a70SApple OSS Distributions * @param vp Vnode to label 5183*a1e26a70SApple OSS Distributions * @param vlabel Label associated with vp 5184*a1e26a70SApple OSS Distributions * 5185*a1e26a70SApple OSS Distributions * Associate label information for the vnode, vp, with the label of 5186*a1e26a70SApple OSS Distributions * the POSIX semaphore described by psem. 5187*a1e26a70SApple OSS Distributions * The label should be stored in the supplied vlabel parameter. 5188*a1e26a70SApple OSS Distributions */ 5189*a1e26a70SApple OSS Distributions typedef void mpo_vnode_label_associate_posixsem_t( 5190*a1e26a70SApple OSS Distributions struct ucred *cred, 5191*a1e26a70SApple OSS Distributions struct pseminfo *psem, 5192*a1e26a70SApple OSS Distributions struct label *psemlabel, 5193*a1e26a70SApple OSS Distributions struct vnode *vp, 5194*a1e26a70SApple OSS Distributions struct label *vlabel 5195*a1e26a70SApple OSS Distributions ); 5196*a1e26a70SApple OSS Distributions /** 5197*a1e26a70SApple OSS Distributions * @brief Associate a POSIX shared memory label with a vnode 5198*a1e26a70SApple OSS Distributions * @param cred User credential for the process that created pshm 5199*a1e26a70SApple OSS Distributions * @param pshm POSIX shared memory structure 5200*a1e26a70SApple OSS Distributions * @param pshmlabel Label associated with pshm 5201*a1e26a70SApple OSS Distributions * @param vp Vnode to label 5202*a1e26a70SApple OSS Distributions * @param vlabel Label associated with vp 5203*a1e26a70SApple OSS Distributions * 5204*a1e26a70SApple OSS Distributions * Associate label information for the vnode, vp, with the label of 5205*a1e26a70SApple OSS Distributions * the POSIX shared memory region described by pshm. 5206*a1e26a70SApple OSS Distributions * The label should be stored in the supplied vlabel parameter. 5207*a1e26a70SApple OSS Distributions */ 5208*a1e26a70SApple OSS Distributions typedef void mpo_vnode_label_associate_posixshm_t( 5209*a1e26a70SApple OSS Distributions struct ucred *cred, 5210*a1e26a70SApple OSS Distributions struct pshminfo *pshm, 5211*a1e26a70SApple OSS Distributions struct label *pshmlabel, 5212*a1e26a70SApple OSS Distributions struct vnode *vp, 5213*a1e26a70SApple OSS Distributions struct label *vlabel 5214*a1e26a70SApple OSS Distributions ); 5215*a1e26a70SApple OSS Distributions /** 5216*a1e26a70SApple OSS Distributions * @brief Associate a label with a vnode 5217*a1e26a70SApple OSS Distributions * @param mp File system mount point 5218*a1e26a70SApple OSS Distributions * @param mntlabel File system mount point label 5219*a1e26a70SApple OSS Distributions * @param vp Vnode to label 5220*a1e26a70SApple OSS Distributions * @param vlabel Label associated with vp 5221*a1e26a70SApple OSS Distributions * 5222*a1e26a70SApple OSS Distributions * On non-multilabel file systems, set the label for a vnode. The 5223*a1e26a70SApple OSS Distributions * label will most likely be based on the file system label. 5224*a1e26a70SApple OSS Distributions */ 5225*a1e26a70SApple OSS Distributions typedef void mpo_vnode_label_associate_singlelabel_t( 5226*a1e26a70SApple OSS Distributions struct mount *mp, 5227*a1e26a70SApple OSS Distributions struct label *mntlabel, 5228*a1e26a70SApple OSS Distributions struct vnode *vp, 5229*a1e26a70SApple OSS Distributions struct label *vlabel 5230*a1e26a70SApple OSS Distributions ); 5231*a1e26a70SApple OSS Distributions /** 5232*a1e26a70SApple OSS Distributions * @brief Associate a socket label with a vnode 5233*a1e26a70SApple OSS Distributions * @param cred User credential for the process that opened the socket 5234*a1e26a70SApple OSS Distributions * @param so Socket structure 5235*a1e26a70SApple OSS Distributions * @param solabel Label associated with so 5236*a1e26a70SApple OSS Distributions * @param vp Vnode to label 5237*a1e26a70SApple OSS Distributions * @param vlabel Label associated with vp 5238*a1e26a70SApple OSS Distributions * 5239*a1e26a70SApple OSS Distributions * Associate label information for the vnode, vp, with the label of 5240*a1e26a70SApple OSS Distributions * the open socket described by the socket structure so. 5241*a1e26a70SApple OSS Distributions * The label should be stored in the supplied vlabel parameter. 5242*a1e26a70SApple OSS Distributions */ 5243*a1e26a70SApple OSS Distributions typedef void mpo_vnode_label_associate_socket_t( 5244*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5245*a1e26a70SApple OSS Distributions socket_t so, 5246*a1e26a70SApple OSS Distributions struct label *solabel, 5247*a1e26a70SApple OSS Distributions struct vnode *vp, 5248*a1e26a70SApple OSS Distributions struct label *vlabel 5249*a1e26a70SApple OSS Distributions ); 5250*a1e26a70SApple OSS Distributions /** 5251*a1e26a70SApple OSS Distributions * @brief Copy a vnode label 5252*a1e26a70SApple OSS Distributions * @param src Source vnode label 5253*a1e26a70SApple OSS Distributions * @param dest Destination vnode label 5254*a1e26a70SApple OSS Distributions * 5255*a1e26a70SApple OSS Distributions * Copy the vnode label information from src to dest. On Darwin, this 5256*a1e26a70SApple OSS Distributions * is currently only necessary when executing interpreted scripts, but 5257*a1e26a70SApple OSS Distributions * will later be used if vnode label externalization cannot be an 5258*a1e26a70SApple OSS Distributions * atomic operation. 5259*a1e26a70SApple OSS Distributions */ 5260*a1e26a70SApple OSS Distributions typedef void mpo_vnode_label_copy_t( 5261*a1e26a70SApple OSS Distributions struct label *src, 5262*a1e26a70SApple OSS Distributions struct label *dest 5263*a1e26a70SApple OSS Distributions ); 5264*a1e26a70SApple OSS Distributions /** 5265*a1e26a70SApple OSS Distributions * @brief Destroy vnode label 5266*a1e26a70SApple OSS Distributions * @param label The label to be destroyed 5267*a1e26a70SApple OSS Distributions * 5268*a1e26a70SApple OSS Distributions * Destroy a vnode label. Since the object is going out of scope, 5269*a1e26a70SApple OSS Distributions * policy modules should free any internal storage associated with the 5270*a1e26a70SApple OSS Distributions * label so that it may be destroyed. 5271*a1e26a70SApple OSS Distributions */ 5272*a1e26a70SApple OSS Distributions typedef void mpo_vnode_label_destroy_t( 5273*a1e26a70SApple OSS Distributions struct label *label 5274*a1e26a70SApple OSS Distributions ); 5275*a1e26a70SApple OSS Distributions /** 5276*a1e26a70SApple OSS Distributions * @brief Externalize a vnode label for auditing 5277*a1e26a70SApple OSS Distributions * @param label Label to be externalized 5278*a1e26a70SApple OSS Distributions * @param element_name Name of the label namespace for which labels should be 5279*a1e26a70SApple OSS Distributions * externalized 5280*a1e26a70SApple OSS Distributions * @param sb String buffer to be filled with a text representation of the label 5281*a1e26a70SApple OSS Distributions * 5282*a1e26a70SApple OSS Distributions * Produce an external representation of the label on a vnode suitable for 5283*a1e26a70SApple OSS Distributions * inclusion in an audit record. An externalized label consists of a text 5284*a1e26a70SApple OSS Distributions * representation of the label contents that will be added to the audit record 5285*a1e26a70SApple OSS Distributions * as part of a text token. Policy-agnostic user space tools will display 5286*a1e26a70SApple OSS Distributions * this externalized version. 5287*a1e26a70SApple OSS Distributions * 5288*a1e26a70SApple OSS Distributions * @return 0 on success, return non-zero if an error occurs while 5289*a1e26a70SApple OSS Distributions * externalizing the label data. 5290*a1e26a70SApple OSS Distributions * 5291*a1e26a70SApple OSS Distributions */ 5292*a1e26a70SApple OSS Distributions typedef int mpo_vnode_label_externalize_audit_t( 5293*a1e26a70SApple OSS Distributions struct label *label, 5294*a1e26a70SApple OSS Distributions char *element_name, 5295*a1e26a70SApple OSS Distributions struct sbuf *sb 5296*a1e26a70SApple OSS Distributions ); 5297*a1e26a70SApple OSS Distributions /** 5298*a1e26a70SApple OSS Distributions * @brief Externalize a vnode label 5299*a1e26a70SApple OSS Distributions * @param label Label to be externalized 5300*a1e26a70SApple OSS Distributions * @param element_name Name of the label namespace for which labels should be 5301*a1e26a70SApple OSS Distributions * externalized 5302*a1e26a70SApple OSS Distributions * @param sb String buffer to be filled with a text representation of the label 5303*a1e26a70SApple OSS Distributions * 5304*a1e26a70SApple OSS Distributions * Produce an external representation of the label on a vnode. An 5305*a1e26a70SApple OSS Distributions * externalized label consists of a text representation of the label 5306*a1e26a70SApple OSS Distributions * contents that can be used with user applications. Policy-agnostic 5307*a1e26a70SApple OSS Distributions * user space tools will display this externalized version. 5308*a1e26a70SApple OSS Distributions * 5309*a1e26a70SApple OSS Distributions * @return 0 on success, return non-zero if an error occurs while 5310*a1e26a70SApple OSS Distributions * externalizing the label data. 5311*a1e26a70SApple OSS Distributions * 5312*a1e26a70SApple OSS Distributions */ 5313*a1e26a70SApple OSS Distributions typedef int mpo_vnode_label_externalize_t( 5314*a1e26a70SApple OSS Distributions struct label *label, 5315*a1e26a70SApple OSS Distributions char *element_name, 5316*a1e26a70SApple OSS Distributions struct sbuf *sb 5317*a1e26a70SApple OSS Distributions ); 5318*a1e26a70SApple OSS Distributions /** 5319*a1e26a70SApple OSS Distributions * @brief Initialize vnode label 5320*a1e26a70SApple OSS Distributions * @param label New label to initialize 5321*a1e26a70SApple OSS Distributions * 5322*a1e26a70SApple OSS Distributions * Initialize label storage for use with a newly instantiated vnode, or 5323*a1e26a70SApple OSS Distributions * for temporary storage associated with the copying in or out of a 5324*a1e26a70SApple OSS Distributions * vnode label. While it is necessary to allocate space for a 5325*a1e26a70SApple OSS Distributions * kernel-resident vnode label, it is not yet necessary to link this vnode 5326*a1e26a70SApple OSS Distributions * with persistent label storage facilities, such as extended attributes. 5327*a1e26a70SApple OSS Distributions * Sleeping is permitted. 5328*a1e26a70SApple OSS Distributions */ 5329*a1e26a70SApple OSS Distributions typedef void mpo_vnode_label_init_t( 5330*a1e26a70SApple OSS Distributions struct label *label 5331*a1e26a70SApple OSS Distributions ); 5332*a1e26a70SApple OSS Distributions /** 5333*a1e26a70SApple OSS Distributions * @brief Internalize a vnode label 5334*a1e26a70SApple OSS Distributions * @param label Label to be internalized 5335*a1e26a70SApple OSS Distributions * @param element_name Name of the label namespace for which the label should 5336*a1e26a70SApple OSS Distributions * be internalized 5337*a1e26a70SApple OSS Distributions * @param element_data Text data to be internalized 5338*a1e26a70SApple OSS Distributions * 5339*a1e26a70SApple OSS Distributions * Produce a vnode label from an external representation. An 5340*a1e26a70SApple OSS Distributions * externalized label consists of a text representation of the label 5341*a1e26a70SApple OSS Distributions * contents that can be used with user applications. Policy-agnostic 5342*a1e26a70SApple OSS Distributions * user space tools will forward text version to the kernel for 5343*a1e26a70SApple OSS Distributions * processing by individual policy modules. 5344*a1e26a70SApple OSS Distributions * 5345*a1e26a70SApple OSS Distributions * The policy's internalize entry points will be called only if the 5346*a1e26a70SApple OSS Distributions * policy has registered interest in the label namespace. 5347*a1e26a70SApple OSS Distributions * 5348*a1e26a70SApple OSS Distributions * @return 0 on success, Otherwise, return non-zero if an error occurs 5349*a1e26a70SApple OSS Distributions * while internalizing the label data. 5350*a1e26a70SApple OSS Distributions */ 5351*a1e26a70SApple OSS Distributions typedef int mpo_vnode_label_internalize_t( 5352*a1e26a70SApple OSS Distributions struct label *label, 5353*a1e26a70SApple OSS Distributions char *element_name, 5354*a1e26a70SApple OSS Distributions char *element_data 5355*a1e26a70SApple OSS Distributions ); 5356*a1e26a70SApple OSS Distributions /** 5357*a1e26a70SApple OSS Distributions * @brief Clean up a vnode label 5358*a1e26a70SApple OSS Distributions * @param label The label to be cleaned or purged 5359*a1e26a70SApple OSS Distributions * 5360*a1e26a70SApple OSS Distributions * Clean up a vnode label. Darwin (Tiger, 8.x) allocates vnodes on demand, but 5361*a1e26a70SApple OSS Distributions * typically never frees them. Before vnodes are placed back on free lists for 5362*a1e26a70SApple OSS Distributions * re-use, policies can cleanup or overwrite any information present in the label, 5363*a1e26a70SApple OSS Distributions * or free any internal resources used for the label. 5364*a1e26a70SApple OSS Distributions */ 5365*a1e26a70SApple OSS Distributions typedef void mpo_vnode_label_recycle_t( 5366*a1e26a70SApple OSS Distributions struct label *label 5367*a1e26a70SApple OSS Distributions ); 5368*a1e26a70SApple OSS Distributions /** 5369*a1e26a70SApple OSS Distributions * @brief Write a label to a extended attribute 5370*a1e26a70SApple OSS Distributions * @param cred Subject credential 5371*a1e26a70SApple OSS Distributions * @param vp The vnode for which the label is being stored 5372*a1e26a70SApple OSS Distributions * @param vlabel Label associated with vp 5373*a1e26a70SApple OSS Distributions * @param intlabel The new label to store 5374*a1e26a70SApple OSS Distributions * 5375*a1e26a70SApple OSS Distributions * Store a new label in the extended attribute corresponding to the 5376*a1e26a70SApple OSS Distributions * supplied vnode. The policy has already authorized the operation; 5377*a1e26a70SApple OSS Distributions * this call must be implemented in order to perform the actual 5378*a1e26a70SApple OSS Distributions * operation. 5379*a1e26a70SApple OSS Distributions * 5380*a1e26a70SApple OSS Distributions * @return In the event of an error, an appropriate value for errno 5381*a1e26a70SApple OSS Distributions * should be returned, otherwise return 0 upon success. 5382*a1e26a70SApple OSS Distributions * 5383*a1e26a70SApple OSS Distributions * @warning XXX After examining the extended attribute implementation on 5384*a1e26a70SApple OSS Distributions * Apple's future release, this entry point may be changed. 5385*a1e26a70SApple OSS Distributions */ 5386*a1e26a70SApple OSS Distributions typedef int mpo_vnode_label_store_t( 5387*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5388*a1e26a70SApple OSS Distributions struct vnode *vp, 5389*a1e26a70SApple OSS Distributions struct label *vlabel, 5390*a1e26a70SApple OSS Distributions struct label *intlabel 5391*a1e26a70SApple OSS Distributions ); 5392*a1e26a70SApple OSS Distributions /** 5393*a1e26a70SApple OSS Distributions * @brief Update vnode label from extended attributes 5394*a1e26a70SApple OSS Distributions * @param mp File system mount point 5395*a1e26a70SApple OSS Distributions * @param mntlabel Mount point label 5396*a1e26a70SApple OSS Distributions * @param vp Vnode to label 5397*a1e26a70SApple OSS Distributions * @param vlabel Label associated with vp 5398*a1e26a70SApple OSS Distributions * @param name Name of the xattr 5399*a1e26a70SApple OSS Distributions * @see mpo_vnode_check_setextattr_t 5400*a1e26a70SApple OSS Distributions * 5401*a1e26a70SApple OSS Distributions * When an extended attribute is updated via the Vendor attribute management 5402*a1e26a70SApple OSS Distributions * functions, the MAC vnode label might also require an update. 5403*a1e26a70SApple OSS Distributions * Policies should first determine if 'name' matches their xattr label 5404*a1e26a70SApple OSS Distributions * name. If it does, the kernel is has either replaced or removed the 5405*a1e26a70SApple OSS Distributions * named extended attribute that was previously associated with the 5406*a1e26a70SApple OSS Distributions * vnode. Normally labels should only be modified via MAC Framework label 5407*a1e26a70SApple OSS Distributions * management calls, but sometimes the user space components will directly 5408*a1e26a70SApple OSS Distributions * modify extended attributes. For example, 'cp', 'tar', etc. manage 5409*a1e26a70SApple OSS Distributions * extended attributes in userspace, not the kernel. 5410*a1e26a70SApple OSS Distributions * 5411*a1e26a70SApple OSS Distributions * This entry point is called after the label update has occurred, so 5412*a1e26a70SApple OSS Distributions * it cannot return a failure. However, the operation is preceded by 5413*a1e26a70SApple OSS Distributions * the mpo_vnode_check_setextattr() access control check. 5414*a1e26a70SApple OSS Distributions * 5415*a1e26a70SApple OSS Distributions * If the vnode label needs to be updated the policy should return 5416*a1e26a70SApple OSS Distributions * a non-zero value. The vnode label will be marked for re-association 5417*a1e26a70SApple OSS Distributions * by the framework. 5418*a1e26a70SApple OSS Distributions */ 5419*a1e26a70SApple OSS Distributions typedef int mpo_vnode_label_update_extattr_t( 5420*a1e26a70SApple OSS Distributions struct mount *mp, 5421*a1e26a70SApple OSS Distributions struct label *mntlabel, 5422*a1e26a70SApple OSS Distributions struct vnode *vp, 5423*a1e26a70SApple OSS Distributions struct label *vlabel, 5424*a1e26a70SApple OSS Distributions const char *name 5425*a1e26a70SApple OSS Distributions ); 5426*a1e26a70SApple OSS Distributions /** 5427*a1e26a70SApple OSS Distributions * @brief Update a vnode label 5428*a1e26a70SApple OSS Distributions * @param cred Subject credential 5429*a1e26a70SApple OSS Distributions * @param vp The vnode to relabel 5430*a1e26a70SApple OSS Distributions * @param vnodelabel Existing vnode label 5431*a1e26a70SApple OSS Distributions * @param label New label to replace existing label 5432*a1e26a70SApple OSS Distributions * @see mpo_vnode_check_label_update_t 5433*a1e26a70SApple OSS Distributions * 5434*a1e26a70SApple OSS Distributions * The subject identified by the credential has previously requested 5435*a1e26a70SApple OSS Distributions * and was authorized to relabel the vnode; this entry point allows 5436*a1e26a70SApple OSS Distributions * policies to perform the actual relabel operation. Policies should 5437*a1e26a70SApple OSS Distributions * update vnodelabel using the label stored in the label parameter. 5438*a1e26a70SApple OSS Distributions */ 5439*a1e26a70SApple OSS Distributions typedef void mpo_vnode_label_update_t( 5440*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5441*a1e26a70SApple OSS Distributions struct vnode *vp, 5442*a1e26a70SApple OSS Distributions struct label *vnodelabel, 5443*a1e26a70SApple OSS Distributions struct label *label 5444*a1e26a70SApple OSS Distributions ); 5445*a1e26a70SApple OSS Distributions /** 5446*a1e26a70SApple OSS Distributions * @brief Find deatched signatures for a shared library 5447*a1e26a70SApple OSS Distributions * @param p file trying to find the signature 5448*a1e26a70SApple OSS Distributions * @param vp The vnode to relabel 5449*a1e26a70SApple OSS Distributions * @param offset offset in the Mach-O that the signature is requested for (for fat binaries) 5450*a1e26a70SApple OSS Distributions * @param label Existing vnode label 5451*a1e26a70SApple OSS Distributions * 5452*a1e26a70SApple OSS Distributions */ 5453*a1e26a70SApple OSS Distributions typedef int mpo_vnode_find_sigs_t( 5454*a1e26a70SApple OSS Distributions struct proc *p, 5455*a1e26a70SApple OSS Distributions struct vnode *vp, 5456*a1e26a70SApple OSS Distributions off_t offset, 5457*a1e26a70SApple OSS Distributions struct label *label 5458*a1e26a70SApple OSS Distributions ); 5459*a1e26a70SApple OSS Distributions /** 5460*a1e26a70SApple OSS Distributions * @brief Create a new vnode, backed by extended attributes 5461*a1e26a70SApple OSS Distributions * @param cred User credential for the creating process 5462*a1e26a70SApple OSS Distributions * @param mp File system mount point 5463*a1e26a70SApple OSS Distributions * @param mntlabel File system mount point label 5464*a1e26a70SApple OSS Distributions * @param dvp Parent directory vnode 5465*a1e26a70SApple OSS Distributions * @param dlabel Parent directory vnode label 5466*a1e26a70SApple OSS Distributions * @param vp Newly created vnode 5467*a1e26a70SApple OSS Distributions * @param vlabel Label to associate with the new vnode 5468*a1e26a70SApple OSS Distributions * @param cnp Component name for vp 5469*a1e26a70SApple OSS Distributions * 5470*a1e26a70SApple OSS Distributions * Write out the label for the newly created vnode, most likely storing 5471*a1e26a70SApple OSS Distributions * the results in a file system extended attribute. Most policies will 5472*a1e26a70SApple OSS Distributions * derive the new vnode label using information from a combination 5473*a1e26a70SApple OSS Distributions * of the subject (user) credential, the file system label, the parent 5474*a1e26a70SApple OSS Distributions * directory label, and potentially the path name component. 5475*a1e26a70SApple OSS Distributions * 5476*a1e26a70SApple OSS Distributions * @return If the operation succeeds, store the new label in vlabel and 5477*a1e26a70SApple OSS Distributions * return 0. Otherwise, return an appropriate errno value. 5478*a1e26a70SApple OSS Distributions */ 5479*a1e26a70SApple OSS Distributions typedef int mpo_vnode_notify_create_t( 5480*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5481*a1e26a70SApple OSS Distributions struct mount *mp, 5482*a1e26a70SApple OSS Distributions struct label *mntlabel, 5483*a1e26a70SApple OSS Distributions struct vnode *dvp, 5484*a1e26a70SApple OSS Distributions struct label *dlabel, 5485*a1e26a70SApple OSS Distributions struct vnode *vp, 5486*a1e26a70SApple OSS Distributions struct label *vlabel, 5487*a1e26a70SApple OSS Distributions struct componentname *cnp 5488*a1e26a70SApple OSS Distributions ); 5489*a1e26a70SApple OSS Distributions 5490*a1e26a70SApple OSS Distributions /** 5491*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that a vnode has been opened 5492*a1e26a70SApple OSS Distributions * @param cred User credential for the creating process 5493*a1e26a70SApple OSS Distributions * @param vp vnode opened 5494*a1e26a70SApple OSS Distributions * @param label Policy label for the vp 5495*a1e26a70SApple OSS Distributions * @param acc_mode open(2) access mode used 5496*a1e26a70SApple OSS Distributions * 5497*a1e26a70SApple OSS Distributions * Inform Mac policies that a vnode have been successfully opened 5498*a1e26a70SApple OSS Distributions * (passing all MAC polices and DAC). 5499*a1e26a70SApple OSS Distributions */ 5500*a1e26a70SApple OSS Distributions typedef void mpo_vnode_notify_open_t( 5501*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5502*a1e26a70SApple OSS Distributions struct vnode *vp, 5503*a1e26a70SApple OSS Distributions struct label *label, 5504*a1e26a70SApple OSS Distributions int acc_mode 5505*a1e26a70SApple OSS Distributions ); 5506*a1e26a70SApple OSS Distributions 5507*a1e26a70SApple OSS Distributions /** 5508*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that a vnode has been renamed 5509*a1e26a70SApple OSS Distributions * @param cred User credential for the renaming process 5510*a1e26a70SApple OSS Distributions * @param vp Vnode that's being renamed 5511*a1e26a70SApple OSS Distributions * @param label Policy label for vp 5512*a1e26a70SApple OSS Distributions * @param dvp Parent directory for the destination 5513*a1e26a70SApple OSS Distributions * @param dlabel Policy label for dvp 5514*a1e26a70SApple OSS Distributions * @param cnp Component name for the destination 5515*a1e26a70SApple OSS Distributions * 5516*a1e26a70SApple OSS Distributions * Inform MAC policies that a vnode has been renamed. 5517*a1e26a70SApple OSS Distributions */ 5518*a1e26a70SApple OSS Distributions typedef void mpo_vnode_notify_rename_t( 5519*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5520*a1e26a70SApple OSS Distributions struct vnode *vp, 5521*a1e26a70SApple OSS Distributions struct label *label, 5522*a1e26a70SApple OSS Distributions struct vnode *dvp, 5523*a1e26a70SApple OSS Distributions struct label *dlabel, 5524*a1e26a70SApple OSS Distributions struct componentname *cnp 5525*a1e26a70SApple OSS Distributions ); 5526*a1e26a70SApple OSS Distributions 5527*a1e26a70SApple OSS Distributions /** 5528*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that two vnodes were atomically swapped. 5529*a1e26a70SApple OSS Distributions * @param cred User credential for the renaming process 5530*a1e26a70SApple OSS Distributions * @param v1 vnode 1 to swap 5531*a1e26a70SApple OSS Distributions * @param vl1 Policy label for v1 5532*a1e26a70SApple OSS Distributions * @param v2 vnode 2 to swap 5533*a1e26a70SApple OSS Distributions * @param vl2 Policy label for v2 5534*a1e26a70SApple OSS Distributions * 5535*a1e26a70SApple OSS Distributions * Inform MAC policies that two vnodes were atomically swapped. 5536*a1e26a70SApple OSS Distributions * NOTE: If a policy implements this notify hook, then this hook will be 5537*a1e26a70SApple OSS Distributions * called instead of two calls to the vnode_notify_rename hook (one for each 5538*a1e26a70SApple OSS Distributions * member of the swap). 5539*a1e26a70SApple OSS Distributions */ 5540*a1e26a70SApple OSS Distributions typedef void mpo_vnode_notify_swap_t( 5541*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5542*a1e26a70SApple OSS Distributions struct vnode *v1, 5543*a1e26a70SApple OSS Distributions struct label *vl1, 5544*a1e26a70SApple OSS Distributions struct vnode *v2, 5545*a1e26a70SApple OSS Distributions struct label *vl2 5546*a1e26a70SApple OSS Distributions ); 5547*a1e26a70SApple OSS Distributions 5548*a1e26a70SApple OSS Distributions /** 5549*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that a vnode has been linked 5550*a1e26a70SApple OSS Distributions * @param cred User credential for the renaming process 5551*a1e26a70SApple OSS Distributions * @param dvp Parent directory for the destination 5552*a1e26a70SApple OSS Distributions * @param dlabel Policy label for dvp 5553*a1e26a70SApple OSS Distributions * @param vp Vnode that's being linked 5554*a1e26a70SApple OSS Distributions * @param vlabel Policy label for vp 5555*a1e26a70SApple OSS Distributions * @param cnp Component name for the destination 5556*a1e26a70SApple OSS Distributions * 5557*a1e26a70SApple OSS Distributions * Inform MAC policies that a vnode has been linked. 5558*a1e26a70SApple OSS Distributions */ 5559*a1e26a70SApple OSS Distributions typedef void mpo_vnode_notify_link_t( 5560*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5561*a1e26a70SApple OSS Distributions struct vnode *dvp, 5562*a1e26a70SApple OSS Distributions struct label *dlabel, 5563*a1e26a70SApple OSS Distributions struct vnode *vp, 5564*a1e26a70SApple OSS Distributions struct label *vlabel, 5565*a1e26a70SApple OSS Distributions struct componentname *cnp 5566*a1e26a70SApple OSS Distributions ); 5567*a1e26a70SApple OSS Distributions 5568*a1e26a70SApple OSS Distributions /** 5569*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that an extended attribute has been removed from a vnode 5570*a1e26a70SApple OSS Distributions * @param cred Subject credential 5571*a1e26a70SApple OSS Distributions * @param vp Object node 5572*a1e26a70SApple OSS Distributions * @param label Policy label for vp 5573*a1e26a70SApple OSS Distributions * @param name Extended attribute name 5574*a1e26a70SApple OSS Distributions * 5575*a1e26a70SApple OSS Distributions * Inform MAC policies that an extended attribute has been removed from a vnode. 5576*a1e26a70SApple OSS Distributions */ 5577*a1e26a70SApple OSS Distributions typedef void mpo_vnode_notify_deleteextattr_t( 5578*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5579*a1e26a70SApple OSS Distributions struct vnode *vp, 5580*a1e26a70SApple OSS Distributions struct label *label, 5581*a1e26a70SApple OSS Distributions const char *name 5582*a1e26a70SApple OSS Distributions ); 5583*a1e26a70SApple OSS Distributions 5584*a1e26a70SApple OSS Distributions 5585*a1e26a70SApple OSS Distributions /** 5586*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that an ACL has been set on a vnode 5587*a1e26a70SApple OSS Distributions * @param cred Subject credential 5588*a1e26a70SApple OSS Distributions * @param vp Object node 5589*a1e26a70SApple OSS Distributions * @param label Policy label for vp 5590*a1e26a70SApple OSS Distributions * @param acl ACL structure pointer 5591*a1e26a70SApple OSS Distributions * 5592*a1e26a70SApple OSS Distributions * Inform MAC policies that an ACL has been set on a vnode. 5593*a1e26a70SApple OSS Distributions */ 5594*a1e26a70SApple OSS Distributions typedef void mpo_vnode_notify_setacl_t( 5595*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5596*a1e26a70SApple OSS Distributions struct vnode *vp, 5597*a1e26a70SApple OSS Distributions struct label *label, 5598*a1e26a70SApple OSS Distributions struct kauth_acl *acl 5599*a1e26a70SApple OSS Distributions ); 5600*a1e26a70SApple OSS Distributions 5601*a1e26a70SApple OSS Distributions /** 5602*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that an attributes have been set on a vnode 5603*a1e26a70SApple OSS Distributions * @param cred Subject credential 5604*a1e26a70SApple OSS Distributions * @param vp Object vnode 5605*a1e26a70SApple OSS Distributions * @param label Policy label for vp 5606*a1e26a70SApple OSS Distributions * @param alist List of attributes to set 5607*a1e26a70SApple OSS Distributions * 5608*a1e26a70SApple OSS Distributions * Inform MAC policies that an attributes have been set on a vnode. 5609*a1e26a70SApple OSS Distributions */ 5610*a1e26a70SApple OSS Distributions typedef void mpo_vnode_notify_setattrlist_t( 5611*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5612*a1e26a70SApple OSS Distributions struct vnode *vp, 5613*a1e26a70SApple OSS Distributions struct label *label, 5614*a1e26a70SApple OSS Distributions struct attrlist *alist 5615*a1e26a70SApple OSS Distributions ); 5616*a1e26a70SApple OSS Distributions 5617*a1e26a70SApple OSS Distributions /** 5618*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that an extended attribute has been set on a vnode 5619*a1e26a70SApple OSS Distributions * @param cred Subject credential 5620*a1e26a70SApple OSS Distributions * @param vp Object vnode 5621*a1e26a70SApple OSS Distributions * @param label Policy label for vp 5622*a1e26a70SApple OSS Distributions * @param name Extended attribute name 5623*a1e26a70SApple OSS Distributions * @param uio I/O structure pointer 5624*a1e26a70SApple OSS Distributions * 5625*a1e26a70SApple OSS Distributions * Inform MAC policies that an extended attribute has been set on a vnode. 5626*a1e26a70SApple OSS Distributions */ 5627*a1e26a70SApple OSS Distributions typedef void mpo_vnode_notify_setextattr_t( 5628*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5629*a1e26a70SApple OSS Distributions struct vnode *vp, 5630*a1e26a70SApple OSS Distributions struct label *label, 5631*a1e26a70SApple OSS Distributions const char *name, 5632*a1e26a70SApple OSS Distributions struct uio *uio 5633*a1e26a70SApple OSS Distributions ); 5634*a1e26a70SApple OSS Distributions 5635*a1e26a70SApple OSS Distributions /** 5636*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that flags have been set on a vnode 5637*a1e26a70SApple OSS Distributions * @param cred Subject credential 5638*a1e26a70SApple OSS Distributions * @param vp Object vnode 5639*a1e26a70SApple OSS Distributions * @param label Policy label for vp 5640*a1e26a70SApple OSS Distributions * @param flags File flags; see chflags(2) 5641*a1e26a70SApple OSS Distributions * 5642*a1e26a70SApple OSS Distributions * Inform MAC policies that flags have been set on a vnode. 5643*a1e26a70SApple OSS Distributions */ 5644*a1e26a70SApple OSS Distributions typedef void mpo_vnode_notify_setflags_t( 5645*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5646*a1e26a70SApple OSS Distributions struct vnode *vp, 5647*a1e26a70SApple OSS Distributions struct label *label, 5648*a1e26a70SApple OSS Distributions u_long flags 5649*a1e26a70SApple OSS Distributions ); 5650*a1e26a70SApple OSS Distributions 5651*a1e26a70SApple OSS Distributions /** 5652*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that a new mode has been set on a vnode 5653*a1e26a70SApple OSS Distributions * @param cred Subject credential 5654*a1e26a70SApple OSS Distributions * @param vp Object vnode 5655*a1e26a70SApple OSS Distributions * @param label Policy label for vp 5656*a1e26a70SApple OSS Distributions * @param mode File mode; see chmod(2) 5657*a1e26a70SApple OSS Distributions * 5658*a1e26a70SApple OSS Distributions * Inform MAC policies that a new mode has been set on a vnode. 5659*a1e26a70SApple OSS Distributions */ 5660*a1e26a70SApple OSS Distributions typedef void mpo_vnode_notify_setmode_t( 5661*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5662*a1e26a70SApple OSS Distributions struct vnode *vp, 5663*a1e26a70SApple OSS Distributions struct label *label, 5664*a1e26a70SApple OSS Distributions mode_t mode 5665*a1e26a70SApple OSS Distributions ); 5666*a1e26a70SApple OSS Distributions 5667*a1e26a70SApple OSS Distributions /** 5668*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that new uid/gid have been set on a vnode 5669*a1e26a70SApple OSS Distributions * @param cred Subject credential 5670*a1e26a70SApple OSS Distributions * @param vp Object vnode 5671*a1e26a70SApple OSS Distributions * @param label Policy label for vp 5672*a1e26a70SApple OSS Distributions * @param uid User ID 5673*a1e26a70SApple OSS Distributions * @param gid Group ID 5674*a1e26a70SApple OSS Distributions * 5675*a1e26a70SApple OSS Distributions * Inform MAC policies that new uid/gid have been set on a vnode. 5676*a1e26a70SApple OSS Distributions */ 5677*a1e26a70SApple OSS Distributions typedef void mpo_vnode_notify_setowner_t( 5678*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5679*a1e26a70SApple OSS Distributions struct vnode *vp, 5680*a1e26a70SApple OSS Distributions struct label *label, 5681*a1e26a70SApple OSS Distributions uid_t uid, 5682*a1e26a70SApple OSS Distributions gid_t gid 5683*a1e26a70SApple OSS Distributions ); 5684*a1e26a70SApple OSS Distributions 5685*a1e26a70SApple OSS Distributions /** 5686*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that new timestamps have been set on a vnode 5687*a1e26a70SApple OSS Distributions * @param cred Subject credential 5688*a1e26a70SApple OSS Distributions * @param vp Object vnode 5689*a1e26a70SApple OSS Distributions * @param label Policy label for vp 5690*a1e26a70SApple OSS Distributions * @param atime Access time; see utimes(2) 5691*a1e26a70SApple OSS Distributions * @param mtime Modification time; see utimes(2) 5692*a1e26a70SApple OSS Distributions * 5693*a1e26a70SApple OSS Distributions * Inform MAC policies that new timestamps have been set on a vnode. 5694*a1e26a70SApple OSS Distributions */ 5695*a1e26a70SApple OSS Distributions typedef void mpo_vnode_notify_setutimes_t( 5696*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5697*a1e26a70SApple OSS Distributions struct vnode *vp, 5698*a1e26a70SApple OSS Distributions struct label *label, 5699*a1e26a70SApple OSS Distributions struct timespec atime, 5700*a1e26a70SApple OSS Distributions struct timespec mtime 5701*a1e26a70SApple OSS Distributions ); 5702*a1e26a70SApple OSS Distributions 5703*a1e26a70SApple OSS Distributions /** 5704*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that a vnode has been truncated 5705*a1e26a70SApple OSS Distributions * @param cred Subject credential 5706*a1e26a70SApple OSS Distributions * @param file_cred Credential associated with the struct fileproc 5707*a1e26a70SApple OSS Distributions * @param vp Object vnode 5708*a1e26a70SApple OSS Distributions * @param label Policy label for vp 5709*a1e26a70SApple OSS Distributions * 5710*a1e26a70SApple OSS Distributions * Inform MAC policies that a vnode has been truncated. 5711*a1e26a70SApple OSS Distributions */ 5712*a1e26a70SApple OSS Distributions typedef void mpo_vnode_notify_truncate_t( 5713*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5714*a1e26a70SApple OSS Distributions kauth_cred_t file_cred, 5715*a1e26a70SApple OSS Distributions struct vnode *vp, 5716*a1e26a70SApple OSS Distributions struct label *label 5717*a1e26a70SApple OSS Distributions ); 5718*a1e26a70SApple OSS Distributions 5719*a1e26a70SApple OSS Distributions 5720*a1e26a70SApple OSS Distributions /** 5721*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that a pty slave has been granted 5722*a1e26a70SApple OSS Distributions * @param p Responsible process 5723*a1e26a70SApple OSS Distributions * @param tp tty data structure 5724*a1e26a70SApple OSS Distributions * @param dev Major and minor numbers of device 5725*a1e26a70SApple OSS Distributions * @param label Policy label for tp 5726*a1e26a70SApple OSS Distributions * 5727*a1e26a70SApple OSS Distributions * Inform MAC policies that a pty slave has been granted. 5728*a1e26a70SApple OSS Distributions */ 5729*a1e26a70SApple OSS Distributions typedef void mpo_pty_notify_grant_t( 5730*a1e26a70SApple OSS Distributions proc_t p, 5731*a1e26a70SApple OSS Distributions struct tty *tp, 5732*a1e26a70SApple OSS Distributions dev_t dev, 5733*a1e26a70SApple OSS Distributions struct label *label 5734*a1e26a70SApple OSS Distributions ); 5735*a1e26a70SApple OSS Distributions 5736*a1e26a70SApple OSS Distributions /** 5737*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that a pty master has been closed 5738*a1e26a70SApple OSS Distributions * @param p Responsible process 5739*a1e26a70SApple OSS Distributions * @param tp tty data structure 5740*a1e26a70SApple OSS Distributions * @param dev Major and minor numbers of device 5741*a1e26a70SApple OSS Distributions * @param label Policy label for tp 5742*a1e26a70SApple OSS Distributions * 5743*a1e26a70SApple OSS Distributions * Inform MAC policies that a pty master has been closed. 5744*a1e26a70SApple OSS Distributions */ 5745*a1e26a70SApple OSS Distributions typedef void mpo_pty_notify_close_t( 5746*a1e26a70SApple OSS Distributions proc_t p, 5747*a1e26a70SApple OSS Distributions struct tty *tp, 5748*a1e26a70SApple OSS Distributions dev_t dev, 5749*a1e26a70SApple OSS Distributions struct label *label 5750*a1e26a70SApple OSS Distributions ); 5751*a1e26a70SApple OSS Distributions 5752*a1e26a70SApple OSS Distributions /** 5753*a1e26a70SApple OSS Distributions * @brief Access control check for kext loading 5754*a1e26a70SApple OSS Distributions * @param cred Subject credential 5755*a1e26a70SApple OSS Distributions * @param identifier Kext identifier 5756*a1e26a70SApple OSS Distributions * 5757*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can load the 5758*a1e26a70SApple OSS Distributions * specified kext. 5759*a1e26a70SApple OSS Distributions * 5760*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 5761*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EPERM for lack of privilege. 5762*a1e26a70SApple OSS Distributions */ 5763*a1e26a70SApple OSS Distributions typedef int mpo_kext_check_load_t( 5764*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5765*a1e26a70SApple OSS Distributions const char *identifier 5766*a1e26a70SApple OSS Distributions ); 5767*a1e26a70SApple OSS Distributions 5768*a1e26a70SApple OSS Distributions /** 5769*a1e26a70SApple OSS Distributions * @brief Access control check for kext unloading 5770*a1e26a70SApple OSS Distributions * @param cred Subject credential 5771*a1e26a70SApple OSS Distributions * @param identifier Kext identifier 5772*a1e26a70SApple OSS Distributions * 5773*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can unload the 5774*a1e26a70SApple OSS Distributions * specified kext. 5775*a1e26a70SApple OSS Distributions * 5776*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 5777*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EPERM for lack of privilege. 5778*a1e26a70SApple OSS Distributions */ 5779*a1e26a70SApple OSS Distributions typedef int mpo_kext_check_unload_t( 5780*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5781*a1e26a70SApple OSS Distributions const char *identifier 5782*a1e26a70SApple OSS Distributions ); 5783*a1e26a70SApple OSS Distributions 5784*a1e26a70SApple OSS Distributions /** 5785*a1e26a70SApple OSS Distributions * @brief Access control check for querying information about loaded kexts 5786*a1e26a70SApple OSS Distributions * @param cred Subject credential 5787*a1e26a70SApple OSS Distributions * 5788*a1e26a70SApple OSS Distributions * Determine whether the subject identified by the credential can query 5789*a1e26a70SApple OSS Distributions * information about loaded kexts. 5790*a1e26a70SApple OSS Distributions * 5791*a1e26a70SApple OSS Distributions * @return Return 0 if access is granted, otherwise an appropriate value for 5792*a1e26a70SApple OSS Distributions * errno should be returned. Suggested failure: EPERM for lack of privilege. 5793*a1e26a70SApple OSS Distributions */ 5794*a1e26a70SApple OSS Distributions typedef int mpo_kext_check_query_t( 5795*a1e26a70SApple OSS Distributions kauth_cred_t cred 5796*a1e26a70SApple OSS Distributions ); 5797*a1e26a70SApple OSS Distributions 5798*a1e26a70SApple OSS Distributions /** 5799*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that a vnode is being reclaimed 5800*a1e26a70SApple OSS Distributions * @param vp Object vnode 5801*a1e26a70SApple OSS Distributions * 5802*a1e26a70SApple OSS Distributions * Any external accounting tracking this vnode must consider it to be no longer valid. 5803*a1e26a70SApple OSS Distributions */ 5804*a1e26a70SApple OSS Distributions typedef void mpo_vnode_notify_reclaim_t( 5805*a1e26a70SApple OSS Distributions struct vnode *vp 5806*a1e26a70SApple OSS Distributions ); 5807*a1e26a70SApple OSS Distributions 5808*a1e26a70SApple OSS Distributions /** 5809*a1e26a70SApple OSS Distributions * @brief Inform MAC policies that a vnode has been deleted 5810*a1e26a70SApple OSS Distributions * @param cred Subject credential 5811*a1e26a70SApple OSS Distributions * @param dvp Parent directory vnode 5812*a1e26a70SApple OSS Distributions * @param dlabel Policy label for dvp 5813*a1e26a70SApple OSS Distributions * @param vp Object vnode to delete 5814*a1e26a70SApple OSS Distributions * @param label Policy label for vp 5815*a1e26a70SApple OSS Distributions * @param cnp Component name for vp 5816*a1e26a70SApple OSS Distributions * 5817*a1e26a70SApple OSS Distributions * Inform Mac policies that a vnode have been successfully deleted 5818*a1e26a70SApple OSS Distributions * (passing all MAC polices and DAC). 5819*a1e26a70SApple OSS Distributions */ 5820*a1e26a70SApple OSS Distributions typedef void mpo_vnode_notify_unlink_t( 5821*a1e26a70SApple OSS Distributions kauth_cred_t cred, 5822*a1e26a70SApple OSS Distributions struct vnode *dvp, 5823*a1e26a70SApple OSS Distributions struct label *dlabel, 5824*a1e26a70SApple OSS Distributions struct vnode *vp, 5825*a1e26a70SApple OSS Distributions struct label *label, 5826*a1e26a70SApple OSS Distributions struct componentname *cnp 5827*a1e26a70SApple OSS Distributions ); 5828*a1e26a70SApple OSS Distributions 5829*a1e26a70SApple OSS Distributions /* 5830*a1e26a70SApple OSS Distributions * Placeholder for future events that may need mac hooks. 5831*a1e26a70SApple OSS Distributions */ 5832*a1e26a70SApple OSS Distributions typedef void mpo_reserved_hook_t(void); 5833*a1e26a70SApple OSS Distributions 5834*a1e26a70SApple OSS Distributions /* 5835*a1e26a70SApple OSS Distributions * Policy module operations. 5836*a1e26a70SApple OSS Distributions * 5837*a1e26a70SApple OSS Distributions * Please note that this should be kept in sync with the check assumptions 5838*a1e26a70SApple OSS Distributions * policy in bsd/kern/policy_check.c (policy_ops struct). 5839*a1e26a70SApple OSS Distributions */ 5840*a1e26a70SApple OSS Distributions #define MAC_POLICY_OPS_VERSION 87 /* inc when new reserved slots are taken */ 5841*a1e26a70SApple OSS Distributions struct mac_policy_ops { 5842*a1e26a70SApple OSS Distributions mpo_audit_check_postselect_t *mpo_audit_check_postselect; 5843*a1e26a70SApple OSS Distributions mpo_audit_check_preselect_t *mpo_audit_check_preselect; 5844*a1e26a70SApple OSS Distributions 5845*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved01; 5846*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved02; 5847*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved03; 5848*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved04; 5849*a1e26a70SApple OSS Distributions 5850*a1e26a70SApple OSS Distributions mpo_cred_check_label_update_execve_t *mpo_cred_check_label_update_execve; 5851*a1e26a70SApple OSS Distributions mpo_cred_check_label_update_t *mpo_cred_check_label_update; 5852*a1e26a70SApple OSS Distributions mpo_cred_check_visible_t *mpo_cred_check_visible; 5853*a1e26a70SApple OSS Distributions mpo_cred_label_associate_fork_t *mpo_cred_label_associate_fork; 5854*a1e26a70SApple OSS Distributions mpo_cred_label_associate_kernel_t *mpo_cred_label_associate_kernel; 5855*a1e26a70SApple OSS Distributions mpo_cred_label_associate_t *mpo_cred_label_associate; 5856*a1e26a70SApple OSS Distributions mpo_cred_label_associate_user_t *mpo_cred_label_associate_user; 5857*a1e26a70SApple OSS Distributions mpo_cred_label_destroy_t *mpo_cred_label_destroy; 5858*a1e26a70SApple OSS Distributions mpo_cred_label_externalize_audit_t *mpo_cred_label_externalize_audit; 5859*a1e26a70SApple OSS Distributions mpo_cred_label_externalize_t *mpo_cred_label_externalize; 5860*a1e26a70SApple OSS Distributions mpo_cred_label_init_t *mpo_cred_label_init; 5861*a1e26a70SApple OSS Distributions mpo_cred_label_internalize_t *mpo_cred_label_internalize; 5862*a1e26a70SApple OSS Distributions mpo_cred_label_update_execve_t *mpo_cred_label_update_execve; 5863*a1e26a70SApple OSS Distributions mpo_cred_label_update_t *mpo_cred_label_update; 5864*a1e26a70SApple OSS Distributions 5865*a1e26a70SApple OSS Distributions mpo_devfs_label_associate_device_t *mpo_devfs_label_associate_device; 5866*a1e26a70SApple OSS Distributions mpo_devfs_label_associate_directory_t *mpo_devfs_label_associate_directory; 5867*a1e26a70SApple OSS Distributions mpo_devfs_label_copy_t *mpo_devfs_label_copy; 5868*a1e26a70SApple OSS Distributions mpo_devfs_label_destroy_t *mpo_devfs_label_destroy; 5869*a1e26a70SApple OSS Distributions mpo_devfs_label_init_t *mpo_devfs_label_init; 5870*a1e26a70SApple OSS Distributions mpo_devfs_label_update_t *mpo_devfs_label_update; 5871*a1e26a70SApple OSS Distributions 5872*a1e26a70SApple OSS Distributions mpo_file_check_change_offset_t *mpo_file_check_change_offset; 5873*a1e26a70SApple OSS Distributions mpo_file_check_create_t *mpo_file_check_create; 5874*a1e26a70SApple OSS Distributions mpo_file_check_dup_t *mpo_file_check_dup; 5875*a1e26a70SApple OSS Distributions mpo_file_check_fcntl_t *mpo_file_check_fcntl; 5876*a1e26a70SApple OSS Distributions mpo_file_check_get_offset_t *mpo_file_check_get_offset; 5877*a1e26a70SApple OSS Distributions mpo_file_check_get_t *mpo_file_check_get; 5878*a1e26a70SApple OSS Distributions mpo_file_check_inherit_t *mpo_file_check_inherit; 5879*a1e26a70SApple OSS Distributions mpo_file_check_ioctl_t *mpo_file_check_ioctl; 5880*a1e26a70SApple OSS Distributions mpo_file_check_lock_t *mpo_file_check_lock; 5881*a1e26a70SApple OSS Distributions mpo_file_check_mmap_downgrade_t *mpo_file_check_mmap_downgrade; 5882*a1e26a70SApple OSS Distributions mpo_file_check_mmap_t *mpo_file_check_mmap; 5883*a1e26a70SApple OSS Distributions mpo_file_check_receive_t *mpo_file_check_receive; 5884*a1e26a70SApple OSS Distributions mpo_file_check_set_t *mpo_file_check_set; 5885*a1e26a70SApple OSS Distributions mpo_file_label_init_t *mpo_file_label_init; /* deprecated not called anymore */ 5886*a1e26a70SApple OSS Distributions mpo_file_label_destroy_t *mpo_file_label_destroy; /* deprecated not called anymore */ 5887*a1e26a70SApple OSS Distributions mpo_file_label_associate_t *mpo_file_label_associate; /* deprecated not called anymore */ 5888*a1e26a70SApple OSS Distributions mpo_file_notify_close_t *mpo_file_notify_close; 5889*a1e26a70SApple OSS Distributions 5890*a1e26a70SApple OSS Distributions mpo_proc_check_launch_constraints_t *mpo_proc_check_launch_constraints; 5891*a1e26a70SApple OSS Distributions mpo_proc_notify_service_port_derive_t *mpo_proc_notify_service_port_derive; 5892*a1e26a70SApple OSS Distributions mpo_proc_check_set_task_exception_port_t *mpo_proc_check_set_task_exception_port; 5893*a1e26a70SApple OSS Distributions mpo_proc_check_set_thread_exception_port_t *mpo_proc_check_set_thread_exception_port; 5894*a1e26a70SApple OSS Distributions 5895*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved08; 5896*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved09; 5897*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved10; 5898*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved11; 5899*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved12; 5900*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved13; 5901*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved14; 5902*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved15; 5903*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved16; 5904*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved17; 5905*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved18; 5906*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved19; 5907*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved20; 5908*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved21; 5909*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved22; 5910*a1e26a70SApple OSS Distributions 5911*a1e26a70SApple OSS Distributions mpo_necp_check_open_t *mpo_necp_check_open; 5912*a1e26a70SApple OSS Distributions mpo_necp_check_client_action_t *mpo_necp_check_client_action; 5913*a1e26a70SApple OSS Distributions 5914*a1e26a70SApple OSS Distributions mpo_file_check_library_validation_t *mpo_file_check_library_validation; 5915*a1e26a70SApple OSS Distributions 5916*a1e26a70SApple OSS Distributions mpo_vnode_notify_setacl_t *mpo_vnode_notify_setacl; 5917*a1e26a70SApple OSS Distributions mpo_vnode_notify_setattrlist_t *mpo_vnode_notify_setattrlist; 5918*a1e26a70SApple OSS Distributions mpo_vnode_notify_setextattr_t *mpo_vnode_notify_setextattr; 5919*a1e26a70SApple OSS Distributions mpo_vnode_notify_setflags_t *mpo_vnode_notify_setflags; 5920*a1e26a70SApple OSS Distributions mpo_vnode_notify_setmode_t *mpo_vnode_notify_setmode; 5921*a1e26a70SApple OSS Distributions mpo_vnode_notify_setowner_t *mpo_vnode_notify_setowner; 5922*a1e26a70SApple OSS Distributions mpo_vnode_notify_setutimes_t *mpo_vnode_notify_setutimes; 5923*a1e26a70SApple OSS Distributions mpo_vnode_notify_truncate_t *mpo_vnode_notify_truncate; 5924*a1e26a70SApple OSS Distributions mpo_vnode_check_getattrlistbulk_t *mpo_vnode_check_getattrlistbulk; 5925*a1e26a70SApple OSS Distributions 5926*a1e26a70SApple OSS Distributions mpo_proc_check_get_task_special_port_t *mpo_proc_check_get_task_special_port; 5927*a1e26a70SApple OSS Distributions mpo_proc_check_set_task_special_port_t *mpo_proc_check_set_task_special_port; 5928*a1e26a70SApple OSS Distributions 5929*a1e26a70SApple OSS Distributions mpo_vnode_notify_swap_t *mpo_vnode_notify_swap; 5930*a1e26a70SApple OSS Distributions mpo_vnode_notify_unlink_t *mpo_vnode_notify_unlink; 5931*a1e26a70SApple OSS Distributions mpo_vnode_check_swap_t *mpo_vnode_check_swap; 5932*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved33; 5933*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved34; 5934*a1e26a70SApple OSS Distributions mpo_mount_notify_mount_t *mpo_mount_notify_mount; 5935*a1e26a70SApple OSS Distributions mpo_vnode_check_copyfile_t *mpo_vnode_check_copyfile; 5936*a1e26a70SApple OSS Distributions 5937*a1e26a70SApple OSS Distributions mpo_mount_check_quotactl_t *mpo_mount_check_quotactl; 5938*a1e26a70SApple OSS Distributions mpo_mount_check_fsctl_t *mpo_mount_check_fsctl; 5939*a1e26a70SApple OSS Distributions mpo_mount_check_getattr_t *mpo_mount_check_getattr; 5940*a1e26a70SApple OSS Distributions mpo_mount_check_label_update_t *mpo_mount_check_label_update; 5941*a1e26a70SApple OSS Distributions mpo_mount_check_mount_t *mpo_mount_check_mount; 5942*a1e26a70SApple OSS Distributions mpo_mount_check_remount_t *mpo_mount_check_remount; 5943*a1e26a70SApple OSS Distributions mpo_mount_check_setattr_t *mpo_mount_check_setattr; 5944*a1e26a70SApple OSS Distributions mpo_mount_check_stat_t *mpo_mount_check_stat; 5945*a1e26a70SApple OSS Distributions mpo_mount_check_umount_t *mpo_mount_check_umount; 5946*a1e26a70SApple OSS Distributions mpo_mount_label_associate_t *mpo_mount_label_associate; 5947*a1e26a70SApple OSS Distributions mpo_mount_label_destroy_t *mpo_mount_label_destroy; 5948*a1e26a70SApple OSS Distributions mpo_mount_label_externalize_t *mpo_mount_label_externalize; 5949*a1e26a70SApple OSS Distributions mpo_mount_label_init_t *mpo_mount_label_init; 5950*a1e26a70SApple OSS Distributions mpo_mount_label_internalize_t *mpo_mount_label_internalize; 5951*a1e26a70SApple OSS Distributions 5952*a1e26a70SApple OSS Distributions mpo_proc_check_expose_task_with_flavor_t *mpo_proc_check_expose_task_with_flavor; 5953*a1e26a70SApple OSS Distributions mpo_proc_check_get_task_with_flavor_t *mpo_proc_check_get_task_with_flavor; 5954*a1e26a70SApple OSS Distributions mpo_proc_check_task_id_token_get_task_t *mpo_proc_check_task_id_token_get_task; 5955*a1e26a70SApple OSS Distributions 5956*a1e26a70SApple OSS Distributions mpo_pipe_check_ioctl_t *mpo_pipe_check_ioctl; 5957*a1e26a70SApple OSS Distributions mpo_pipe_check_kqfilter_t *mpo_pipe_check_kqfilter; 5958*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved41; 5959*a1e26a70SApple OSS Distributions mpo_pipe_check_read_t *mpo_pipe_check_read; 5960*a1e26a70SApple OSS Distributions mpo_pipe_check_select_t *mpo_pipe_check_select; 5961*a1e26a70SApple OSS Distributions mpo_pipe_check_stat_t *mpo_pipe_check_stat; 5962*a1e26a70SApple OSS Distributions mpo_pipe_check_write_t *mpo_pipe_check_write; 5963*a1e26a70SApple OSS Distributions mpo_pipe_label_associate_t *mpo_pipe_label_associate; 5964*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved42; 5965*a1e26a70SApple OSS Distributions mpo_pipe_label_destroy_t *mpo_pipe_label_destroy; 5966*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved43; 5967*a1e26a70SApple OSS Distributions mpo_pipe_label_init_t *mpo_pipe_label_init; 5968*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved44; 5969*a1e26a70SApple OSS Distributions mpo_proc_check_syscall_mac_t *mpo_proc_check_syscall_mac; 5970*a1e26a70SApple OSS Distributions 5971*a1e26a70SApple OSS Distributions mpo_policy_destroy_t *mpo_policy_destroy; 5972*a1e26a70SApple OSS Distributions mpo_policy_init_t *mpo_policy_init; 5973*a1e26a70SApple OSS Distributions mpo_policy_initbsd_t *mpo_policy_initbsd; 5974*a1e26a70SApple OSS Distributions mpo_policy_syscall_t *mpo_policy_syscall; 5975*a1e26a70SApple OSS Distributions 5976*a1e26a70SApple OSS Distributions mpo_system_check_sysctlbyname_t *mpo_system_check_sysctlbyname; 5977*a1e26a70SApple OSS Distributions mpo_proc_check_inherit_ipc_ports_t *mpo_proc_check_inherit_ipc_ports; 5978*a1e26a70SApple OSS Distributions mpo_vnode_check_rename_t *mpo_vnode_check_rename; 5979*a1e26a70SApple OSS Distributions mpo_kext_check_query_t *mpo_kext_check_query; 5980*a1e26a70SApple OSS Distributions mpo_proc_notify_exec_complete_t *mpo_proc_notify_exec_complete; 5981*a1e26a70SApple OSS Distributions mpo_proc_notify_cs_invalidated_t *mpo_proc_notify_cs_invalidated; 5982*a1e26a70SApple OSS Distributions mpo_proc_check_syscall_unix_t *mpo_proc_check_syscall_unix; 5983*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved45; 5984*a1e26a70SApple OSS Distributions mpo_proc_check_set_host_special_port_t *mpo_proc_check_set_host_special_port; 5985*a1e26a70SApple OSS Distributions mpo_proc_check_set_host_exception_port_t *mpo_proc_check_set_host_exception_port; 5986*a1e26a70SApple OSS Distributions mpo_exc_action_check_exception_send_t *mpo_exc_action_check_exception_send; 5987*a1e26a70SApple OSS Distributions mpo_exc_action_label_associate_t *mpo_exc_action_label_associate; 5988*a1e26a70SApple OSS Distributions mpo_exc_action_label_populate_t *mpo_exc_action_label_populate; 5989*a1e26a70SApple OSS Distributions mpo_exc_action_label_destroy_t *mpo_exc_action_label_destroy; 5990*a1e26a70SApple OSS Distributions mpo_exc_action_label_init_t *mpo_exc_action_label_init; 5991*a1e26a70SApple OSS Distributions mpo_exc_action_label_update_t *mpo_exc_action_label_update; 5992*a1e26a70SApple OSS Distributions 5993*a1e26a70SApple OSS Distributions mpo_vnode_check_trigger_resolve_t *mpo_vnode_check_trigger_resolve; 5994*a1e26a70SApple OSS Distributions mpo_mount_check_mount_late_t *mpo_mount_check_mount_late; 5995*a1e26a70SApple OSS Distributions mpo_mount_check_snapshot_mount_t *mpo_mount_check_snapshot_mount; 5996*a1e26a70SApple OSS Distributions mpo_vnode_notify_reclaim_t *mpo_vnode_notify_reclaim; 5997*a1e26a70SApple OSS Distributions mpo_skywalk_flow_check_connect_t *mpo_skywalk_flow_check_connect; 5998*a1e26a70SApple OSS Distributions mpo_skywalk_flow_check_listen_t *mpo_skywalk_flow_check_listen; 5999*a1e26a70SApple OSS Distributions 6000*a1e26a70SApple OSS Distributions mpo_posixsem_check_create_t *mpo_posixsem_check_create; 6001*a1e26a70SApple OSS Distributions mpo_posixsem_check_open_t *mpo_posixsem_check_open; 6002*a1e26a70SApple OSS Distributions mpo_posixsem_check_post_t *mpo_posixsem_check_post; 6003*a1e26a70SApple OSS Distributions mpo_posixsem_check_unlink_t *mpo_posixsem_check_unlink; 6004*a1e26a70SApple OSS Distributions mpo_posixsem_check_wait_t *mpo_posixsem_check_wait; 6005*a1e26a70SApple OSS Distributions mpo_posixsem_label_associate_t *mpo_posixsem_label_associate; 6006*a1e26a70SApple OSS Distributions mpo_posixsem_label_destroy_t *mpo_posixsem_label_destroy; 6007*a1e26a70SApple OSS Distributions mpo_posixsem_label_init_t *mpo_posixsem_label_init; 6008*a1e26a70SApple OSS Distributions mpo_posixshm_check_create_t *mpo_posixshm_check_create; 6009*a1e26a70SApple OSS Distributions mpo_posixshm_check_mmap_t *mpo_posixshm_check_mmap; 6010*a1e26a70SApple OSS Distributions mpo_posixshm_check_open_t *mpo_posixshm_check_open; 6011*a1e26a70SApple OSS Distributions mpo_posixshm_check_stat_t *mpo_posixshm_check_stat; 6012*a1e26a70SApple OSS Distributions mpo_posixshm_check_truncate_t *mpo_posixshm_check_truncate; 6013*a1e26a70SApple OSS Distributions mpo_posixshm_check_unlink_t *mpo_posixshm_check_unlink; 6014*a1e26a70SApple OSS Distributions mpo_posixshm_label_associate_t *mpo_posixshm_label_associate; 6015*a1e26a70SApple OSS Distributions mpo_posixshm_label_destroy_t *mpo_posixshm_label_destroy; 6016*a1e26a70SApple OSS Distributions mpo_posixshm_label_init_t *mpo_posixshm_label_init; 6017*a1e26a70SApple OSS Distributions 6018*a1e26a70SApple OSS Distributions mpo_proc_check_debug_t *mpo_proc_check_debug; 6019*a1e26a70SApple OSS Distributions mpo_proc_check_fork_t *mpo_proc_check_fork; 6020*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved61; 6021*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved62; 6022*a1e26a70SApple OSS Distributions mpo_proc_check_getaudit_t *mpo_proc_check_getaudit; 6023*a1e26a70SApple OSS Distributions mpo_proc_check_getauid_t *mpo_proc_check_getauid; 6024*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved63; 6025*a1e26a70SApple OSS Distributions mpo_proc_check_mprotect_t *mpo_proc_check_mprotect; 6026*a1e26a70SApple OSS Distributions mpo_proc_check_sched_t *mpo_proc_check_sched; 6027*a1e26a70SApple OSS Distributions mpo_proc_check_setaudit_t *mpo_proc_check_setaudit; 6028*a1e26a70SApple OSS Distributions mpo_proc_check_setauid_t *mpo_proc_check_setauid; 6029*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved64; 6030*a1e26a70SApple OSS Distributions mpo_proc_check_signal_t *mpo_proc_check_signal; 6031*a1e26a70SApple OSS Distributions mpo_proc_check_wait_t *mpo_proc_check_wait; 6032*a1e26a70SApple OSS Distributions mpo_proc_check_dump_core_t *mpo_proc_check_dump_core; 6033*a1e26a70SApple OSS Distributions mpo_proc_check_remote_thread_create_t *mpo_proc_check_remote_thread_create; 6034*a1e26a70SApple OSS Distributions 6035*a1e26a70SApple OSS Distributions mpo_socket_check_accept_t *mpo_socket_check_accept; 6036*a1e26a70SApple OSS Distributions mpo_socket_check_accepted_t *mpo_socket_check_accepted; 6037*a1e26a70SApple OSS Distributions mpo_socket_check_bind_t *mpo_socket_check_bind; 6038*a1e26a70SApple OSS Distributions mpo_socket_check_connect_t *mpo_socket_check_connect; 6039*a1e26a70SApple OSS Distributions mpo_socket_check_create_t *mpo_socket_check_create; 6040*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved46; 6041*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved47; 6042*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved48; 6043*a1e26a70SApple OSS Distributions mpo_socket_check_listen_t *mpo_socket_check_listen; 6044*a1e26a70SApple OSS Distributions mpo_socket_check_receive_t *mpo_socket_check_receive; 6045*a1e26a70SApple OSS Distributions mpo_socket_check_received_t *mpo_socket_check_received; 6046*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved49; 6047*a1e26a70SApple OSS Distributions mpo_socket_check_send_t *mpo_socket_check_send; 6048*a1e26a70SApple OSS Distributions mpo_socket_check_stat_t *mpo_socket_check_stat; 6049*a1e26a70SApple OSS Distributions mpo_socket_check_setsockopt_t *mpo_socket_check_setsockopt; 6050*a1e26a70SApple OSS Distributions mpo_socket_check_getsockopt_t *mpo_socket_check_getsockopt; 6051*a1e26a70SApple OSS Distributions 6052*a1e26a70SApple OSS Distributions mpo_proc_check_get_movable_control_port_t *mpo_proc_check_get_movable_control_port; 6053*a1e26a70SApple OSS Distributions mpo_proc_check_dyld_process_info_notify_register_t *mpo_proc_check_dyld_process_info_notify_register; 6054*a1e26a70SApple OSS Distributions mpo_proc_check_setuid_t *mpo_proc_check_setuid; 6055*a1e26a70SApple OSS Distributions mpo_proc_check_seteuid_t *mpo_proc_check_seteuid; 6056*a1e26a70SApple OSS Distributions mpo_proc_check_setreuid_t *mpo_proc_check_setreuid; 6057*a1e26a70SApple OSS Distributions mpo_proc_check_setgid_t *mpo_proc_check_setgid; 6058*a1e26a70SApple OSS Distributions mpo_proc_check_setegid_t *mpo_proc_check_setegid; 6059*a1e26a70SApple OSS Distributions mpo_proc_check_setregid_t *mpo_proc_check_setregid; 6060*a1e26a70SApple OSS Distributions mpo_proc_check_settid_t *mpo_proc_check_settid; 6061*a1e26a70SApple OSS Distributions mpo_proc_check_memorystatus_control_t *mpo_proc_check_memorystatus_control; 6062*a1e26a70SApple OSS Distributions mpo_reserved_hook_t *mpo_reserved60; 6063*a1e26a70SApple OSS Distributions 6064*a1e26a70SApple OSS Distributions mpo_thread_telemetry_t *mpo_thread_telemetry; 6065*a1e26a70SApple OSS Distributions 6066*a1e26a70SApple OSS Distributions mpo_iokit_check_open_service_t *mpo_iokit_check_open_service; 6067*a1e26a70SApple OSS Distributions 6068*a1e26a70SApple OSS Distributions mpo_system_check_acct_t *mpo_system_check_acct; 6069*a1e26a70SApple OSS Distributions mpo_system_check_audit_t *mpo_system_check_audit; 6070*a1e26a70SApple OSS Distributions mpo_system_check_auditctl_t *mpo_system_check_auditctl; 6071*a1e26a70SApple OSS Distributions mpo_system_check_auditon_t *mpo_system_check_auditon; 6072*a1e26a70SApple OSS Distributions mpo_system_check_host_priv_t *mpo_system_check_host_priv; 6073*a1e26a70SApple OSS Distributions mpo_system_check_nfsd_t *mpo_system_check_nfsd; 6074*a1e26a70SApple OSS Distributions mpo_system_check_reboot_t *mpo_system_check_reboot; 6075*a1e26a70SApple OSS Distributions mpo_system_check_settime_t *mpo_system_check_settime; 6076*a1e26a70SApple OSS Distributions mpo_system_check_swapoff_t *mpo_system_check_swapoff; 6077*a1e26a70SApple OSS Distributions mpo_system_check_swapon_t *mpo_system_check_swapon; 6078*a1e26a70SApple OSS Distributions mpo_socket_check_ioctl_t *mpo_socket_check_ioctl; 6079*a1e26a70SApple OSS Distributions 6080*a1e26a70SApple OSS Distributions mpo_sysvmsg_label_associate_t *mpo_sysvmsg_label_associate; 6081*a1e26a70SApple OSS Distributions mpo_sysvmsg_label_destroy_t *mpo_sysvmsg_label_destroy; 6082*a1e26a70SApple OSS Distributions mpo_sysvmsg_label_init_t *mpo_sysvmsg_label_init; 6083*a1e26a70SApple OSS Distributions mpo_sysvmsg_label_recycle_t *mpo_sysvmsg_label_recycle; 6084*a1e26a70SApple OSS Distributions mpo_sysvmsq_check_enqueue_t *mpo_sysvmsq_check_enqueue; 6085*a1e26a70SApple OSS Distributions mpo_sysvmsq_check_msgrcv_t *mpo_sysvmsq_check_msgrcv; 6086*a1e26a70SApple OSS Distributions mpo_sysvmsq_check_msgrmid_t *mpo_sysvmsq_check_msgrmid; 6087*a1e26a70SApple OSS Distributions mpo_sysvmsq_check_msqctl_t *mpo_sysvmsq_check_msqctl; 6088*a1e26a70SApple OSS Distributions mpo_sysvmsq_check_msqget_t *mpo_sysvmsq_check_msqget; 6089*a1e26a70SApple OSS Distributions mpo_sysvmsq_check_msqrcv_t *mpo_sysvmsq_check_msqrcv; 6090*a1e26a70SApple OSS Distributions mpo_sysvmsq_check_msqsnd_t *mpo_sysvmsq_check_msqsnd; 6091*a1e26a70SApple OSS Distributions mpo_sysvmsq_label_associate_t *mpo_sysvmsq_label_associate; 6092*a1e26a70SApple OSS Distributions mpo_sysvmsq_label_destroy_t *mpo_sysvmsq_label_destroy; 6093*a1e26a70SApple OSS Distributions mpo_sysvmsq_label_init_t *mpo_sysvmsq_label_init; 6094*a1e26a70SApple OSS Distributions mpo_sysvmsq_label_recycle_t *mpo_sysvmsq_label_recycle; 6095*a1e26a70SApple OSS Distributions mpo_sysvsem_check_semctl_t *mpo_sysvsem_check_semctl; 6096*a1e26a70SApple OSS Distributions mpo_sysvsem_check_semget_t *mpo_sysvsem_check_semget; 6097*a1e26a70SApple OSS Distributions mpo_sysvsem_check_semop_t *mpo_sysvsem_check_semop; 6098*a1e26a70SApple OSS Distributions mpo_sysvsem_label_associate_t *mpo_sysvsem_label_associate; 6099*a1e26a70SApple OSS Distributions mpo_sysvsem_label_destroy_t *mpo_sysvsem_label_destroy; 6100*a1e26a70SApple OSS Distributions mpo_sysvsem_label_init_t *mpo_sysvsem_label_init; 6101*a1e26a70SApple OSS Distributions mpo_sysvsem_label_recycle_t *mpo_sysvsem_label_recycle; 6102*a1e26a70SApple OSS Distributions mpo_sysvshm_check_shmat_t *mpo_sysvshm_check_shmat; 6103*a1e26a70SApple OSS Distributions mpo_sysvshm_check_shmctl_t *mpo_sysvshm_check_shmctl; 6104*a1e26a70SApple OSS Distributions mpo_sysvshm_check_shmdt_t *mpo_sysvshm_check_shmdt; 6105*a1e26a70SApple OSS Distributions mpo_sysvshm_check_shmget_t *mpo_sysvshm_check_shmget; 6106*a1e26a70SApple OSS Distributions mpo_sysvshm_label_associate_t *mpo_sysvshm_label_associate; 6107*a1e26a70SApple OSS Distributions mpo_sysvshm_label_destroy_t *mpo_sysvshm_label_destroy; 6108*a1e26a70SApple OSS Distributions mpo_sysvshm_label_init_t *mpo_sysvshm_label_init; 6109*a1e26a70SApple OSS Distributions mpo_sysvshm_label_recycle_t *mpo_sysvshm_label_recycle; 6110*a1e26a70SApple OSS Distributions 6111*a1e26a70SApple OSS Distributions mpo_proc_notify_exit_t *mpo_proc_notify_exit; 6112*a1e26a70SApple OSS Distributions mpo_mount_check_snapshot_revert_t *mpo_mount_check_snapshot_revert; 6113*a1e26a70SApple OSS Distributions mpo_vnode_check_getattr_t *mpo_vnode_check_getattr; 6114*a1e26a70SApple OSS Distributions mpo_mount_check_snapshot_create_t *mpo_mount_check_snapshot_create; 6115*a1e26a70SApple OSS Distributions mpo_mount_check_snapshot_delete_t *mpo_mount_check_snapshot_delete; 6116*a1e26a70SApple OSS Distributions mpo_vnode_check_clone_t *mpo_vnode_check_clone; 6117*a1e26a70SApple OSS Distributions mpo_proc_check_get_cs_info_t *mpo_proc_check_get_cs_info; 6118*a1e26a70SApple OSS Distributions mpo_proc_check_set_cs_info_t *mpo_proc_check_set_cs_info; 6119*a1e26a70SApple OSS Distributions 6120*a1e26a70SApple OSS Distributions mpo_iokit_check_hid_control_t *mpo_iokit_check_hid_control; 6121*a1e26a70SApple OSS Distributions 6122*a1e26a70SApple OSS Distributions mpo_vnode_check_access_t *mpo_vnode_check_access; 6123*a1e26a70SApple OSS Distributions mpo_vnode_check_chdir_t *mpo_vnode_check_chdir; 6124*a1e26a70SApple OSS Distributions mpo_vnode_check_chroot_t *mpo_vnode_check_chroot; 6125*a1e26a70SApple OSS Distributions mpo_vnode_check_create_t *mpo_vnode_check_create; 6126*a1e26a70SApple OSS Distributions mpo_vnode_check_deleteextattr_t *mpo_vnode_check_deleteextattr; 6127*a1e26a70SApple OSS Distributions mpo_vnode_check_exchangedata_t *mpo_vnode_check_exchangedata; 6128*a1e26a70SApple OSS Distributions mpo_vnode_check_exec_t *mpo_vnode_check_exec; 6129*a1e26a70SApple OSS Distributions mpo_vnode_check_getattrlist_t *mpo_vnode_check_getattrlist; 6130*a1e26a70SApple OSS Distributions mpo_vnode_check_getextattr_t *mpo_vnode_check_getextattr; 6131*a1e26a70SApple OSS Distributions mpo_vnode_check_ioctl_t *mpo_vnode_check_ioctl; 6132*a1e26a70SApple OSS Distributions mpo_vnode_check_kqfilter_t *mpo_vnode_check_kqfilter; 6133*a1e26a70SApple OSS Distributions mpo_vnode_check_label_update_t *mpo_vnode_check_label_update; 6134*a1e26a70SApple OSS Distributions mpo_vnode_check_link_t *mpo_vnode_check_link; 6135*a1e26a70SApple OSS Distributions mpo_vnode_check_listextattr_t *mpo_vnode_check_listextattr; 6136*a1e26a70SApple OSS Distributions mpo_vnode_check_lookup_t *mpo_vnode_check_lookup; 6137*a1e26a70SApple OSS Distributions mpo_vnode_check_open_t *mpo_vnode_check_open; 6138*a1e26a70SApple OSS Distributions mpo_vnode_check_read_t *mpo_vnode_check_read; 6139*a1e26a70SApple OSS Distributions mpo_vnode_check_readdir_t *mpo_vnode_check_readdir; 6140*a1e26a70SApple OSS Distributions mpo_vnode_check_readlink_t *mpo_vnode_check_readlink; 6141*a1e26a70SApple OSS Distributions mpo_vnode_check_rename_from_t *mpo_vnode_check_rename_from; 6142*a1e26a70SApple OSS Distributions mpo_vnode_check_rename_to_t *mpo_vnode_check_rename_to; 6143*a1e26a70SApple OSS Distributions mpo_vnode_check_revoke_t *mpo_vnode_check_revoke; 6144*a1e26a70SApple OSS Distributions mpo_vnode_check_select_t *mpo_vnode_check_select; 6145*a1e26a70SApple OSS Distributions mpo_vnode_check_setattrlist_t *mpo_vnode_check_setattrlist; 6146*a1e26a70SApple OSS Distributions mpo_vnode_check_setextattr_t *mpo_vnode_check_setextattr; 6147*a1e26a70SApple OSS Distributions mpo_vnode_check_setflags_t *mpo_vnode_check_setflags; 6148*a1e26a70SApple OSS Distributions mpo_vnode_check_setmode_t *mpo_vnode_check_setmode; 6149*a1e26a70SApple OSS Distributions mpo_vnode_check_setowner_t *mpo_vnode_check_setowner; 6150*a1e26a70SApple OSS Distributions mpo_vnode_check_setutimes_t *mpo_vnode_check_setutimes; 6151*a1e26a70SApple OSS Distributions mpo_vnode_check_stat_t *mpo_vnode_check_stat; 6152*a1e26a70SApple OSS Distributions mpo_vnode_check_truncate_t *mpo_vnode_check_truncate; 6153*a1e26a70SApple OSS Distributions mpo_vnode_check_unlink_t *mpo_vnode_check_unlink; 6154*a1e26a70SApple OSS Distributions mpo_vnode_check_write_t *mpo_vnode_check_write; 6155*a1e26a70SApple OSS Distributions mpo_vnode_label_associate_devfs_t *mpo_vnode_label_associate_devfs; 6156*a1e26a70SApple OSS Distributions mpo_vnode_label_associate_extattr_t *mpo_vnode_label_associate_extattr; 6157*a1e26a70SApple OSS Distributions mpo_vnode_label_associate_file_t *mpo_vnode_label_associate_file; 6158*a1e26a70SApple OSS Distributions mpo_vnode_label_associate_pipe_t *mpo_vnode_label_associate_pipe; 6159*a1e26a70SApple OSS Distributions mpo_vnode_label_associate_posixsem_t *mpo_vnode_label_associate_posixsem; 6160*a1e26a70SApple OSS Distributions mpo_vnode_label_associate_posixshm_t *mpo_vnode_label_associate_posixshm; 6161*a1e26a70SApple OSS Distributions mpo_vnode_label_associate_singlelabel_t *mpo_vnode_label_associate_singlelabel; 6162*a1e26a70SApple OSS Distributions mpo_vnode_label_associate_socket_t *mpo_vnode_label_associate_socket; 6163*a1e26a70SApple OSS Distributions mpo_vnode_label_copy_t *mpo_vnode_label_copy; 6164*a1e26a70SApple OSS Distributions mpo_vnode_label_destroy_t *mpo_vnode_label_destroy; 6165*a1e26a70SApple OSS Distributions mpo_vnode_label_externalize_audit_t *mpo_vnode_label_externalize_audit; 6166*a1e26a70SApple OSS Distributions mpo_vnode_label_externalize_t *mpo_vnode_label_externalize; 6167*a1e26a70SApple OSS Distributions mpo_vnode_label_init_t *mpo_vnode_label_init; 6168*a1e26a70SApple OSS Distributions mpo_vnode_label_internalize_t *mpo_vnode_label_internalize; 6169*a1e26a70SApple OSS Distributions mpo_vnode_label_recycle_t *mpo_vnode_label_recycle; 6170*a1e26a70SApple OSS Distributions mpo_vnode_label_store_t *mpo_vnode_label_store; 6171*a1e26a70SApple OSS Distributions mpo_vnode_label_update_extattr_t *mpo_vnode_label_update_extattr; 6172*a1e26a70SApple OSS Distributions mpo_vnode_label_update_t *mpo_vnode_label_update; 6173*a1e26a70SApple OSS Distributions mpo_vnode_notify_create_t *mpo_vnode_notify_create; 6174*a1e26a70SApple OSS Distributions mpo_vnode_check_signature_t *mpo_vnode_check_signature; 6175*a1e26a70SApple OSS Distributions mpo_vnode_check_uipc_bind_t *mpo_vnode_check_uipc_bind; 6176*a1e26a70SApple OSS Distributions mpo_vnode_check_uipc_connect_t *mpo_vnode_check_uipc_connect; 6177*a1e26a70SApple OSS Distributions 6178*a1e26a70SApple OSS Distributions mpo_proc_check_run_cs_invalid_t *mpo_proc_check_run_cs_invalid; 6179*a1e26a70SApple OSS Distributions mpo_proc_check_suspend_resume_t *mpo_proc_check_suspend_resume; 6180*a1e26a70SApple OSS Distributions 6181*a1e26a70SApple OSS Distributions mpo_thread_userret_t *mpo_thread_userret; 6182*a1e26a70SApple OSS Distributions 6183*a1e26a70SApple OSS Distributions mpo_iokit_check_set_properties_t *mpo_iokit_check_set_properties; 6184*a1e26a70SApple OSS Distributions 6185*a1e26a70SApple OSS Distributions mpo_vnode_check_supplemental_signature_t *mpo_vnode_check_supplemental_signature; 6186*a1e26a70SApple OSS Distributions 6187*a1e26a70SApple OSS Distributions mpo_vnode_check_searchfs_t *mpo_vnode_check_searchfs; 6188*a1e26a70SApple OSS Distributions 6189*a1e26a70SApple OSS Distributions mpo_priv_check_t *mpo_priv_check; 6190*a1e26a70SApple OSS Distributions mpo_priv_grant_t *mpo_priv_grant; 6191*a1e26a70SApple OSS Distributions 6192*a1e26a70SApple OSS Distributions mpo_proc_check_map_anon_t *mpo_proc_check_map_anon; 6193*a1e26a70SApple OSS Distributions 6194*a1e26a70SApple OSS Distributions mpo_vnode_check_fsgetpath_t *mpo_vnode_check_fsgetpath; 6195*a1e26a70SApple OSS Distributions 6196*a1e26a70SApple OSS Distributions mpo_iokit_check_open_t *mpo_iokit_check_open; 6197*a1e26a70SApple OSS Distributions 6198*a1e26a70SApple OSS Distributions mpo_proc_check_ledger_t *mpo_proc_check_ledger; 6199*a1e26a70SApple OSS Distributions 6200*a1e26a70SApple OSS Distributions mpo_vnode_notify_rename_t *mpo_vnode_notify_rename; 6201*a1e26a70SApple OSS Distributions 6202*a1e26a70SApple OSS Distributions mpo_vnode_check_setacl_t *mpo_vnode_check_setacl; 6203*a1e26a70SApple OSS Distributions 6204*a1e26a70SApple OSS Distributions mpo_vnode_notify_deleteextattr_t *mpo_vnode_notify_deleteextattr; 6205*a1e26a70SApple OSS Distributions 6206*a1e26a70SApple OSS Distributions mpo_system_check_kas_info_t *mpo_system_check_kas_info; 6207*a1e26a70SApple OSS Distributions 6208*a1e26a70SApple OSS Distributions mpo_vnode_check_lookup_preflight_t *mpo_vnode_check_lookup_preflight; 6209*a1e26a70SApple OSS Distributions 6210*a1e26a70SApple OSS Distributions mpo_vnode_notify_open_t *mpo_vnode_notify_open; 6211*a1e26a70SApple OSS Distributions 6212*a1e26a70SApple OSS Distributions mpo_system_check_info_t *mpo_system_check_info; 6213*a1e26a70SApple OSS Distributions 6214*a1e26a70SApple OSS Distributions mpo_pty_notify_grant_t *mpo_pty_notify_grant; 6215*a1e26a70SApple OSS Distributions mpo_pty_notify_close_t *mpo_pty_notify_close; 6216*a1e26a70SApple OSS Distributions 6217*a1e26a70SApple OSS Distributions mpo_vnode_find_sigs_t *mpo_vnode_find_sigs; 6218*a1e26a70SApple OSS Distributions 6219*a1e26a70SApple OSS Distributions mpo_kext_check_load_t *mpo_kext_check_load; 6220*a1e26a70SApple OSS Distributions mpo_kext_check_unload_t *mpo_kext_check_unload; 6221*a1e26a70SApple OSS Distributions 6222*a1e26a70SApple OSS Distributions mpo_proc_check_proc_info_t *mpo_proc_check_proc_info; 6223*a1e26a70SApple OSS Distributions mpo_vnode_notify_link_t *mpo_vnode_notify_link; 6224*a1e26a70SApple OSS Distributions mpo_iokit_check_filter_properties_t *mpo_iokit_check_filter_properties; 6225*a1e26a70SApple OSS Distributions mpo_iokit_check_get_property_t *mpo_iokit_check_get_property; 6226*a1e26a70SApple OSS Distributions }; 6227*a1e26a70SApple OSS Distributions 6228*a1e26a70SApple OSS Distributions /** 6229*a1e26a70SApple OSS Distributions * @brief MAC policy handle type 6230*a1e26a70SApple OSS Distributions * 6231*a1e26a70SApple OSS Distributions * The MAC handle is used to uniquely identify a loaded policy within 6232*a1e26a70SApple OSS Distributions * the MAC Framework. 6233*a1e26a70SApple OSS Distributions * 6234*a1e26a70SApple OSS Distributions * A variable of this type is set by mac_policy_register(). 6235*a1e26a70SApple OSS Distributions */ 6236*a1e26a70SApple OSS Distributions typedef unsigned int mac_policy_handle_t; 6237*a1e26a70SApple OSS Distributions 6238*a1e26a70SApple OSS Distributions #define mpc_t struct mac_policy_conf * 6239*a1e26a70SApple OSS Distributions 6240*a1e26a70SApple OSS Distributions /** 6241*a1e26a70SApple OSS Distributions * @brief Mac policy configuration 6242*a1e26a70SApple OSS Distributions * 6243*a1e26a70SApple OSS Distributions * This structure specifies the configuration information for a 6244*a1e26a70SApple OSS Distributions * MAC policy module. A policy module developer must supply 6245*a1e26a70SApple OSS Distributions * a short unique policy name, a more descriptive full name, a list of label 6246*a1e26a70SApple OSS Distributions * namespaces and count, a pointer to the registered enty point operations, 6247*a1e26a70SApple OSS Distributions * any load time flags, and optionally, a pointer to a label slot identifier. 6248*a1e26a70SApple OSS Distributions * 6249*a1e26a70SApple OSS Distributions * The Framework will update the runtime flags (mpc_runtime_flags) to 6250*a1e26a70SApple OSS Distributions * indicate that the module has been registered. 6251*a1e26a70SApple OSS Distributions * 6252*a1e26a70SApple OSS Distributions * If the label slot identifier (mpc_field_off) is NULL, the Framework 6253*a1e26a70SApple OSS Distributions * will not provide label storage for the policy. Otherwise, the 6254*a1e26a70SApple OSS Distributions * Framework will store the label location (slot) in this field. 6255*a1e26a70SApple OSS Distributions * 6256*a1e26a70SApple OSS Distributions * The mpc_list field is used by the Framework and should not be 6257*a1e26a70SApple OSS Distributions * modified by policies. 6258*a1e26a70SApple OSS Distributions */ 6259*a1e26a70SApple OSS Distributions /* XXX - reorder these for better alignment on 64bit platforms */ 6260*a1e26a70SApple OSS Distributions struct mac_policy_conf { 6261*a1e26a70SApple OSS Distributions const char *mpc_name; /** policy name */ 6262*a1e26a70SApple OSS Distributions const char *mpc_fullname; /** full name */ 6263*a1e26a70SApple OSS Distributions char const * const *mpc_labelnames; /** managed label namespaces */ 6264*a1e26a70SApple OSS Distributions unsigned int mpc_labelname_count; /** number of managed label namespaces */ 6265*a1e26a70SApple OSS Distributions const struct mac_policy_ops *mpc_ops; /** operation vector */ 6266*a1e26a70SApple OSS Distributions int mpc_loadtime_flags; /** load time flags */ 6267*a1e26a70SApple OSS Distributions int *mpc_field_off; /** label slot */ 6268*a1e26a70SApple OSS Distributions int mpc_runtime_flags; /** run time flags */ 6269*a1e26a70SApple OSS Distributions mpc_t mpc_list; /** List reference */ 6270*a1e26a70SApple OSS Distributions void *mpc_data; /** module data */ 6271*a1e26a70SApple OSS Distributions }; 6272*a1e26a70SApple OSS Distributions 6273*a1e26a70SApple OSS Distributions /** 6274*a1e26a70SApple OSS Distributions * @brief MAC policy module registration routine 6275*a1e26a70SApple OSS Distributions * 6276*a1e26a70SApple OSS Distributions * This function is called to register a policy with the 6277*a1e26a70SApple OSS Distributions * MAC framework. A policy module will typically call this from the 6278*a1e26a70SApple OSS Distributions * Darwin KEXT registration routine. 6279*a1e26a70SApple OSS Distributions */ 6280*a1e26a70SApple OSS Distributions int mac_policy_register(struct mac_policy_conf *mpc, 6281*a1e26a70SApple OSS Distributions mac_policy_handle_t *handlep, void *xd); 6282*a1e26a70SApple OSS Distributions 6283*a1e26a70SApple OSS Distributions /** 6284*a1e26a70SApple OSS Distributions * @brief MAC policy module de-registration routine 6285*a1e26a70SApple OSS Distributions * 6286*a1e26a70SApple OSS Distributions * This function is called to de-register a policy with the 6287*a1e26a70SApple OSS Distributions * MAC framework. A policy module will typically call this from the 6288*a1e26a70SApple OSS Distributions * Darwin KEXT de-registration routine. 6289*a1e26a70SApple OSS Distributions */ 6290*a1e26a70SApple OSS Distributions int mac_policy_unregister(mac_policy_handle_t handle); 6291*a1e26a70SApple OSS Distributions 6292*a1e26a70SApple OSS Distributions /* 6293*a1e26a70SApple OSS Distributions * Framework entry points for the policies to add audit data. 6294*a1e26a70SApple OSS Distributions */ 6295*a1e26a70SApple OSS Distributions int mac_audit_text(char *text, mac_policy_handle_t handle); 6296*a1e26a70SApple OSS Distributions 6297*a1e26a70SApple OSS Distributions /* 6298*a1e26a70SApple OSS Distributions * Calls to assist with use of Apple XATTRs within policy modules. 6299*a1e26a70SApple OSS Distributions */ 6300*a1e26a70SApple OSS Distributions int mac_vnop_setxattr(struct vnode *, const char *, char *, size_t); 6301*a1e26a70SApple OSS Distributions int mac_vnop_getxattr(struct vnode *, const char *, char *, size_t, 6302*a1e26a70SApple OSS Distributions size_t *); 6303*a1e26a70SApple OSS Distributions int mac_vnop_removexattr(struct vnode *, const char *); 6304*a1e26a70SApple OSS Distributions 6305*a1e26a70SApple OSS Distributions /** 6306*a1e26a70SApple OSS Distributions * @brief Set an extended attribute on a vnode-based fileglob. 6307*a1e26a70SApple OSS Distributions * @param fg fileglob representing file to attach the extended attribute 6308*a1e26a70SApple OSS Distributions * @param name extended attribute name 6309*a1e26a70SApple OSS Distributions * @param buf buffer of data to use as the extended attribute value 6310*a1e26a70SApple OSS Distributions * @param len size of buffer 6311*a1e26a70SApple OSS Distributions * 6312*a1e26a70SApple OSS Distributions * Sets the value of an extended attribute on a file. 6313*a1e26a70SApple OSS Distributions * 6314*a1e26a70SApple OSS Distributions * Caller must hold an iocount on the vnode represented by the fileglob. 6315*a1e26a70SApple OSS Distributions */ 6316*a1e26a70SApple OSS Distributions #ifdef KERNEL_PRIVATE 6317*a1e26a70SApple OSS Distributions int mac_file_setxattr(struct fileglob *fg, const char *name, char *buf, size_t len); 6318*a1e26a70SApple OSS Distributions #endif 6319*a1e26a70SApple OSS Distributions 6320*a1e26a70SApple OSS Distributions /** 6321*a1e26a70SApple OSS Distributions * @brief Get an extended attribute from a vnode-based fileglob. 6322*a1e26a70SApple OSS Distributions * @param fg fileglob representing file to read the extended attribute 6323*a1e26a70SApple OSS Distributions * @param name extended attribute name 6324*a1e26a70SApple OSS Distributions * @param buf buffer of data to hold the extended attribute value 6325*a1e26a70SApple OSS Distributions * @param len size of buffer 6326*a1e26a70SApple OSS Distributions * @param attrlen size of full extended attribute value 6327*a1e26a70SApple OSS Distributions * 6328*a1e26a70SApple OSS Distributions * Gets the value of an extended attribute on a file. 6329*a1e26a70SApple OSS Distributions * 6330*a1e26a70SApple OSS Distributions * Caller must hold an iocount on the vnode represented by the fileglob. 6331*a1e26a70SApple OSS Distributions */ 6332*a1e26a70SApple OSS Distributions #ifdef KERNEL_PRIVATE 6333*a1e26a70SApple OSS Distributions int mac_file_getxattr(struct fileglob *fg, const char *name, char *buf, size_t len, 6334*a1e26a70SApple OSS Distributions size_t *attrlen); 6335*a1e26a70SApple OSS Distributions #endif 6336*a1e26a70SApple OSS Distributions 6337*a1e26a70SApple OSS Distributions /** 6338*a1e26a70SApple OSS Distributions * @brief Remove an extended attribute from a vnode-based fileglob. 6339*a1e26a70SApple OSS Distributions * @param fg fileglob representing file to remove the extended attribute 6340*a1e26a70SApple OSS Distributions * @param name extended attribute name 6341*a1e26a70SApple OSS Distributions * 6342*a1e26a70SApple OSS Distributions * Removes the named extended attribute from the file. 6343*a1e26a70SApple OSS Distributions * 6344*a1e26a70SApple OSS Distributions * Caller must hold an iocount on the vnode represented by the fileglob. 6345*a1e26a70SApple OSS Distributions */ 6346*a1e26a70SApple OSS Distributions #ifdef KERNEL_PRIVATE 6347*a1e26a70SApple OSS Distributions int mac_file_removexattr(struct fileglob *fg, const char *name); 6348*a1e26a70SApple OSS Distributions #endif 6349*a1e26a70SApple OSS Distributions 6350*a1e26a70SApple OSS Distributions /* 6351*a1e26a70SApple OSS Distributions * Arbitrary limit on how much data will be logged by the audit 6352*a1e26a70SApple OSS Distributions * entry points above. 6353*a1e26a70SApple OSS Distributions */ 6354*a1e26a70SApple OSS Distributions #define MAC_AUDIT_DATA_LIMIT 1024 6355*a1e26a70SApple OSS Distributions 6356*a1e26a70SApple OSS Distributions /* 6357*a1e26a70SApple OSS Distributions * Values returned by mac_audit_{pre,post}select. To combine the responses 6358*a1e26a70SApple OSS Distributions * of the security policies into a single decision, 6359*a1e26a70SApple OSS Distributions * mac_audit_{pre,post}select() choose the greatest value returned. 6360*a1e26a70SApple OSS Distributions */ 6361*a1e26a70SApple OSS Distributions #define MAC_AUDIT_DEFAULT 0 /* use system behavior */ 6362*a1e26a70SApple OSS Distributions #define MAC_AUDIT_NO 1 /* force not auditing this event */ 6363*a1e26a70SApple OSS Distributions #define MAC_AUDIT_YES 2 /* force auditing this event */ 6364*a1e26a70SApple OSS Distributions 6365*a1e26a70SApple OSS Distributions // \defgroup mpc_loadtime_flags Flags for the mpc_loadtime_flags field 6366*a1e26a70SApple OSS Distributions 6367*a1e26a70SApple OSS Distributions /** 6368*a1e26a70SApple OSS Distributions * @name Flags for the mpc_loadtime_flags field 6369*a1e26a70SApple OSS Distributions * @see mac_policy_conf 6370*a1e26a70SApple OSS Distributions * 6371*a1e26a70SApple OSS Distributions * This is the complete list of flags that are supported by the 6372*a1e26a70SApple OSS Distributions * mpc_loadtime_flags field of the mac_policy_conf structure. These 6373*a1e26a70SApple OSS Distributions * flags specify the load time behavior of MAC Framework policy 6374*a1e26a70SApple OSS Distributions * modules. 6375*a1e26a70SApple OSS Distributions */ 6376*a1e26a70SApple OSS Distributions 6377*a1e26a70SApple OSS Distributions /*@{*/ 6378*a1e26a70SApple OSS Distributions 6379*a1e26a70SApple OSS Distributions /** 6380*a1e26a70SApple OSS Distributions * @brief Flag to indicate registration preference 6381*a1e26a70SApple OSS Distributions * 6382*a1e26a70SApple OSS Distributions * This flag indicates that the policy module must be loaded and 6383*a1e26a70SApple OSS Distributions * initialized early in the boot process. If the flag is specified, 6384*a1e26a70SApple OSS Distributions * attempts to register the module following boot will be rejected. The 6385*a1e26a70SApple OSS Distributions * flag may be used by policies that require pervasive labeling of all 6386*a1e26a70SApple OSS Distributions * system objects, and cannot handle objects that have not been 6387*a1e26a70SApple OSS Distributions * properly initialized by the policy. 6388*a1e26a70SApple OSS Distributions */ 6389*a1e26a70SApple OSS Distributions #define MPC_LOADTIME_FLAG_NOTLATE 0x00000001 6390*a1e26a70SApple OSS Distributions 6391*a1e26a70SApple OSS Distributions /** 6392*a1e26a70SApple OSS Distributions * @brief Flag to indicate unload preference 6393*a1e26a70SApple OSS Distributions * 6394*a1e26a70SApple OSS Distributions * This flag indicates that the policy module may be unloaded. If this 6395*a1e26a70SApple OSS Distributions * flag is not set, then the policy framework will reject requests to 6396*a1e26a70SApple OSS Distributions * unload the module. This flag might be used by modules that allocate 6397*a1e26a70SApple OSS Distributions * label state and are unable to free that state at runtime, or for 6398*a1e26a70SApple OSS Distributions * modules that simply do not want to permit unload operations. 6399*a1e26a70SApple OSS Distributions */ 6400*a1e26a70SApple OSS Distributions #define MPC_LOADTIME_FLAG_UNLOADOK 0x00000002 6401*a1e26a70SApple OSS Distributions 6402*a1e26a70SApple OSS Distributions /** 6403*a1e26a70SApple OSS Distributions * @brief Unsupported 6404*a1e26a70SApple OSS Distributions * 6405*a1e26a70SApple OSS Distributions * XXX This flag is not yet supported. 6406*a1e26a70SApple OSS Distributions */ 6407*a1e26a70SApple OSS Distributions #define MPC_LOADTIME_FLAG_LABELMBUFS 0x00000004 6408*a1e26a70SApple OSS Distributions 6409*a1e26a70SApple OSS Distributions /** 6410*a1e26a70SApple OSS Distributions * @brief Flag to indicate a base policy 6411*a1e26a70SApple OSS Distributions * 6412*a1e26a70SApple OSS Distributions * This flag indicates that the policy module is a base policy. Only 6413*a1e26a70SApple OSS Distributions * one module can declare itself as base, otherwise the boot process 6414*a1e26a70SApple OSS Distributions * will be halted. 6415*a1e26a70SApple OSS Distributions */ 6416*a1e26a70SApple OSS Distributions #define MPC_LOADTIME_BASE_POLICY 0x00000008 6417*a1e26a70SApple OSS Distributions 6418*a1e26a70SApple OSS Distributions /*@}*/ 6419*a1e26a70SApple OSS Distributions 6420*a1e26a70SApple OSS Distributions /** 6421*a1e26a70SApple OSS Distributions * @brief Policy registration flag 6422*a1e26a70SApple OSS Distributions * @see mac_policy_conf 6423*a1e26a70SApple OSS Distributions * 6424*a1e26a70SApple OSS Distributions * This flag indicates that the policy module has been successfully 6425*a1e26a70SApple OSS Distributions * registered with the TrustedBSD MAC Framework. The Framework will 6426*a1e26a70SApple OSS Distributions * set this flag in the mpc_runtime_flags field of the policy's 6427*a1e26a70SApple OSS Distributions * mac_policy_conf structure after registering the policy. 6428*a1e26a70SApple OSS Distributions */ 6429*a1e26a70SApple OSS Distributions #define MPC_RUNTIME_FLAG_REGISTERED 0x00000001 6430*a1e26a70SApple OSS Distributions 6431*a1e26a70SApple OSS Distributions /* 6432*a1e26a70SApple OSS Distributions * Depends on POLICY_VER 6433*a1e26a70SApple OSS Distributions */ 6434*a1e26a70SApple OSS Distributions 6435*a1e26a70SApple OSS Distributions #ifndef POLICY_VER 6436*a1e26a70SApple OSS Distributions #define POLICY_VER 1.0 6437*a1e26a70SApple OSS Distributions #endif 6438*a1e26a70SApple OSS Distributions 6439*a1e26a70SApple OSS Distributions #define MAC_POLICY_SET(handle, mpops, mpname, mpfullname, lnames, lcount, slot, lflags, rflags) \ 6440*a1e26a70SApple OSS Distributions static struct mac_policy_conf mpname##_mac_policy_conf = { \ 6441*a1e26a70SApple OSS Distributions .mpc_name = #mpname, \ 6442*a1e26a70SApple OSS Distributions .mpc_fullname = mpfullname, \ 6443*a1e26a70SApple OSS Distributions .mpc_labelnames = lnames, \ 6444*a1e26a70SApple OSS Distributions .mpc_labelname_count = lcount, \ 6445*a1e26a70SApple OSS Distributions .mpc_ops = mpops, \ 6446*a1e26a70SApple OSS Distributions .mpc_loadtime_flags = lflags, \ 6447*a1e26a70SApple OSS Distributions .mpc_field_off = slot, \ 6448*a1e26a70SApple OSS Distributions .mpc_runtime_flags = rflags \ 6449*a1e26a70SApple OSS Distributions }; \ 6450*a1e26a70SApple OSS Distributions \ 6451*a1e26a70SApple OSS Distributions static kern_return_t \ 6452*a1e26a70SApple OSS Distributions kmod_start(kmod_info_t *ki, void *xd) \ 6453*a1e26a70SApple OSS Distributions { \ 6454*a1e26a70SApple OSS Distributions return mac_policy_register(&mpname##_mac_policy_conf, \ 6455*a1e26a70SApple OSS Distributions &handle, xd); \ 6456*a1e26a70SApple OSS Distributions } \ 6457*a1e26a70SApple OSS Distributions \ 6458*a1e26a70SApple OSS Distributions static kern_return_t \ 6459*a1e26a70SApple OSS Distributions kmod_stop(kmod_info_t *ki, void *xd) \ 6460*a1e26a70SApple OSS Distributions { \ 6461*a1e26a70SApple OSS Distributions return mac_policy_unregister(handle); \ 6462*a1e26a70SApple OSS Distributions } \ 6463*a1e26a70SApple OSS Distributions \ 6464*a1e26a70SApple OSS Distributions extern kern_return_t _start(kmod_info_t *ki, void *data); \ 6465*a1e26a70SApple OSS Distributions extern kern_return_t _stop(kmod_info_t *ki, void *data); \ 6466*a1e26a70SApple OSS Distributions \ 6467*a1e26a70SApple OSS Distributions KMOD_EXPLICIT_DECL(security.mpname, POLICY_VER, _start, _stop) \ 6468*a1e26a70SApple OSS Distributions kmod_start_func_t *_realmain = kmod_start; \ 6469*a1e26a70SApple OSS Distributions kmod_stop_func_t *_antimain = kmod_stop; \ 6470*a1e26a70SApple OSS Distributions int _kext_apple_cc = __APPLE_CC__ 6471*a1e26a70SApple OSS Distributions 6472*a1e26a70SApple OSS Distributions /* 6473*a1e26a70SApple OSS Distributions * Policy interface to map a struct label pointer to per-policy data. 6474*a1e26a70SApple OSS Distributions * Typically, policies wrap this in their own accessor macro that casts an 6475*a1e26a70SApple OSS Distributions * intptr_t to a policy-specific data type. 6476*a1e26a70SApple OSS Distributions */ 6477*a1e26a70SApple OSS Distributions #ifdef KERNEL_PRIVATE 6478*a1e26a70SApple OSS Distributions struct label * mac_label_verify(struct label **labelp); 6479*a1e26a70SApple OSS Distributions intptr_t mac_label_get(struct label *l, int slot); 6480*a1e26a70SApple OSS Distributions /* 6481*a1e26a70SApple OSS Distributions * Sets a label slot to the given pointer value, `v`. `v` cannot be `~0ULL`. 6482*a1e26a70SApple OSS Distributions */ 6483*a1e26a70SApple OSS Distributions void mac_label_set(struct label *l, int slot, intptr_t v); 6484*a1e26a70SApple OSS Distributions struct label * mac_labelzone_alloc(int flags); 6485*a1e26a70SApple OSS Distributions struct label * mac_labelzone_alloc_for_owner(struct label **labelp, int flags, 6486*a1e26a70SApple OSS Distributions void (^extra_setup)(struct label *)); 6487*a1e26a70SApple OSS Distributions struct label * mac_labelzone_alloc_owned(struct label **labelp, int flags, 6488*a1e26a70SApple OSS Distributions void (^extra_setup)(struct label *)); 6489*a1e26a70SApple OSS Distributions void mac_labelzone_free(struct label *l); 6490*a1e26a70SApple OSS Distributions void mac_labelzone_free_owned(struct label **labelp, 6491*a1e26a70SApple OSS Distributions void (^extra_deinit)(struct label *)); 6492*a1e26a70SApple OSS Distributions intptr_t mac_vnode_label_get(struct vnode *vp, int slot, intptr_t sentinel); 6493*a1e26a70SApple OSS Distributions void mac_vnode_label_set(struct vnode *vp, int slot, intptr_t v); 6494*a1e26a70SApple OSS Distributions #endif 6495*a1e26a70SApple OSS Distributions 6496*a1e26a70SApple OSS Distributions #define mac_get_mpc(h) (mac_policy_list.entries[h].mpc) 6497*a1e26a70SApple OSS Distributions 6498*a1e26a70SApple OSS Distributions /** 6499*a1e26a70SApple OSS Distributions * @name Flags for MAC allocator interfaces 6500*a1e26a70SApple OSS Distributions * 6501*a1e26a70SApple OSS Distributions * These flags are passed to the Darwin kernel allocator routines to 6502*a1e26a70SApple OSS Distributions * indicate whether the allocation is permitted to block or not. 6503*a1e26a70SApple OSS Distributions * Caution should be taken; some operations are not permitted to sleep, 6504*a1e26a70SApple OSS Distributions * and some types of locks cannot be held when sleeping. 6505*a1e26a70SApple OSS Distributions */ 6506*a1e26a70SApple OSS Distributions 6507*a1e26a70SApple OSS Distributions /*@{*/ 6508*a1e26a70SApple OSS Distributions 6509*a1e26a70SApple OSS Distributions /** 6510*a1e26a70SApple OSS Distributions * @brief Allocation operations may block 6511*a1e26a70SApple OSS Distributions * 6512*a1e26a70SApple OSS Distributions * If memory is not immediately available, the allocation routine 6513*a1e26a70SApple OSS Distributions * will block (typically sleeping) until memory is available. 6514*a1e26a70SApple OSS Distributions * 6515*a1e26a70SApple OSS Distributions * @warning Inappropriate use of this flag may cause kernel panics. 6516*a1e26a70SApple OSS Distributions */ 6517*a1e26a70SApple OSS Distributions #define MAC_WAITOK 0 6518*a1e26a70SApple OSS Distributions 6519*a1e26a70SApple OSS Distributions /** 6520*a1e26a70SApple OSS Distributions * @brief Allocation operations may not block 6521*a1e26a70SApple OSS Distributions * 6522*a1e26a70SApple OSS Distributions * Rather than blocking, the allocator may return an error if memory 6523*a1e26a70SApple OSS Distributions * is not immediately available. This type of allocation will not 6524*a1e26a70SApple OSS Distributions * sleep, preserving locking semantics. 6525*a1e26a70SApple OSS Distributions */ 6526*a1e26a70SApple OSS Distributions #define MAC_NOWAIT 1 6527*a1e26a70SApple OSS Distributions 6528*a1e26a70SApple OSS Distributions /*@}*/ 6529*a1e26a70SApple OSS Distributions 6530*a1e26a70SApple OSS Distributions #endif /* !_SECURITY_MAC_POLICY_H_ */ 6531