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