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