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