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