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