2 * Copyright (c) 2007-2010 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
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.
34 * This software was developed by Robert Watson for the TrustedBSD Project.
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.
41 * This software was enhanced by SPARTA ISSO under SPAWAR contract
42 * N66001-04-C-6019 ("SEFOS").
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
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.
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
65 * $FreeBSD: src/sys/sys/mac_policy.h,v 1.39 2003/04/18 19:57:37 rwatson Exp $
70 @brief Kernel Interfaces for MAC policy modules
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
80 #ifndef _SECURITY_MAC_POLICY_H_
81 #define _SECURITY_MAC_POLICY_H_
83 #include <security/_label.h>
95 struct mac_module_data
;
96 struct mac_policy_conf
;
113 #ifndef _KAUTH_CRED_T
114 #define _KAUTH_CRED_T
115 typedef struct ucred
*kauth_cred_t
;
116 #endif /* !_KAUTH_CRED_T */
118 #ifndef __IOKIT_PORTS_DEFINED__
119 #define __IOKIT_PORTS_DEFINED__
122 typedef OSObject
*io_object_t
;
125 typedef struct OSObject
*io_object_t
;
127 #endif /* __IOKIT_PORTS_DEFINED__ */
130 * MAC entry points are generally named using the following template:
132 * mpo_<object>_<operation>()
136 * mpo_<object>_check_<operation>()
138 * Entry points are sorted by object type.
140 * It may be desirable also to consider some subsystems as "objects", such
141 * as system, iokit, etc.
145 @name Entry Points for Label Management
147 These are the entry points corresponding to the life cycle events for
148 kernel objects, such as initialization, creation, and destruction.
150 Most policies (that use labels) will initialize labels by allocating
151 space for policy-specific data. In most cases, it is permitted to
152 sleep during label initialization operations; it will be noted when
155 Initialization usually will not require doing more than allocating a
156 generic label for the given object. What follows initialization is
157 creation, where a label is made specific to the object it is associated
158 with. Destruction occurs when the label is no longer needed, such as
159 when the corresponding object is destroyed. All necessary cleanup should
160 be performed in label destroy operations.
162 Where possible, the label entry points have identical parameters. If
163 the policy module does not require structure-specific label
164 information, the same function may be registered in the policy
165 operation vector. Many policies will implement two such generic
166 allocation calls: one to handle sleepable requests, and one to handle
167 potentially non-sleepable requests.
172 @brief Audit event postselection
173 @param cred Subject credential
174 @param syscode Syscall number
175 @param args Syscall arguments
176 @param error Syscall errno
177 @param retval Syscall return value
179 This is the MAC Framework audit postselect, which is called before
180 exiting a syscall to determine if an audit event should be committed.
181 A return value of MAC_AUDIT_NO forces the audit record to be suppressed.
182 Any other return value results in the audit record being committed.
184 @warning The suppression behavior will probably go away in Apple's
185 future version of the audit implementation.
187 @return Return MAC_AUDIT_NO to force suppression of the audit record.
188 Any other value results in the audit record being committed.
191 typedef int mpo_audit_check_postselect_t(
193 unsigned short syscode
,
199 @brief Audit event preselection
200 @param cred Subject credential
201 @param syscode Syscall number
202 @param args Syscall arguments
204 This is the MAC Framework audit preselect, which is called before a
205 syscall is entered to determine if an audit event should be created.
206 If the MAC policy forces the syscall to be audited, MAC_AUDIT_YES should be
207 returned. A return value of MAC_AUDIT_NO causes the audit record to
208 be suppressed. Returning MAC_POLICY_DEFAULT indicates that the policy wants
209 to defer to the system's existing preselection mechanism.
211 When policies return different preferences, the Framework decides what action
212 to take based on the following policy. If any policy returns MAC_AUDIT_YES,
213 then create an audit record, else if any policy returns MAC_AUDIT_NO, then
214 suppress the creations of an audit record, else defer to the system's
215 existing preselection mechanism.
217 @warning The audit implementation in Apple's current version is
218 incomplete, so the MAC policies have priority over the system's existing
219 mechanisms. This will probably change in the future version where
220 the audit implementation is more complete.
222 @return Return MAC_AUDIT_YES to force auditing of the syscall,
223 MAC_AUDIT_NO to force no auditing of the syscall, MAC_AUDIT_DEFAULT
224 to allow auditing mechanisms to determine if the syscall is audited.
227 typedef int mpo_audit_check_preselect_t(
229 unsigned short syscode
,
233 @brief Initialize BPF descriptor label
234 @param label New label to initialize
236 Initialize the label for a newly instantiated BPF descriptor.
237 Sleeping is permitted.
239 typedef void mpo_bpfdesc_label_init_t(
243 @brief Destroy BPF descriptor label
244 @param label The label to be destroyed
246 Destroy a BPF descriptor label. Since the BPF descriptor
247 is going out of scope, policy modules should free any internal
248 storage associated with the label so that it may be destroyed.
250 typedef void mpo_bpfdesc_label_destroy_t(
254 @brief Associate a BPF descriptor with a label
255 @param cred User credential creating the BPF descriptor
256 @param bpf_d The BPF descriptor
257 @param bpflabel The new label
259 Set the label on a newly created BPF descriptor from the passed
260 subject credential. This call will be made when a BPF device node
261 is opened by a process with the passed subject credential.
263 typedef void mpo_bpfdesc_label_associate_t(
266 struct label
*bpflabel
269 @brief Check whether BPF can read from a network interface
270 @param bpf_d Subject; the BPF descriptor
271 @param bpflabel Policy label for bpf_d
272 @param ifp Object; the network interface
273 @param ifnetlabel Policy label for ifp
275 Determine whether the MAC framework should permit datagrams from
276 the passed network interface to be delivered to the buffers of
277 the passed BPF descriptor. Return (0) for success, or an errno
278 value for failure. Suggested failure: EACCES for label mismatches,
279 EPERM for lack of privilege.
281 typedef int mpo_bpfdesc_check_receive_t(
283 struct label
*bpflabel
,
285 struct label
*ifnetlabel
288 @brief Indicate desire to change the process label at exec time
289 @param old Existing subject credential
290 @param vp File being executed
291 @param vnodelabel Label corresponding to vp
292 @param scriptvnodelabel Script vnode label
293 @param execlabel Userspace provided execution label
294 @param proc Object process
296 @see mpo_cred_label_update_execve_t
297 @see mpo_vnode_check_exec_t
299 Indicate whether this policy intends to update the label of a newly
300 created credential from the existing subject credential (old). This
301 call occurs when a process executes the passed vnode. If a policy
302 returns success from this entry point, the mpo_cred_label_update_execve
303 entry point will later be called with the same parameters. Access
304 has already been checked via the mpo_vnode_check_exec entry point,
305 this entry point is necessary to preserve kernel locking constraints
306 during program execution.
308 The supplied vnode and vnodelabel correspond with the file actually
309 being executed; in the case that the file is interpreted (for
310 example, a script), the label of the original exec-time vnode has
311 been preserved in scriptvnodelabel.
313 The final label, execlabel, corresponds to a label supplied by a
314 user space application through the use of the mac_execve system call.
316 The vnode lock is held during this operation. No changes should be
317 made to the old credential structure.
319 @warning Even if a policy returns 0, it should behave correctly in
320 the presence of an invocation of mpo_cred_label_update_execve, as that
321 call may happen as a result of another policy requesting a transition.
323 @return Non-zero if a transition is required, 0 otherwise.
325 typedef int mpo_cred_check_label_update_execve_t(
328 struct label
*vnodelabel
,
329 struct label
*scriptvnodelabel
,
330 struct label
*execlabel
,
334 @brief Access control check for relabelling processes
335 @param cred Subject credential
336 @param newlabel New label to apply to the user credential
337 @see mpo_cred_label_update_t
340 Determine whether the subject identified by the credential can relabel
341 itself to the supplied new label (newlabel). This access control check
342 is called when the mac_set_proc system call is invoked. A user space
343 application will supply a new value, the value will be internalized
344 and provided in newlabel.
346 @return Return 0 if access is granted, otherwise an appropriate value for
347 errno should be returned.
349 typedef int mpo_cred_check_label_update_t(
351 struct label
*newlabel
354 @brief Access control check for visibility of other subjects
355 @param u1 Subject credential
356 @param u2 Object credential
358 Determine whether the subject identified by the credential u1 can
359 "see" other subjects with the passed subject credential u2. This call
360 may be made in a number of situations, including inter-process status
361 sysctls used by ps, and in procfs lookups.
363 @return Return 0 if access is granted, otherwise an appropriate value for
364 errno should be returned. Suggested failure: EACCES for label mismatch,
365 EPERM for lack of privilege, or ESRCH to hide visibility.
367 typedef int mpo_cred_check_visible_t(
372 @brief Associate a credential with a new process at fork
373 @param cred credential to inherited by new process
374 @param proc the new process
376 Allow a process to associate the credential with a new
377 process for reference countng purposes.
378 NOTE: the credential can be dis-associated in ways other
379 than exit - so this strategy is flawed - should just
380 catch label destroy callback.
382 typedef void mpo_cred_label_associate_fork_t(
387 @brief Create the first process
388 @param cred Subject credential to be labeled
390 Create the subject credential of process 0, the parent of all BSD
391 kernel processes. Policies should update the label in the
392 previously initialized credential structure.
394 typedef void mpo_cred_label_associate_kernel_t(
398 @brief Create a credential label
399 @param parent_cred Parent credential
400 @param child_cred Child credential
402 Set the label of a newly created credential, most likely using the
403 information in the supplied parent credential.
405 @warning This call is made when crcopy or crdup is invoked on a
406 newly created struct ucred, and should not be confused with a
407 process fork or creation event.
409 typedef void mpo_cred_label_associate_t(
410 kauth_cred_t parent_cred
,
411 kauth_cred_t child_cred
414 @brief Create the first process
415 @param cred Subject credential to be labeled
417 Create the subject credential of process 1, the parent of all BSD
418 user processes. Policies should update the label in the previously
419 initialized credential structure. This is the 'init' process.
421 typedef void mpo_cred_label_associate_user_t(
425 @brief Destroy credential label
426 @param label The label to be destroyed
428 Destroy a user credential label. Since the user credential
429 is going out of scope, policy modules should free any internal
430 storage associated with the label so that it may be destroyed.
432 typedef void mpo_cred_label_destroy_t(
436 @brief Externalize a user credential label for auditing
437 @param label Label to be externalized
438 @param element_name Name of the label namespace for which labels should be
440 @param sb String buffer to be filled with a text representation of the label
442 Produce an external representation of the label on a user credential for
443 inclusion in an audit record. An externalized label consists of a text
444 representation of the label contents that will be added to the audit record
445 as part of a text token. Policy-agnostic user space tools will display
446 this externalized version.
448 @return 0 on success, return non-zero if an error occurs while
449 externalizing the label data.
452 typedef int mpo_cred_label_externalize_audit_t(
458 @brief Externalize a user credential label
459 @param label Label to be externalized
460 @param element_name Name of the label namespace for which labels should be
462 @param sb String buffer to be filled with a text representation of the label
464 Produce an external representation of the label on a user
465 credential. An externalized label consists of a text representation
466 of the label contents that can be used with user applications.
467 Policy-agnostic user space tools will display this externalized
470 @return 0 on success, return non-zero if an error occurs while
471 externalizing the label data.
474 typedef int mpo_cred_label_externalize_t(
480 @brief Initialize user credential label
481 @param label New label to initialize
483 Initialize the label for a newly instantiated user credential.
484 Sleeping is permitted.
486 typedef void mpo_cred_label_init_t(
490 @brief Internalize a user credential label
491 @param label Label to be internalized
492 @param element_name Name of the label namespace for which the label should
494 @param element_data Text data to be internalized
496 Produce a user credential label from an external representation. An
497 externalized label consists of a text representation of the label
498 contents that can be used with user applications. Policy-agnostic
499 user space tools will forward text version to the kernel for
500 processing by individual policy modules.
502 The policy's internalize entry points will be called only if the
503 policy has registered interest in the label namespace.
505 @return 0 on success, Otherwise, return non-zero if an error occurs
506 while internalizing the label data.
509 typedef int mpo_cred_label_internalize_t(
515 @brief Update credential at exec time
516 @param old_cred Existing subject credential
517 @param new_cred New subject credential to be labeled
518 @param vp File being executed
519 @param vnodelabel Label corresponding to vp
520 @param scriptvnodelabel Script vnode label
521 @param execlabel Userspace provided execution label
523 @see mpo_cred_check_label_update_execve_t
524 @see mpo_vnode_check_exec_t
526 Update the label of a newly created credential (new) from the
527 existing subject credential (old). This call occurs when a process
528 executes the passed vnode and one of the loaded policy modules has
529 returned success from the mpo_cred_check_label_update_execve entry point.
530 Access has already been checked via the mpo_vnode_check_exec entry
531 point, this entry point is only used to update any policy state.
533 The supplied vnode and vnodelabel correspond with the file actually
534 being executed; in the case that the file is interpreted (for
535 example, a script), the label of the original exec-time vnode has
536 been preserved in scriptvnodelabel.
538 The final label, execlabel, corresponds to a label supplied by a
539 user space application through the use of the mac_execve system call.
541 If non-NULL, the value pointed to by disjointp will be set to 0 to
542 indicate that the old and new credentials are not disjoint, or 1 to
543 indicate that they are.
545 The vnode lock is held during this operation. No changes should be
546 made to the old credential structure.
548 typedef void mpo_cred_label_update_execve_t(
549 kauth_cred_t old_cred
,
550 kauth_cred_t new_cred
,
552 struct label
*vnodelabel
,
553 struct label
*scriptvnodelabel
,
554 struct label
*execlabel
,
558 @brief Update a credential label
559 @param cred The existing credential
560 @param newlabel A new label to apply to the credential
561 @see mpo_cred_check_label_update_t
564 Update the label on a user credential, using the supplied new label.
565 This is called as a result of a process relabel operation. Access
566 control was already confirmed by mpo_cred_check_label_update.
568 typedef void mpo_cred_label_update_t(
570 struct label
*newlabel
573 @brief Create a new devfs device
574 @param dev Major and minor numbers of special file
575 @param de "inode" of new device file
576 @param label Destination label
577 @param fullpath Path relative to mount (e.g. /dev) of new device file
579 This entry point labels a new devfs device. The label will likely be based
580 on the path to the device, or the major and minor numbers.
581 The policy should store an appropriate label into 'label'.
583 typedef void mpo_devfs_label_associate_device_t(
590 @brief Create a new devfs directory
591 @param dirname Name of new directory
592 @param dirnamelen Length of 'dirname'
593 @param de "inode" of new directory
594 @param label Destination label
595 @param fullpath Path relative to mount (e.g. /dev) of new directory
597 This entry point labels a new devfs directory. The label will likely be
598 based on the path of the new directory. The policy should store an appropriate
599 label into 'label'. The devfs root directory is labelled in this way.
601 typedef void mpo_devfs_label_associate_directory_t(
609 @brief Copy a devfs label
610 @param src Source devfs label
611 @param dest Destination devfs label
613 Copy the label information from src to dest. The devfs file system
614 often duplicates (splits) existing device nodes rather than creating
617 typedef void mpo_devfs_label_copy_t(
622 @brief Destroy devfs label
623 @param label The label to be destroyed
625 Destroy a devfs entry label. Since the object is going out
626 of scope, policy modules should free any internal storage associated
627 with the label so that it may be destroyed.
629 typedef void mpo_devfs_label_destroy_t(
633 @brief Initialize devfs label
634 @param label New label to initialize
636 Initialize the label for a newly instantiated devfs entry. Sleeping
639 typedef void mpo_devfs_label_init_t(
643 @brief Update a devfs label after relabelling its vnode
644 @param mp Devfs mount point
645 @param de Affected devfs directory entry
646 @param delabel Label of devfs directory entry
647 @param vp Vnode associated with de
648 @param vnodelabel New label of vnode
650 Update a devfs label when its vnode is manually relabelled,
651 for example with setfmac(1). Typically, this will simply copy
652 the vnode label into the devfs label.
654 typedef void mpo_devfs_label_update_t(
657 struct label
*delabel
,
659 struct label
*vnodelabel
662 @brief Access control for changing the offset of a file descriptor
663 @param cred Subject credential
664 @param fg Fileglob structure
665 @param label Policy label for fg
667 Determine whether the subject identified by the credential can
668 change the offset of the file represented by fg.
670 @return Return 0 if access if granted, otherwise an appropriate
671 value for errno should be returned.
673 typedef int mpo_file_check_change_offset_t(
679 @brief Access control for creating a file descriptor
680 @param cred Subject credential
682 Determine whether the subject identified by the credential can
683 allocate a new file descriptor.
685 @return Return 0 if access if granted, otherwise an appropriate
686 value for errno should be returned.
688 typedef int mpo_file_check_create_t(
692 @brief Access control for duplicating a file descriptor
693 @param cred Subject credential
694 @param fg Fileglob structure
695 @param label Policy label for fg
696 @param newfd New file descriptor number
698 Determine whether the subject identified by the credential can
699 duplicate the fileglob structure represented by fg and as file
700 descriptor number newfd.
702 @return Return 0 if access if granted, otherwise an appropriate
703 value for errno should be returned.
705 typedef int mpo_file_check_dup_t(
712 @brief Access control check for fcntl
713 @param cred Subject credential
714 @param fg Fileglob structure
715 @param label Policy label for fg
716 @param cmd Control operation to be performed; see fcntl(2)
717 @param arg fcnt arguments; see fcntl(2)
719 Determine whether the subject identified by the credential can perform
720 the file control operation indicated by cmd.
722 @return Return 0 if access is granted, otherwise an appropriate value for
723 errno should be returned.
725 typedef int mpo_file_check_fcntl_t(
733 @brief Access control check for mac_get_fd
734 @param cred Subject credential
735 @param fg Fileglob structure
736 @param elements Element buffer
737 @param len Length of buffer
739 Determine whether the subject identified by the credential should be allowed
740 to get an externalized version of the label on the object indicated by fd.
742 @return Return 0 if access is granted, otherwise an appropriate value for
743 errno should be returned.
745 typedef int mpo_file_check_get_t(
752 @brief Access control for getting the offset of a file descriptor
753 @param cred Subject credential
754 @param fg Fileglob structure
755 @param label Policy label for fg
757 Determine whether the subject identified by the credential can
758 get the offset of the file represented by fg.
760 @return Return 0 if access if granted, otherwise an appropriate
761 value for errno should be returned.
763 typedef int mpo_file_check_get_offset_t(
769 @brief Access control for inheriting a file descriptor
770 @param cred Subject credential
771 @param fg Fileglob structure
772 @param label Policy label for fg
774 Determine whether the subject identified by the credential can
775 inherit the fileglob structure represented by fg.
777 @return Return 0 if access if granted, otherwise an appropriate
778 value for errno should be returned.
780 typedef int mpo_file_check_inherit_t(
786 @brief Access control check for file ioctl
787 @param cred Subject credential
788 @param fg Fileglob structure
789 @param label Policy label for fg
790 @param cmd The ioctl command; see ioctl(2)
792 Determine whether the subject identified by the credential can perform
793 the ioctl operation indicated by cmd.
795 @warning Since ioctl data is opaque from the standpoint of the MAC
796 framework, policies must exercise extreme care when implementing
797 access control checks.
799 @return Return 0 if access is granted, otherwise an appropriate value for
800 errno should be returned.
803 typedef int mpo_file_check_ioctl_t(
810 @brief Access control check for file locking
811 @param cred Subject credential
812 @param fg Fileglob structure
813 @param label Policy label for fg
814 @param op The lock operation (F_GETLK, F_SETLK, F_UNLK)
815 @param fl The flock structure
817 Determine whether the subject identified by the credential can perform
818 the lock operation indicated by op and fl on the file represented by fg.
820 @return Return 0 if access is granted, otherwise an appropriate value for
821 errno should be returned.
824 typedef int mpo_file_check_lock_t(
832 @brief Access control check for mapping a file
833 @param cred Subject credential
834 @param fg fileglob representing file to map
835 @param label Policy label associated with vp
836 @param prot mmap protections; see mmap(2)
837 @param flags Type of mapped object; see mmap(2)
838 @param maxprot Maximum rights
840 Determine whether the subject identified by the credential should be
841 allowed to map the file represented by fg with the protections specified
842 in prot. The maxprot field holds the maximum permissions on the new
843 mapping, a combination of VM_PROT_READ, VM_PROT_WRITE, and VM_PROT_EXECUTE.
844 To avoid overriding prior access control checks, a policy should only
845 remove flags from maxprot.
847 @return Return 0 if access is granted, otherwise an appropriate value for
848 errno should be returned. Suggested failure: EACCES for label mismatch or
849 EPERM for lack of privilege.
851 typedef int mpo_file_check_mmap_t(
860 @brief Downgrade the mmap protections
861 @param cred Subject credential
862 @param fg file to map
863 @param label Policy label associated with vp
864 @param prot mmap protections to be downgraded
866 Downgrade the mmap protections based on the subject and object labels.
868 typedef void mpo_file_check_mmap_downgrade_t(
875 @brief Access control for receiving a file descriptor
876 @param cred Subject credential
877 @param fg Fileglob structure
878 @param label Policy label for fg
880 Determine whether the subject identified by the credential can
881 receive the fileglob structure represented by fg.
883 @return Return 0 if access if granted, otherwise an appropriate
884 value for errno should be returned.
886 typedef int mpo_file_check_receive_t(
892 @brief Access control check for mac_set_fd
893 @param cred Subject credential
894 @param fg Fileglob structure
895 @param elements Elements buffer
896 @param len Length of elements buffer
898 Determine whether the subject identified by the credential can
899 perform the mac_set_fd operation. The mac_set_fd operation is used
900 to associate a MAC label with a file.
902 @return Return 0 if access is granted, otherwise an appropriate value for
903 errno should be returned.
905 typedef int mpo_file_check_set_t(
912 @brief Create file label
913 @param cred Subject credential
914 @param fg Fileglob structure
915 @param label Policy label for fg
917 typedef void mpo_file_label_associate_t(
923 @brief Destroy file label
924 @param label The label to be destroyed
926 Destroy the label on a file descriptor. In this entry point, a
927 policy module should free any internal storage associated with
928 label so that it may be destroyed.
930 typedef void mpo_file_label_destroy_t(
934 @brief Initialize file label
935 @param label New label to initialize
937 typedef void mpo_file_label_init_t(
941 @brief Access control check for relabeling network interfaces
942 @param cred Subject credential
943 @param ifp network interface being relabeled
944 @param ifnetlabel Current label of the network interfaces
945 @param newlabel New label to apply to the network interfaces
946 @see mpo_ifnet_label_update_t
948 Determine whether the subject identified by the credential can
949 relabel the network interface represented by ifp to the supplied
950 new label (newlabel).
952 @return Return 0 if access is granted, otherwise an appropriate value for
953 errno should be returned.
955 typedef int mpo_ifnet_check_label_update_t(
958 struct label
*ifnetlabel
,
959 struct label
*newlabel
962 @brief Access control check for relabeling network interfaces
963 @param ifp Network interface mbuf will be transmitted through
964 @param ifnetlabel Label of the network interfaces
965 @param m The mbuf to be transmitted
966 @param mbuflabel Label of the mbuf to be transmitted
967 @param family Address Family, AF_*
968 @param type Type of socket, SOCK_{STREAM,DGRAM,RAW}
970 Determine whether the mbuf with label mbuflabel may be transmitted
971 through the network interface represented by ifp that has the
974 @return Return 0 if access is granted, otherwise an appropriate value for
975 errno should be returned.
977 typedef int mpo_ifnet_check_transmit_t(
979 struct label
*ifnetlabel
,
981 struct label
*mbuflabel
,
986 @brief Create a network interface label
987 @param ifp Network interface labeled
988 @param ifnetlabel Label for the network interface
990 Set the label of a newly created network interface, most likely
991 using the information in the supplied network interface struct.
993 typedef void mpo_ifnet_label_associate_t(
995 struct label
*ifnetlabel
998 @brief Copy an ifnet label
999 @param src Source ifnet label
1000 @param dest Destination ifnet label
1002 Copy the label information from src to dest.
1004 typedef void mpo_ifnet_label_copy_t(
1009 @brief Destroy ifnet label
1010 @param label The label to be destroyed
1012 Destroy the label on an ifnet label. In this entry point, a
1013 policy module should free any internal storage associated with
1014 label so that it may be destroyed.
1016 typedef void mpo_ifnet_label_destroy_t(
1020 @brief Externalize an ifnet label
1021 @param label Label to be externalized
1022 @param element_name Name of the label namespace for which labels should be
1024 @param sb String buffer to be filled with a text representation of the label
1026 Produce an external representation of the label on an interface.
1027 An externalized label consists of a text representation of the
1028 label contents that can be used with user applications.
1029 Policy-agnostic user space tools will display this externalized
1032 @return 0 on success, return non-zero if an error occurs while
1033 externalizing the label data.
1036 typedef int mpo_ifnet_label_externalize_t(
1037 struct label
*label
,
1042 @brief Initialize ifnet label
1043 @param label New label to initialize
1045 typedef void mpo_ifnet_label_init_t(
1049 @brief Internalize an interface label
1050 @param label Label to be internalized
1051 @param element_name Name of the label namespace for which the label should
1053 @param element_data Text data to be internalized
1055 Produce an interface label from an external representation. An
1056 externalized label consists of a text representation of the label
1057 contents that can be used with user applications. Policy-agnostic
1058 user space tools will forward text version to the kernel for
1059 processing by individual policy modules.
1061 The policy's internalize entry points will be called only if the
1062 policy has registered interest in the label namespace.
1064 @return 0 on success, Otherwise, return non-zero if an error occurs
1065 while internalizing the label data.
1068 typedef int mpo_ifnet_label_internalize_t(
1069 struct label
*label
,
1074 @brief Recycle up a network interface label
1075 @param label The label to be recycled
1077 Recycle a network interface label. Darwin caches the struct ifnet
1078 of detached ifnets in a "free pool". Before ifnets are returned
1079 to the "free pool", policies can cleanup or overwrite any information
1080 present in the label.
1082 typedef void mpo_ifnet_label_recycle_t(
1086 @brief Update a network interface label
1087 @param cred Subject credential
1088 @param ifp The network interface to be relabeled
1089 @param ifnetlabel The current label of the network interface
1090 @param newlabel A new label to apply to the network interface
1091 @see mpo_ifnet_check_label_update_t
1093 Update the label on a network interface, using the supplied new label.
1095 typedef void mpo_ifnet_label_update_t(
1098 struct label
*ifnetlabel
,
1099 struct label
*newlabel
1102 @brief Access control check for delivering a packet to a socket
1103 @param inp inpcb the socket is associated with
1104 @param inplabel Label of the inpcb
1105 @param m The mbuf being received
1106 @param mbuflabel Label of the mbuf being received
1107 @param family Address family, AF_*
1108 @param type Type of socket, SOCK_{STREAM,DGRAM,RAW}
1110 Determine whether the mbuf with label mbuflabel may be received
1111 by the socket associated with inpcb that has the label inplabel.
1113 @return Return 0 if access is granted, otherwise an appropriate value for
1114 errno should be returned.
1116 typedef int mpo_inpcb_check_deliver_t(
1118 struct label
*inplabel
,
1120 struct label
*mbuflabel
,
1125 @brief Create an inpcb label
1126 @param so Socket containing the inpcb to be labeled
1127 @param solabel Label of the socket
1128 @param inp inpcb to be labeled
1129 @param inplabel Label for the inpcb
1131 Set the label of a newly created inpcb, most likely
1132 using the information in the socket and/or socket label.
1134 typedef void mpo_inpcb_label_associate_t(
1136 struct label
*solabel
,
1138 struct label
*inplabel
1141 @brief Destroy inpcb label
1142 @param label The label to be destroyed
1144 Destroy the label on an inpcb label. In this entry point, a
1145 policy module should free any internal storage associated with
1146 label so that it may be destroyed.
1148 typedef void mpo_inpcb_label_destroy_t(
1152 @brief Initialize inpcb label
1153 @param label New label to initialize
1154 @param flag M_WAITOK or M_NOWAIT
1156 typedef int mpo_inpcb_label_init_t(
1157 struct label
*label
,
1161 @brief Recycle up an inpcb label
1162 @param label The label to be recycled
1164 Recycle an inpcb label. Darwin allocates the inpcb as part of
1165 the socket structure in some cases. For this case we must recycle
1166 rather than destroy the inpcb as it will be reused later.
1168 typedef void mpo_inpcb_label_recycle_t(
1172 @brief Update an inpcb label from a socket label
1173 @param so Socket containing the inpcb to be relabeled
1174 @param solabel New label of the socket
1175 @param inp inpcb to be labeled
1176 @param inplabel Label for the inpcb
1178 Set the label of a newly created inpcb due to a change in the
1179 underlying socket label.
1181 typedef void mpo_inpcb_label_update_t(
1183 struct label
*solabel
,
1185 struct label
*inplabel
1188 @brief Device hardware access control
1189 @param devtype Type of device connected
1190 @param properties XML-formatted property list
1191 @param proplen Length of the property list
1193 This is the MAC Framework device access control, which is called by the I/O
1194 Kit when a new device is connected to the system to determine whether that
1195 device should be trusted. A list of properties associated with the device
1196 is passed as an XML-formatted string. The routine should examine these
1197 properties to determine the trustworthiness of the device. A return value
1198 of EPERM forces the device to be claimed by a special device driver that
1199 will prevent its operation.
1201 @warning This is an experimental interface and may change in the future.
1203 @return Return EPERM to indicate that the device is untrusted and should
1204 not be allowed to operate. Return zero to indicate that the device is
1205 trusted and should be allowed to operate normally.
1208 typedef int mpo_iokit_check_device_t(
1210 struct mac_module_data
*mdata
1213 @brief Access control check for opening an I/O Kit device
1214 @param cred Subject credential
1215 @param device_path Device path
1216 @param user_client User client instance
1217 @param user_client_type User client type
1219 Determine whether the subject identified by the credential can open an
1220 I/O Kit device at the passed path of the passed user client class and
1223 @return Return 0 if access is granted, or an appropriate value for
1224 errno should be returned.
1226 typedef int mpo_iokit_check_open_t(
1228 io_object_t user_client
,
1229 unsigned int user_client_type
1232 @brief Access control check for setting I/O Kit device properties
1233 @param cred Subject credential
1234 @param registry_entry Target device
1235 @param properties Property list
1237 Determine whether the subject identified by the credential can set
1238 properties on an I/O Kit device.
1240 @return Return 0 if access is granted, or an appropriate value for
1241 errno should be returned.
1243 typedef int mpo_iokit_check_set_properties_t(
1246 io_object_t properties
1249 @brief Access control check for software HID control
1250 @param cred Subject credential
1252 Determine whether the subject identified by the credential can
1253 control the HID (Human Interface Device) subsystem, such as to
1254 post synthetic keypresses, pointer movement and clicks.
1256 @return Return 0 if access is granted, or an appropriate value for
1259 typedef int mpo_iokit_check_hid_control_t(
1263 @brief Create an IP reassembly queue label
1264 @param fragment First received IP fragment
1265 @param fragmentlabel Policy label for fragment
1266 @param ipq IP reassembly queue to be labeled
1267 @param ipqlabel Policy label to be filled in for ipq
1269 Set the label on a newly created IP reassembly queue from
1270 the mbuf header of the first received fragment.
1272 typedef void mpo_ipq_label_associate_t(
1273 struct mbuf
*fragment
,
1274 struct label
*fragmentlabel
,
1276 struct label
*ipqlabel
1279 @brief Compare an mbuf header label to an ipq label
1280 @param fragment IP datagram fragment
1281 @param fragmentlabel Policy label for fragment
1282 @param ipq IP fragment reassembly queue
1283 @param ipqlabel Policy label for ipq
1285 Compare the label of the mbuf header containing an IP datagram
1286 (fragment) fragment with the label of the passed IP fragment
1287 reassembly queue (ipq). Return (1) for a successful match, or (0)
1288 for no match. This call is made when the IP stack attempts to
1289 find an existing fragment reassembly queue for a newly received
1290 fragment; if this fails, a new fragment reassembly queue may be
1291 instantiated for the fragment. Policies may use this entry point
1292 to prevent the reassembly of otherwise matching IP fragments if
1293 policy does not permit them to be reassembled based on the label
1294 or other information.
1296 typedef int mpo_ipq_label_compare_t(
1297 struct mbuf
*fragment
,
1298 struct label
*fragmentlabel
,
1300 struct label
*ipqlabel
1303 @brief Destroy IP reassembly queue label
1304 @param label The label to be destroyed
1306 Destroy the label on an IP fragment queue. In this entry point, a
1307 policy module should free any internal storage associated with
1308 label so that it may be destroyed.
1310 typedef void mpo_ipq_label_destroy_t(
1314 @brief Initialize IP reassembly queue label
1315 @param label New label to initialize
1316 @param flag M_WAITOK or M_NOWAIT
1318 Initialize the label on a newly instantiated IP fragment reassembly
1319 queue. The flag field may be one of M_WAITOK and M_NOWAIT, and
1320 should be employed to avoid performing a sleeping malloc(9) during
1321 this initialization call. IP fragment reassembly queue allocation
1322 frequently occurs in performance sensitive environments, and the
1323 implementation should be careful to avoid sleeping or long-lived
1324 operations. This entry point is permitted to fail resulting in
1325 the failure to allocate the IP fragment reassembly queue.
1327 typedef int mpo_ipq_label_init_t(
1328 struct label
*label
,
1332 @brief Update the label on an IP fragment reassembly queue
1333 @param fragment IP fragment
1334 @param fragmentlabel Policy label for fragment
1335 @param ipq IP fragment reassembly queue
1336 @param ipqlabel Policy label to be updated for ipq
1338 Update the label on an IP fragment reassembly queue (ipq) based
1339 on the acceptance of the passed IP fragment mbuf header (fragment).
1341 typedef void mpo_ipq_label_update_t(
1342 struct mbuf
*fragment
,
1343 struct label
*fragmentlabel
,
1345 struct label
*ipqlabel
1348 @brief Access control check for relabelling Login Context
1349 @param l Subject credential
1350 @param newlabel New label to apply to the Login Context
1351 @see mpo_lctx_label_update_t
1355 Determine whether the subject identified by the credential can relabel
1356 itself to the supplied new label (newlabel). This access control check
1357 is called when the mac_set_lctx/lcid system call is invoked. A user space
1358 application will supply a new value, the value will be internalized
1359 and provided in newlabel.
1361 @return Return 0 if access is granted, otherwise an appropriate value for
1362 errno should be returned.
1364 typedef int mpo_lctx_check_label_update_t(
1366 struct label
*newlabel
1369 @brief Destroy Login Context label
1370 @param label The label to be destroyed
1372 typedef void mpo_lctx_label_destroy_t(
1376 @brief Externalize a Login Context label
1377 @param label Label to be externalized
1378 @param element_name Name of the label namespace for which labels should be
1380 @param sb String buffer to be filled with a text representation of the label
1382 Produce an external representation of the label on a Login Context.
1383 An externalized label consists of a text representation
1384 of the label contents that can be used with user applications.
1385 Policy-agnostic user space tools will display this externalized
1388 @return 0 on success, return non-zero if an error occurs while
1389 externalizing the label data.
1392 typedef int mpo_lctx_label_externalize_t(
1393 struct label
*label
,
1398 @brief Initialize Login Context label
1399 @param label New label to initialize
1401 typedef void mpo_lctx_label_init_t(
1405 @brief Internalize a Login Context label
1406 @param label Label to be internalized
1407 @param element_name Name of the label namespace for which the label should
1409 @param element_data Text data to be internalized
1411 Produce a Login Context label from an external representation. An
1412 externalized label consists of a text representation of the label
1413 contents that can be used with user applications. Policy-agnostic
1414 user space tools will forward text version to the kernel for
1415 processing by individual policy modules.
1417 The policy's internalize entry points will be called only if the
1418 policy has registered interest in the label namespace.
1420 @return 0 on success, Otherwise, return non-zero if an error occurs
1421 while internalizing the label data.
1424 typedef int mpo_lctx_label_internalize_t(
1425 struct label
*label
,
1430 @brief Update a Login Context label
1432 @param newlabel A new label to apply to the Login Context
1433 @see mpo_lctx_check_label_update_t
1437 Update the label on a login context, using the supplied new label.
1438 This is called as a result of a login context relabel operation. Access
1439 control was already confirmed by mpo_lctx_check_label_update.
1441 typedef void mpo_lctx_label_update_t(
1443 struct label
*newlabel
1446 @brief A process has created a login context
1448 @param l Login Context
1450 When a process creates a login context (via setlcid()) this entrypoint
1451 is called to notify the policy that the process 'p' has created login
1454 typedef void mpo_lctx_notify_create_t(
1459 @brief A process has joined a login context
1461 @param l Login Context
1463 When a process joins a login context, either via setlcid() or via
1464 fork() this entrypoint is called to notify the policy that process
1465 'p' is now a member of login context 'l'.
1467 typedef void mpo_lctx_notify_join_t(
1472 @brief A process has left a login context
1474 @param l Login Context
1476 When a process leaves a login context either via setlcid() or as a
1477 result of the process exiting this entrypoint is called to notify
1478 the policy that the process 'p' is no longer a member of login context 'l'.
1480 typedef void mpo_lctx_notify_leave_t(
1485 @brief Assign a label to a new mbuf
1486 @param bpf_d BPF descriptor
1487 @param b_label Policy label for bpf_d
1488 @param m Object; mbuf
1489 @param m_label Policy label to fill in for m
1491 Set the label on the mbuf header of a newly created datagram
1492 generated using the passed BPF descriptor. This call is made when
1493 a write is performed to the BPF device associated with the passed
1496 typedef void mpo_mbuf_label_associate_bpfdesc_t(
1497 struct bpf_d
*bpf_d
,
1498 struct label
*b_label
,
1500 struct label
*m_label
1503 @brief Assign a label to a new mbuf
1504 @param ifp Interface descriptor
1505 @param i_label Existing label of ifp
1506 @param m Object; mbuf
1507 @param m_label Policy label to fill in for m
1509 Label an mbuf based on the interface from which it was received.
1511 typedef void mpo_mbuf_label_associate_ifnet_t(
1513 struct label
*i_label
,
1515 struct label
*m_label
1518 @brief Assign a label to a new mbuf
1519 @param inp inpcb structure
1520 @param i_label Existing label of inp
1521 @param m Object; mbuf
1522 @param m_label Policy label to fill in for m
1524 Label an mbuf based on the inpcb from which it was derived.
1526 typedef void mpo_mbuf_label_associate_inpcb_t(
1528 struct label
*i_label
,
1530 struct label
*m_label
1533 @brief Set the label on a newly reassembled IP datagram
1534 @param ipq IP fragment reassembly queue
1535 @param ipqlabel Policy label for ipq
1536 @param mbuf IP datagram to be labeled
1537 @param mbuflabel Policy label to be filled in for mbuf
1539 Set the label on a newly reassembled IP datagram (mbuf) from the IP
1540 fragment reassembly queue (ipq) from which it was generated.
1542 typedef void mpo_mbuf_label_associate_ipq_t(
1544 struct label
*ipqlabel
,
1546 struct label
*mbuflabel
1549 @brief Assign a label to a new mbuf
1550 @param ifp Subject; network interface
1551 @param i_label Existing label of ifp
1552 @param m Object; mbuf
1553 @param m_label Policy label to fill in for m
1555 Set the label on the mbuf header of a newly created datagram
1556 generated for the purposes of a link layer response for the passed
1557 interface. This call may be made in a number of situations, including
1558 for ARP or ND6 responses in the IPv4 and IPv6 stacks.
1560 typedef void mpo_mbuf_label_associate_linklayer_t(
1562 struct label
*i_label
,
1564 struct label
*m_label
1567 @brief Assign a label to a new mbuf
1568 @param oldmbuf mbuf headerder for existing datagram for existing datagram
1569 @param oldmbuflabel Policy label for oldmbuf
1570 @param ifp Network interface
1571 @param ifplabel Policy label for ifp
1572 @param newmbuf mbuf header to be labeled for new datagram
1573 @param newmbuflabel Policy label for newmbuf
1575 Set the label on the mbuf header of a newly created datagram
1576 generated from the existing passed datagram when it is processed
1577 by the passed multicast encapsulation interface. This call is made
1578 when an mbuf is to be delivered using the virtual interface.
1580 typedef void mpo_mbuf_label_associate_multicast_encap_t(
1581 struct mbuf
*oldmbuf
,
1582 struct label
*oldmbuflabel
,
1584 struct label
*ifplabel
,
1585 struct mbuf
*newmbuf
,
1586 struct label
*newmbuflabel
1589 @brief Assign a label to a new mbuf
1590 @param oldmbuf Received datagram
1591 @param oldmbuflabel Policy label for oldmbuf
1592 @param newmbuf Newly created datagram
1593 @param newmbuflabel Policy label for newmbuf
1595 Set the label on the mbuf header of a newly created datagram generated
1596 by the IP stack in response to an existing received datagram (oldmbuf).
1597 This call may be made in a number of situations, including when responding
1598 to ICMP request datagrams.
1600 typedef void mpo_mbuf_label_associate_netlayer_t(
1601 struct mbuf
*oldmbuf
,
1602 struct label
*oldmbuflabel
,
1603 struct mbuf
*newmbuf
,
1604 struct label
*newmbuflabel
1607 @brief Assign a label to a new mbuf
1608 @param so Socket to label
1609 @param so_label Policy label for socket
1610 @param m Object; mbuf
1611 @param m_label Policy label to fill in for m
1613 An mbuf structure is used to store network traffic in transit.
1614 When an application sends data to a socket or a pipe, it is wrapped
1615 in an mbuf first. This function sets the label on a newly created mbuf header
1616 based on the socket sending the data. The contents of the label should be
1617 suitable for performing an access check on the receiving side of the
1620 Only labeled MBUFs will be presented to the policy via this entrypoint.
1622 typedef void mpo_mbuf_label_associate_socket_t(
1624 struct label
*so_label
,
1626 struct label
*m_label
1629 @brief Copy a mbuf label
1630 @param src Source label
1631 @param dest Destination label
1633 Copy the mbuf label information in src into dest.
1635 Only called when both source and destination mbufs have labels.
1637 typedef void mpo_mbuf_label_copy_t(
1642 @brief Destroy mbuf label
1643 @param label The label to be destroyed
1645 Destroy a mbuf label. Since the
1646 object is going out of scope, policy modules should free any
1647 internal storage associated with the label so that it may be
1650 typedef void mpo_mbuf_label_destroy_t(
1654 @brief Initialize mbuf label
1655 @param label New label to initialize
1656 @param flag Malloc flags
1658 Initialize the label for a newly instantiated mbuf.
1660 @warning Since it is possible for the flags to be set to
1661 M_NOWAIT, the malloc operation may fail.
1663 @return On success, 0, otherwise, an appropriate errno return value.
1665 typedef int mpo_mbuf_label_init_t(
1666 struct label
*label
,
1670 @brief Access control check for fsctl
1671 @param cred Subject credential
1672 @param mp The mount point
1673 @param label Label associated with the mount point
1674 @param com Filesystem-dependent request code; see fsctl(2)
1676 Determine whether the subject identified by the credential can perform
1677 the volume operation indicated by com.
1679 @warning The fsctl() system call is directly analogous to ioctl(); since
1680 the associated data is opaque from the standpoint of the MAC framework
1681 and since these operations can affect many aspects of system operation,
1682 policies must exercise extreme care when implementing access control checks.
1684 @return Return 0 if access is granted, otherwise an appropriate value for
1685 errno should be returned.
1687 typedef int mpo_mount_check_fsctl_t(
1690 struct label
*label
,
1694 @brief Access control check for the retrieval of file system attributes
1695 @param cred Subject credential
1696 @param mp The mount structure of the file system
1697 @param vfa The attributes requested
1699 This entry point determines whether given subject can get information
1700 about the given file system. This check happens during statfs() syscalls,
1701 but is also used by other parts within the kernel such as the audit system.
1703 @return Return 0 if access is granted, otherwise an appropriate value for
1704 errno should be returned.
1707 typedef int mpo_mount_check_getattr_t(
1710 struct label
*mp_label
,
1711 struct vfs_attr
*vfa
1714 @brief Access control check for mount point relabeling
1715 @param cred Subject credential
1716 @param mp Object file system mount point
1717 @param mntlabel Policy label for fle system mount point
1719 Determine whether the subject identified by the credential can relabel
1720 the mount point. This call is made when a file system mount is updated.
1722 @return Return 0 if access is granted, otherwise an appropriate value for
1723 errno should be returned. Suggested failure: EACCES for label mismatch
1724 or EPERM for lack of privilege.
1726 typedef int mpo_mount_check_label_update_t(
1729 struct label
*mntlabel
1732 @brief Access control check for mounting a file system
1733 @param cred Subject credential
1734 @param vp Vnode that is to be the mount point
1735 @param vlabel Label associated with the vnode
1736 @param cnp Component name for vp
1737 @param vfc_name Filesystem type name
1739 Determine whether the subject identified by the credential can perform
1740 the mount operation on the target vnode.
1742 @return Return 0 if access is granted, otherwise an appropriate value for
1743 errno should be returned.
1745 typedef int mpo_mount_check_mount_t(
1748 struct label
*vlabel
,
1749 struct componentname
*cnp
,
1750 const char *vfc_name
1753 @brief Access control check remounting a filesystem
1754 @param cred Subject credential
1755 @param mp The mount point
1756 @param mlabel Label currently associated with the mount point
1758 Determine whether the subject identified by the credential can perform
1759 the remount operation on the target vnode.
1761 @return Return 0 if access is granted, otherwise an appropriate value for
1762 errno should be returned.
1764 typedef int mpo_mount_check_remount_t(
1767 struct label
*mlabel
1770 @brief Access control check for the settting of file system attributes
1771 @param cred Subject credential
1772 @param mp The mount structure of the file system
1773 @param vfa The attributes requested
1775 This entry point determines whether given subject can set information
1776 about the given file system, for example the volume name.
1778 @return Return 0 if access is granted, otherwise an appropriate value for
1779 errno should be returned.
1782 typedef int mpo_mount_check_setattr_t(
1785 struct label
*mp_label
,
1786 struct vfs_attr
*vfa
1789 @brief Access control check for file system statistics
1790 @param cred Subject credential
1791 @param mp Object file system mount
1792 @param mntlabel Policy label for mp
1794 Determine whether the subject identified by the credential can see
1795 the results of a statfs performed on the file system. This call may
1796 be made in a number of situations, including during invocations of
1797 statfs(2) and related calls, as well as to determine what file systems
1798 to exclude from listings of file systems, such as when getfsstat(2)
1801 @return Return 0 if access is granted, otherwise an appropriate value for
1802 errno should be returned. Suggested failure: EACCES for label mismatch
1803 or EPERM for lack of privilege.
1805 typedef int mpo_mount_check_stat_t(
1808 struct label
*mntlabel
1811 @brief Access control check for unmounting a filesystem
1812 @param cred Subject credential
1813 @param mp The mount point
1814 @param mlabel Label associated with the mount point
1816 Determine whether the subject identified by the credential can perform
1817 the unmount operation on the target vnode.
1819 @return Return 0 if access is granted, otherwise an appropriate value for
1820 errno should be returned.
1822 typedef int mpo_mount_check_umount_t(
1825 struct label
*mlabel
1828 @brief Create mount labels
1829 @param cred Subject credential
1830 @param mp Mount point of file system being mounted
1831 @param mntlabel Label to associate with the new mount point
1832 @see mpo_mount_label_init_t
1834 Fill out the labels on the mount point being created by the supplied
1835 user credential. This call is made when file systems are first mounted.
1837 typedef void mpo_mount_label_associate_t(
1840 struct label
*mntlabel
1843 @brief Destroy mount label
1844 @param label The label to be destroyed
1846 Destroy a file system mount label. Since the
1847 object is going out of scope, policy modules should free any
1848 internal storage associated with the label so that it may be
1851 typedef void mpo_mount_label_destroy_t(
1855 @brief Externalize a mount point label
1856 @param label Label to be externalized
1857 @param element_name Name of the label namespace for which labels should be
1859 @param sb String buffer to be filled with a text representation of the label
1861 Produce an external representation of the mount point label. An
1862 externalized label consists of a text representation of the label
1863 contents that can be used with user applications. Policy-agnostic
1864 user space tools will display this externalized version.
1866 The policy's externalize entry points will be called only if the
1867 policy has registered interest in the label namespace.
1869 @return 0 on success, return non-zero if an error occurs while
1870 externalizing the label data.
1873 typedef int mpo_mount_label_externalize_t(
1874 struct label
*label
,
1879 @brief Initialize mount point label
1880 @param label New label to initialize
1882 Initialize the label for a newly instantiated mount structure.
1883 This label is typically used to store a default label in the case
1884 that the file system has been mounted singlelabel. Since some
1885 file systems do not support persistent labels (extended attributes)
1886 or are read-only (such as CD-ROMs), it is often necessary to store
1887 a default label separately from the label of the mount point
1888 itself. Sleeping is permitted.
1890 typedef void mpo_mount_label_init_t(
1894 @brief Internalize a mount point label
1895 @param label Label to be internalized
1896 @param element_name Name of the label namespace for which the label should
1898 @param element_data Text data to be internalized
1900 Produce a mount point file system label from an external representation.
1901 An externalized label consists of a text representation of the label
1902 contents that can be used with user applications. Policy-agnostic
1903 user space tools will forward text version to the kernel for
1904 processing by individual policy modules.
1906 The policy's internalize entry points will be called only if the
1907 policy has registered interest in the label namespace.
1909 @return 0 on success, Otherwise, return non-zero if an error occurs
1910 while internalizing the label data.
1913 typedef int mpo_mount_label_internalize_t(
1914 struct label
*label
,
1919 @brief Set the label on an IPv4 datagram fragment
1920 @param datagram Datagram being fragmented
1921 @param datagramlabel Policy label for datagram
1922 @param fragment New fragment
1923 @param fragmentlabel Policy label for fragment
1925 Called when an IPv4 datagram is fragmented into several smaller datagrams.
1926 Policies implementing mbuf labels will typically copy the label from the
1927 source datagram to the new fragment.
1929 typedef void mpo_netinet_fragment_t(
1930 struct mbuf
*datagram
,
1931 struct label
*datagramlabel
,
1932 struct mbuf
*fragment
,
1933 struct label
*fragmentlabel
1936 @brief Set the label on an ICMP reply
1937 @param m mbuf containing the ICMP reply
1938 @param mlabel Policy label for m
1940 A policy may wish to update the label of an mbuf that refers to
1941 an ICMP packet being sent in response to an IP packet. This may
1942 be called in response to a bad packet or an ICMP request.
1944 typedef void mpo_netinet_icmp_reply_t(
1946 struct label
*mlabel
1949 @brief Set the label on a TCP reply
1950 @param m mbuf containing the TCP reply
1951 @param mlabel Policy label for m
1953 Called for outgoing TCP packets not associated with an actual socket.
1955 typedef void mpo_netinet_tcp_reply_t(
1957 struct label
*mlabel
1960 @brief Access control check for pipe ioctl
1961 @param cred Subject credential
1962 @param cpipe Object to be accessed
1963 @param pipelabel The label on the pipe
1964 @param cmd The ioctl command; see ioctl(2)
1966 Determine whether the subject identified by the credential can perform
1967 the ioctl operation indicated by cmd.
1969 @warning Since ioctl data is opaque from the standpoint of the MAC
1970 framework, policies must exercise extreme care when implementing
1971 access control checks.
1973 @return Return 0 if access is granted, otherwise an appropriate value for
1974 errno should be returned.
1977 typedef int mpo_pipe_check_ioctl_t(
1980 struct label
*pipelabel
,
1984 @brief Access control check for pipe kqfilter
1985 @param cred Subject credential
1986 @param kn Object knote
1987 @param cpipe Object to be accessed
1988 @param pipelabel Policy label for the pipe
1990 Determine whether the subject identified by the credential can
1991 receive the knote on the passed pipe.
1993 @return Return 0 if access if granted, otherwise an appropriate
1994 value for errno should be returned.
1996 typedef int mpo_pipe_check_kqfilter_t(
2000 struct label
*pipelabel
2003 @brief Access control check for pipe relabel
2004 @param cred Subject credential
2005 @param cpipe Object to be accessed
2006 @param pipelabel The current label on the pipe
2007 @param newlabel The new label to be used
2009 Determine whether the subject identified by the credential can
2010 perform a relabel operation on the passed pipe. The cred object holds
2011 the credentials of the subject performing the operation.
2013 @return Return 0 if access is granted, otherwise an appropriate value for
2014 errno should be returned.
2017 typedef int mpo_pipe_check_label_update_t(
2020 struct label
*pipelabel
,
2021 struct label
*newlabel
2024 @brief Access control check for pipe read
2025 @param cred Subject credential
2026 @param cpipe Object to be accessed
2027 @param pipelabel The label on the pipe
2029 Determine whether the subject identified by the credential can
2030 perform a read operation on the passed pipe. The cred object holds
2031 the credentials of the subject performing the operation.
2033 @return Return 0 if access is granted, otherwise an appropriate value for
2034 errno should be returned.
2037 typedef int mpo_pipe_check_read_t(
2040 struct label
*pipelabel
2043 @brief Access control check for pipe select
2044 @param cred Subject credential
2045 @param cpipe Object to be accessed
2046 @param pipelabel The label on the pipe
2047 @param which The operation selected on: FREAD or FWRITE
2049 Determine whether the subject identified by the credential can
2050 perform a select operation on the passed pipe. The cred object holds
2051 the credentials of the subject performing the operation.
2053 @return Return 0 if access is granted, otherwise an appropriate value for
2054 errno should be returned.
2057 typedef int mpo_pipe_check_select_t(
2060 struct label
*pipelabel
,
2064 @brief Access control check for pipe stat
2065 @param cred Subject credential
2066 @param cpipe Object to be accessed
2067 @param pipelabel The label on the pipe
2069 Determine whether the subject identified by the credential can
2070 perform a stat operation on the passed pipe. The cred object holds
2071 the credentials of the subject performing the operation.
2073 @return Return 0 if access is granted, otherwise an appropriate value for
2074 errno should be returned.
2077 typedef int mpo_pipe_check_stat_t(
2080 struct label
*pipelabel
2083 @brief Access control check for pipe write
2084 @param cred Subject credential
2085 @param cpipe Object to be accessed
2086 @param pipelabel The label on the pipe
2088 Determine whether the subject identified by the credential can
2089 perform a write operation on the passed pipe. The cred object holds
2090 the credentials of the subject performing the operation.
2092 @return Return 0 if access is granted, otherwise an appropriate value for
2093 errno should be returned.
2096 typedef int mpo_pipe_check_write_t(
2099 struct label
*pipelabel
2102 @brief Create a pipe label
2103 @param cred Subject credential
2104 @param cpipe object to be labeled
2105 @param label Label for the pipe object
2107 Create a label for the pipe object being created by the supplied
2108 user credential. This call is made when the pipe is being created
2109 XXXPIPE(for one or both sides of the pipe?).
2112 typedef void mpo_pipe_label_associate_t(
2115 struct label
*pipelabel
2118 @brief Copy a pipe label
2119 @param src Source pipe label
2120 @param dest Destination pipe label
2122 Copy the pipe label associated with src to dest.
2123 XXXPIPE Describe when this is used: most likely during pipe creation to
2124 copy from rpipe to wpipe.
2126 typedef void mpo_pipe_label_copy_t(
2131 @brief Destroy pipe label
2132 @param label The label to be destroyed
2134 Destroy a pipe label. Since the object is going out of scope,
2135 policy modules should free any internal storage associated with the
2136 label so that it may be destroyed.
2138 typedef void mpo_pipe_label_destroy_t(
2142 @brief Externalize a pipe label
2143 @param label Label to be externalized
2144 @param element_name Name of the label namespace for which labels should be
2146 @param sb String buffer to be filled with a text representation of the label
2148 Produce an external representation of the label on a pipe.
2149 An externalized label consists of a text representation
2150 of the label contents that can be used with user applications.
2151 Policy-agnostic user space tools will display this externalized
2154 The policy's externalize entry points will be called only if the
2155 policy has registered interest in the label namespace.
2157 @return 0 on success, return non-zero if an error occurs while
2158 externalizing the label data.
2161 typedef int mpo_pipe_label_externalize_t(
2162 struct label
*label
,
2167 @brief Initialize pipe label
2168 @param label New label to initialize
2170 Initialize label storage for use with a newly instantiated pipe object.
2171 Sleeping is permitted.
2173 typedef void mpo_pipe_label_init_t(
2177 @brief Internalize a pipe label
2178 @param label Label to be internalized
2179 @param element_name Name of the label namespace for which the label should
2181 @param element_data Text data to be internalized
2183 Produce a pipe label from an external representation. An
2184 externalized label consists of a text representation of the label
2185 contents that can be used with user applications. Policy-agnostic
2186 user space tools will forward text version to the kernel for
2187 processing by individual policy modules.
2189 The policy's internalize entry points will be called only if the
2190 policy has registered interest in the label namespace.
2192 @return 0 on success, Otherwise, return non-zero if an error occurs
2193 while internalizing the label data.
2196 typedef int mpo_pipe_label_internalize_t(
2197 struct label
*label
,
2202 @brief Update a pipe label
2203 @param cred Subject credential
2204 @param cpipe Object to be labeled
2205 @param oldlabel Existing pipe label
2206 @param newlabel New label to replace existing label
2207 @see mpo_pipe_check_label_update_t
2209 The subject identified by the credential has previously requested
2210 and was authorized to relabel the pipe; this entry point allows
2211 policies to perform the actual relabel operation. Policies should
2212 update oldlabel using the label stored in the newlabel parameter.
2215 typedef void mpo_pipe_label_update_t(
2218 struct label
*oldlabel
,
2219 struct label
*newlabel
2222 @brief Policy unload event
2223 @param mpc MAC policy configuration
2225 This is the MAC Framework policy unload event. This entry point will
2226 only be called if the module's policy configuration allows unload (if
2227 the MPC_LOADTIME_FLAG_UNLOADOK is set). Most security policies won't
2228 want to be unloaded; they should set their flags to prevent this
2229 entry point from being called.
2231 @warning During this call, the mac policy list mutex is held, so
2232 sleep operations cannot be performed, and calls out to other kernel
2233 subsystems must be made with caution.
2235 @see MPC_LOADTIME_FLAG_UNLOADOK
2237 typedef void mpo_policy_destroy_t(
2238 struct mac_policy_conf
*mpc
2241 @brief Policy initialization event
2242 @param mpc MAC policy configuration
2243 @see mac_policy_register
2244 @see mpo_policy_initbsd_t
2246 This is the MAC Framework policy initialization event. This entry
2247 point is called during mac_policy_register, when the policy module
2248 is first registered with the MAC Framework. This is often done very
2249 early in the boot process, after the kernel Mach subsystem has been
2250 initialized, but prior to the BSD subsystem being initialized.
2251 Since the kernel BSD services are not yet available, it is possible
2252 that some initialization must occur later, possibly in the
2253 mpo_policy_initbsd_t policy entry point, such as registering BSD system
2254 controls (sysctls). Policy modules loaded at boot time will be
2255 registered and initialized before labeled Mach objects are created.
2257 @warning During this call, the mac policy list mutex is held, so
2258 sleep operations cannot be performed, and calls out to other kernel
2259 subsystems must be made with caution.
2261 typedef void mpo_policy_init_t(
2262 struct mac_policy_conf
*mpc
2265 @brief Policy BSD initialization event
2266 @param mpc MAC policy configuration
2267 @see mpo_policy_init_t
2269 This entry point is called after the kernel BSD subsystem has been
2270 initialized. By this point, the module should already be loaded,
2271 registered, and initialized. Since policy modules are initialized
2272 before kernel BSD services are available, this second initialization
2273 phase is necessary. At this point, BSD services (memory management,
2274 synchronization primitives, vfs, etc.) are available, but the first
2275 process has not yet been created. Mach-related objects and tasks
2276 will already be fully initialized and may be in use--policies requiring
2277 ubiquitous labeling may also want to implement mpo_policy_init_t.
2279 @warning During this call, the mac policy list mutex is held, so
2280 sleep operations cannot be performed, and calls out to other kernel
2281 subsystems must be made with caution.
2283 typedef void mpo_policy_initbsd_t(
2284 struct mac_policy_conf
*mpc
2287 @brief Policy extension service
2288 @param p Calling process
2289 @param call Policy-specific syscall number
2290 @param arg Pointer to syscall arguments
2292 This entry point provides a policy-multiplexed system call so that
2293 policies may provide additional services to user processes without
2294 registering specific system calls. The policy name provided during
2295 registration is used to demux calls from userland, and the arguments
2296 will be forwarded to this entry point. When implementing new
2297 services, security modules should be sure to invoke appropriate
2298 access control checks from the MAC framework as needed. For
2299 example, if a policy implements an augmented signal functionality,
2300 it should call the necessary signal access control checks to invoke
2301 the MAC framework and other registered policies.
2303 @warning Since the format and contents of the policy-specific
2304 arguments are unknown to the MAC Framework, modules must perform the
2305 required copyin() of the syscall data on their own. No policy
2306 mediation is performed, so policies must perform any necessary
2307 access control checks themselves. If multiple policies are loaded,
2308 they will currently be unable to mediate calls to other policies.
2310 @return In the event of an error, an appropriate value for errno
2311 should be returned, otherwise return 0 upon success.
2313 typedef int mpo_policy_syscall_t(
2319 @brief Access control check for copying a send right to another task
2320 @param task Label of the sender task
2321 @param port Label of the affected port
2323 Access control check for copying send rights to the port from the
2324 specified task. A complementary entry point, mpo_port_check_hold_send,
2325 handles the receiving task. port_check_copy_send is called as part of
2326 a group of policy invocations when messages with port rights are sent.
2327 All access control checks made for a particular message must be successful
2328 for the message to be sent.
2330 The task label and the port are locked. Sleeping is permitted.
2332 @return Return 0 if access is granted, non-zero otherwise.
2334 typedef int mpo_port_check_copy_send_t(
2339 @brief Access control check for obtaining a receive right
2340 @param task Label of the receiving task
2341 @param port Label of the affected port
2343 Access control check for a task obtaining receive rights to a
2344 port. Usually, these are port rights that were obtained with a call
2345 to mach_port_allocate. This entry point is called as part of a
2346 group of policy invocations when messages with port rights are
2347 received. All of these access control checks must succeed in order
2348 to receive the message.
2350 The task label and the port are locked. Sleeping is permitted.
2352 @return Return 0 if access is granted, non-zero otherwise.
2354 typedef int mpo_port_check_hold_receive_t(
2359 @brief Access control check for obtaining a send once right
2360 @param task Label of the receiving task
2361 @param port Label of the affected port
2363 Access control check for a task obtaining send once rights to a port. Usually,
2364 these are port rights that were part of a message sent by another userspace
2365 task. port_check_hold_send_once is called as part of a group of policy
2366 invocations when messages with port rights are received. All of these access
2367 control checks must succeed in order to receive the message.
2369 The task label and the port are locked. Sleeping is permitted.
2371 @return Return 0 if access is granted, non-zero otherwise.
2373 typedef int mpo_port_check_hold_send_once_t(
2378 @brief Access control check for obtaining a send right
2379 @param task Label of the receiving task
2380 @param port Label of the affected port
2382 Access control check for a task obtaining send rights to a port. Usually,
2383 these are port rights that were part of a message sent by another userspace
2384 task. port_check_hold_send is called as part of a group of policy
2385 invocations when messages with port rights are received. All of these access
2386 control checks must succeed in order to receive the message.
2388 The task label and the port are locked. Sleeping is permitted.
2390 @return Return 0 if access is granted, non-zero otherwise.
2392 typedef int mpo_port_check_hold_send_t(
2397 @brief Access control check for relabelling ports
2398 @param task Subject's task label
2399 @param oldlabel Original label of port
2400 @param newlabel New label for port
2402 Access control check for relabelling ports. The policy should
2403 indicate whether the subject is permitted to change the label
2404 of a port from oldlabel to newlabel. The port is locked, but
2405 the subject's task label is not locked.
2407 @warning XXX In future releases, the task label lock will likely
2410 @return Return 0 if access is granted, non-zero otherwise.
2412 typedef int mpo_port_check_label_update_t(
2414 struct label
*oldlabel
,
2415 struct label
*newlabel
2418 @brief Access control check for producing a send once right from a receive right
2419 @param task Label of the sender task
2420 @param port Label of the affected port
2422 Access control check for obtaining send once rights from receive rights.
2423 The new send once right may be destined for the calling task, or a different
2424 task. In either case the mpo_port_check_hold_send_once entry point handles
2425 the receiving task. port_check_make_send_once may be called as part of a
2426 group of policy invocations when messages with port rights are sent.
2427 All access control checks made for a particular message must be successful
2428 for the message to be sent.
2430 The task label and the port are locked. Sleeping is permitted.
2432 @return Return 0 if access is granted, non-zero otherwise.
2434 typedef int mpo_port_check_make_send_once_t(
2439 @brief Access control check for producing a send right from a receive right
2440 @param task Label of the sender task
2441 @param port Label of the affected port
2443 Access control check for obtaining send rights from receive rights. The new
2444 send right may be destined for the calling task, or a different task.
2445 In either case the mpo_port_check_hold_send entry point
2446 handles the receiving task. port_check_make_send may be called as part of
2447 a group of policy invocations when messages with port rights are sent.
2448 All access control checks made for a particular message must be successful
2449 for the message to be sent.
2451 The task label and the port are locked. Sleeping is permitted.
2453 @return Return 0 if access is granted, non-zero otherwise.
2455 typedef int mpo_port_check_make_send_t(
2460 @brief Compute access control check for a Mach message-based service
2461 @param proc Sender's process structure (may be NULL)
2462 @param task Sender's task label
2463 @param port Destination port label
2464 @param msgid Message id
2466 Access control computation for message-based services. This entry point
2467 computes permission to the service requested by the specified port and message
2468 id, for example a single MiG server routine, and is unrelated to the access
2469 check for sending messages to ports (but that check must succeed for the
2470 message to be sent to the destination). The result of this access computation
2471 is stored in the message trailer field msgh_ad (only if requested by the
2472 recipient); it does not actually inhibit the message from being sent or
2475 @return 0 for access granted, nonzero for access denied.
2478 typedef int mpo_port_check_method_t(
2485 @brief Access control check for transferring a receive right
2486 @param task Label of the sender task
2487 @param port Label of the affected port
2489 Access control check for transferring the receive right to a port out
2490 of the specified task. A complementary entry point,
2491 mpo_port_check_hold_receive, handles the receiving task.
2492 port_check_move_receive is called as part of
2493 a group of policy invocations when messages with port rights are sent.
2494 All access control checks made for a particular message must be successful
2495 for the message to be sent.
2497 The task label and the port are locked. Sleeping is permitted.
2499 @return Return 0 if access is granted, non-zero otherwise.
2501 typedef int mpo_port_check_move_receive_t(
2506 @brief Access control check for transferring a send once right
2507 @param task Label of the sender task
2508 @param port Label of the affected port
2510 Access control check for transferring a send once right from one task to
2511 the task listening to the specified port. A complementary entry point,
2512 mpo_port_check_hold_send_once, handles the receiving task.
2513 port_check_move_send_once is called as part of a group of policy invocations
2514 when messages with port rights are sent. All access control checks made
2515 for a particular message must be successful for the message to be sent.
2517 The task label and the port are locked. Sleeping is permitted.
2519 @return Return 0 if access is granted, non-zero otherwise.
2521 typedef int mpo_port_check_move_send_once_t(
2526 @brief Access control check for transferring a send right
2527 @param task Label of the sender task
2528 @param port Label of the affected port
2530 Access control check for transferring a send right from one task to the
2531 task listening to the specified port. A complementary entry point,
2532 mpo_port_check_hold_send, handles the receiving task.
2533 port_check_move_send is called as part of a group of policy invocations
2534 when messages with port rights are sent. All access control checks made
2535 for a particular message must be successful for the message to be sent.
2537 The task label and the port are locked. Sleeping is permitted.
2539 @return Return 0 if access is granted, non-zero otherwise.
2541 typedef int mpo_port_check_move_send_t(
2546 @brief Access control check for receiving Mach messsages
2547 @param task Label of the receiving task
2548 @param sender Label of the sending task
2550 Access control check for receiving messages. The two labels are locked.
2552 @warning This entry point can be invoked from many places inside the
2553 kernel, with arbitrary other locks held. The implementation of this
2554 entry point must not cause page faults, as those are handled by mach
2557 @return Return 0 if access is granted, non-zero otherwise.
2559 typedef int mpo_port_check_receive_t(
2561 struct label
*sender
2564 @brief Access control check for sending Mach messsages
2565 @param task Label of the sender task
2566 @param port Label of the destination port
2568 Access control check for sending messages. The task label and the
2571 @warning This entry point can be invoked from many places inside the
2572 kernel, with arbitrary other locks held. The implementation of this
2573 entry point must not cause page faults, as those are handled by mach
2576 @return Return 0 if access is granted, non-zero otherwise.
2578 typedef int mpo_port_check_send_t(
2583 @brief Generic access control check
2584 @param subj Caller-provided subject label
2585 @param obj Caller-provided object label
2586 @param serv Service or object class name
2587 @param perm Permission, or method, within the specified service
2589 This function provides a general way for a user process to query
2590 an arbitrary access control decision from the system's security policies.
2591 Currently, there are no standards for the format of the service and
2592 permission names. Labels may be either cred or port labels; the policy
2593 must accept either. The userspace interfaces to this entry point allow
2594 label strings or label handles (ports) to be provided.
2596 @return Return 0 if access is granted, non-zero otherwise.
2598 typedef int mpo_port_check_service_t(
2605 @brief Assign a label to a new Mach port created by the kernel
2606 @param portlabel Label for the new port
2607 @param isreply True if the port is for a reply message from the kernel
2609 Assign a label to a new port created by the kernel. If the port is being
2610 used to reply to a message, isreply is 1 (0 otherwise). The port is locked.
2612 typedef void mpo_port_label_associate_kernel_t(
2613 struct label
*portlabel
,
2617 @brief Assign a label to a new Mach port
2618 @param it Task label of issuer
2619 @param st Task label of target
2620 @param portlabel Label for the new port
2622 Assign a label to a new port. The policy can base this label on
2623 the label of the calling task, as well as the label of the target task.
2624 The target task is the one which recieves the first right for this port.
2625 Both task labels and the port are locked.
2627 typedef void mpo_port_label_associate_t(
2630 struct label
*portlabel
2633 @brief Request label for new (userspace) object
2634 @param subj Subject label
2635 @param obj Parent or existing object label
2636 @param serv Name of service
2637 @param out Computed label
2639 Ask the loaded policies to compute a label based on the two input labels
2640 and the service name. There is currently no standard for the service name,
2641 or even what the input labels represent (Subject and parent object are only
2642 a suggestion). If successful, the computed label is stored in out. All labels
2643 must be port (or task) labels. The userspace interfaces to this entry point
2644 allow label handles (ports) to be provided.
2646 @return 0 on success, or an errno value for failure.
2648 typedef int mpo_port_label_compute_t(
2655 @brief Copy a Mach port label
2656 @param src Source port label
2657 @param dest Destination port label
2659 Copy the Mach port label information from src to dest. This is used
2660 to copy user-suplied labels into an existing port.
2662 typedef void mpo_port_label_copy_t(
2667 @brief Destroy Mach port label
2668 @param label The label to be destroyed
2670 Destroy a Mach port label. Since the object is going out of
2671 scope, policy modules should free any internal storage associated
2672 with the label so that it may be destroyed.
2674 typedef void mpo_port_label_destroy_t(
2678 @brief Initialize Mach port label
2679 @param label New label to initialize
2681 Initialize the label for a newly instantiated Mach port. Sleeping
2684 typedef void mpo_port_label_init_t(
2688 @brief Update a Mach task port label
2689 @param cred User credential label to be used as the source
2690 @param task Mach port label to be used as the destination
2691 @see mpo_cred_label_update_t
2692 @see mpo_cred_label_update_execve_t
2694 Update the label on a Mach task port, using the supplied user
2695 credential label. When a mac_cred_label_update_execve or a mac_cred_label_update
2696 operation causes the label on a user credential to change, the Mach
2697 task port label also needs to be updated to reflect the change.
2698 Both labels are already valid (initialized and created).
2700 typedef void mpo_port_label_update_cred_t(
2705 @brief Assign a label to a Mach port connected to a kernel object
2706 @param portlabel Label for the port
2707 @param kotype Type of kernel object
2709 Label a kernel port based on the type of object behind it. The
2710 kotype parameter is one of the IKOT constants in
2711 <kern/ipc_kobject.h>. The port already has a valid label from either
2712 mpo_port_label_associate_kernel, or because it is a task port and has a label
2713 derived from the process and task labels. The port is locked.
2715 typedef void mpo_port_label_update_kobject_t(
2716 struct label
*portlabel
,
2720 @brief Access control check for POSIX semaphore create
2721 @param cred Subject credential
2722 @param name String name of the semaphore
2724 Determine whether the subject identified by the credential can create
2725 a POSIX semaphore specified by name.
2727 @return Return 0 if access is granted, otherwise an appropriate value for
2728 errno should be returned.
2730 typedef int mpo_posixsem_check_create_t(
2735 @brief Access control check for POSIX semaphore open
2736 @param cred Subject credential
2737 @param ps Pointer to semaphore information structure
2738 @param semlabel Label associated with the semaphore
2740 Determine whether the subject identified by the credential can open
2741 the named POSIX semaphore with label semlabel.
2743 @return Return 0 if access is granted, otherwise an appropriate value for
2744 errno should be returned.
2746 typedef int mpo_posixsem_check_open_t(
2748 struct pseminfo
*ps
,
2749 struct label
*semlabel
2752 @brief Access control check for POSIX semaphore post
2753 @param cred Subject credential
2754 @param ps Pointer to semaphore information structure
2755 @param semlabel Label associated with the semaphore
2757 Determine whether the subject identified by the credential can unlock
2758 the named POSIX semaphore with label semlabel.
2760 @return Return 0 if access is granted, otherwise an appropriate value for
2761 errno should be returned.
2763 typedef int mpo_posixsem_check_post_t(
2765 struct pseminfo
*ps
,
2766 struct label
*semlabel
2769 @brief Access control check for POSIX semaphore unlink
2770 @param cred Subject credential
2771 @param ps Pointer to semaphore information structure
2772 @param semlabel Label associated with the semaphore
2773 @param name String name of the semaphore
2775 Determine whether the subject identified by the credential can remove
2776 the named POSIX semaphore with label semlabel.
2778 @return Return 0 if access is granted, otherwise an appropriate value for
2779 errno should be returned.
2781 typedef int mpo_posixsem_check_unlink_t(
2783 struct pseminfo
*ps
,
2784 struct label
*semlabel
,
2788 @brief Access control check for POSIX semaphore wait
2789 @param cred Subject credential
2790 @param ps Pointer to semaphore information structure
2791 @param semlabel Label associated with the semaphore
2793 Determine whether the subject identified by the credential can lock
2794 the named POSIX semaphore with label semlabel.
2796 @return Return 0 if access is granted, otherwise an appropriate value for
2797 errno should be returned.
2799 typedef int mpo_posixsem_check_wait_t(
2801 struct pseminfo
*ps
,
2802 struct label
*semlabel
2805 @brief Create a POSIX semaphore label
2806 @param cred Subject credential
2807 @param ps Pointer to semaphore information structure
2808 @param semlabel Label to associate with the new semaphore
2809 @param name String name of the semaphore
2811 Label a new POSIX semaphore. The label was previously
2812 initialized and associated with the semaphore. At this time, an
2813 appropriate initial label value should be assigned to the object and
2814 stored in semalabel.
2816 typedef void mpo_posixsem_label_associate_t(
2818 struct pseminfo
*ps
,
2819 struct label
*semlabel
,
2823 @brief Destroy POSIX semaphore label
2824 @param label The label to be destroyed
2826 Destroy a POSIX semaphore label. Since the object is
2827 going out of scope, policy modules should free any internal storage
2828 associated with the label so that it may be destroyed.
2830 typedef void mpo_posixsem_label_destroy_t(
2834 @brief Initialize POSIX semaphore label
2835 @param label New label to initialize
2837 Initialize the label for a newly instantiated POSIX semaphore. Sleeping
2840 typedef void mpo_posixsem_label_init_t(
2844 @brief Access control check for POSIX shared memory region create
2845 @param cred Subject credential
2846 @param name String name of the shared memory region
2848 Determine whether the subject identified by the credential can create
2849 the POSIX shared memory region referenced by name.
2851 @return Return 0 if access is granted, otherwise an appropriate value for
2852 errno should be returned.
2854 typedef int mpo_posixshm_check_create_t(
2859 @brief Access control check for mapping POSIX shared memory
2860 @param cred Subject credential
2861 @param ps Pointer to shared memory information structure
2862 @param shmlabel Label associated with the shared memory region
2863 @param prot mmap protections; see mmap(2)
2864 @param flags shmat flags; see shmat(2)
2866 Determine whether the subject identified by the credential can map
2867 the POSIX shared memory segment associated with shmlabel.
2869 @return Return 0 if access is granted, otherwise an appropriate value for
2870 errno should be returned.
2872 typedef int mpo_posixshm_check_mmap_t(
2874 struct pshminfo
*ps
,
2875 struct label
*shmlabel
,
2880 @brief Access control check for POSIX shared memory region open
2881 @param cred Subject credential
2882 @param ps Pointer to shared memory information structure
2883 @param shmlabel Label associated with the shared memory region
2885 Determine whether the subject identified by the credential can open
2886 the POSIX shared memory region.
2888 @return Return 0 if access is granted, otherwise an appropriate value for
2889 errno should be returned.
2891 typedef int mpo_posixshm_check_open_t(
2893 struct pshminfo
*ps
,
2894 struct label
*shmlabel
2897 @brief Access control check for POSIX shared memory stat
2898 @param cred Subject credential
2899 @param ps Pointer to shared memory information structure
2900 @param shmlabel Label associated with the shared memory region
2902 Determine whether the subject identified by the credential can obtain
2903 status for the POSIX shared memory segment associated with shmlabel.
2905 @return Return 0 if access is granted, otherwise an appropriate value for
2906 errno should be returned.
2908 typedef int mpo_posixshm_check_stat_t(
2910 struct pshminfo
*ps
,
2911 struct label
*shmlabel
2914 @brief Access control check for POSIX shared memory truncate
2915 @param cred Subject credential
2916 @param ps Pointer to shared memory information structure
2917 @param shmlabel Label associated with the shared memory region
2918 @param len Length to truncate or extend shared memory segment
2920 Determine whether the subject identified by the credential can truncate
2921 or extend (to len) the POSIX shared memory segment associated with shmlabel.
2923 @return Return 0 if access is granted, otherwise an appropriate value for
2924 errno should be returned.
2926 typedef int mpo_posixshm_check_truncate_t(
2928 struct pshminfo
*ps
,
2929 struct label
*shmlabel
,
2933 @brief Access control check for POSIX shared memory unlink
2934 @param cred Subject credential
2935 @param ps Pointer to shared memory information structure
2936 @param shmlabel Label associated with the shared memory region
2937 @param name String name of the shared memory region
2939 Determine whether the subject identified by the credential can delete
2940 the POSIX shared memory segment associated with shmlabel.
2942 @return Return 0 if access is granted, otherwise an appropriate value for
2943 errno should be returned.
2945 typedef int mpo_posixshm_check_unlink_t(
2947 struct pshminfo
*ps
,
2948 struct label
*shmlabel
,
2952 @brief Create a POSIX shared memory region label
2953 @param cred Subject credential
2954 @param ps Pointer to shared memory information structure
2955 @param shmlabel Label to associate with the new shared memory region
2956 @param name String name of the shared memory region
2958 Label a new POSIX shared memory region. The label was previously
2959 initialized and associated with the shared memory region. At this
2960 time, an appropriate initial label value should be assigned to the
2961 object and stored in shmlabel.
2963 typedef void mpo_posixshm_label_associate_t(
2965 struct pshminfo
*ps
,
2966 struct label
*shmlabel
,
2970 @brief Destroy POSIX shared memory label
2971 @param label The label to be destroyed
2973 Destroy a POSIX shared memory region label. Since the
2974 object is going out of scope, policy modules should free any
2975 internal storage associated with the label so that it may be
2978 typedef void mpo_posixshm_label_destroy_t(
2982 @brief Initialize POSIX Shared Memory region label
2983 @param label New label to initialize
2985 Initialize the label for newly a instantiated POSIX Shared Memory
2986 region. Sleeping is permitted.
2988 typedef void mpo_posixshm_label_init_t(
2992 @brief Access control check for privileged operations
2993 @param cred Subject credential
2994 @param priv Requested privilege (see sys/priv.h)
2996 Determine whether the subject identified by the credential can perform
2997 a privileged operation. Privileged operations are allowed if the cred
2998 is the superuser or any policy returns zero for mpo_priv_grant, unless
2999 any policy returns nonzero for mpo_priv_check.
3001 @return Return 0 if access is granted, otherwise EPERM should be returned.
3003 typedef int mpo_priv_check_t(
3008 @brief Grant regular users the ability to perform privileged operations
3009 @param cred Subject credential
3010 @param priv Requested privilege (see sys/priv.h)
3012 Determine whether the subject identified by the credential should be
3013 allowed to perform a privileged operation that in the absense of any
3014 MAC policy it would not be able to perform. Privileged operations are
3015 allowed if the cred is the superuser or any policy returns zero for
3016 mpo_priv_grant, unless any policy returns nonzero for mpo_priv_check.
3018 Unlike other MAC hooks which can only reduce the privilege of a
3019 credential, this hook raises the privilege of a credential when it
3020 returns 0. Extreme care must be taken when implementing this hook to
3021 avoid undermining the security of the system.
3023 @return Return 0 if additional privilege is granted, otherwise EPERM
3026 typedef int mpo_priv_grant_t(
3031 @brief Access control check for debugging process
3032 @param cred Subject credential
3033 @param proc Object process
3035 Determine whether the subject identified by the credential can debug
3036 the passed process. This call may be made in a number of situations,
3037 including use of the ptrace(2) and ktrace(2) APIs, as well as for some
3038 types of procfs operations.
3040 @return Return 0 if access is granted, otherwise an appropriate value for
3041 errno should be returned. Suggested failure: EACCES for label mismatch,
3042 EPERM for lack of privilege, or ESRCH to hide visibility of the target.
3044 typedef int mpo_proc_check_debug_t(
3049 @brief Access control over fork
3050 @param cred Subject credential
3051 @param proc Subject process trying to fork
3053 Determine whether the subject identified is allowed to fork.
3055 @return Return 0 if access is granted, otherwise an appropriate value for
3056 errno should be returned.
3058 typedef int mpo_proc_check_fork_t(
3063 @brief Access control over pid_suspend and pid_resume
3064 @param cred Subject credential
3065 @param proc Subject process trying to run pid_suspend or pid_resume
3066 @param sr Call is suspend (0) or resume (1)
3068 Determine whether the subject identified is allowed to suspend or resume
3071 @return Return 0 if access is granted, otherwise an appropriate value for
3072 errno should be returned.
3074 typedef int mpo_proc_check_suspend_resume_t(
3080 @brief Access control check for retrieving audit information
3081 @param cred Subject credential
3083 Determine whether the subject identified by the credential can get
3084 audit information such as the audit user ID, the preselection mask,
3085 the terminal ID and the audit session ID, using the getaudit() system call.
3087 @return Return 0 if access is granted, otherwise an appropriate value for
3088 errno should be returned.
3090 typedef int mpo_proc_check_getaudit_t(
3094 @brief Access control check for retrieving audit user ID
3095 @param cred Subject credential
3097 Determine whether the subject identified by the credential can get
3098 the user identity being used by the auditing system, using the getauid()
3101 @return Return 0 if access is granted, otherwise an appropriate value for
3102 errno should be returned.
3104 typedef int mpo_proc_check_getauid_t(
3108 @brief Access control check for retrieving Login Context ID
3109 @param p0 Calling process
3110 @param p Effected process
3111 @param pid syscall PID argument
3113 Determine if getlcid(2) system call is permitted.
3115 Information returned by this system call is similar to that returned via
3116 process listings etc.
3118 @return Return 0 if access is granted, otherwise an appropriate value for
3119 errno should be returned.
3121 typedef int mpo_proc_check_getlcid_t(
3127 @brief Access control check for mmap MAP_ANON
3128 @param proc User process requesting the memory
3129 @param cred Subject credential
3130 @param u_addr Start address of the memory range
3131 @param u_size Length address of the memory range
3132 @param prot mmap protections; see mmap(2)
3133 @param flags Type of mapped object; see mmap(2)
3134 @param maxprot Maximum rights
3136 Determine whether the subject identified by the credential should be
3137 allowed to obtain anonymous memory using the specified flags and
3138 protections on the new mapping. MAP_ANON will always be present in the
3139 flags. Certain combinations of flags with a non-NULL addr may
3140 cause a mapping to be rejected before this hook is called. The maxprot field
3141 holds the maximum permissions on the new mapping, a combination of
3142 VM_PROT_READ, VM_PROT_WRITE and VM_PROT_EXECUTE. To avoid overriding prior
3143 access control checks, a policy should only remove flags from maxprot.
3145 @return Return 0 if access is granted, otherwise an appropriate value for
3146 errno should be returned. Suggested failure: EPERM for lack of privilege.
3148 typedef int mpo_proc_check_map_anon_t(
3158 @brief Access control check for setting memory protections
3159 @param cred Subject credential
3160 @param proc User process requesting the change
3161 @param addr Start address of the memory range
3162 @param size Length address of the memory range
3163 @param prot Memory protections, see mmap(2)
3165 Determine whether the subject identified by the credential should
3166 be allowed to set the specified memory protections on memory mapped
3167 in the process proc.
3169 @return Return 0 if access is granted, otherwise an appropriate value for
3170 errno should be returned.
3172 typedef int mpo_proc_check_mprotect_t(
3180 @brief Access control check for changing scheduling parameters
3181 @param cred Subject credential
3182 @param proc Object process
3184 Determine whether the subject identified by the credential can change
3185 the scheduling parameters of the passed process.
3187 @return Return 0 if access is granted, otherwise an appropriate value for
3188 errno should be returned. Suggested failure: EACCES for label mismatch,
3189 EPERM for lack of privilege, or ESRCH to limit visibility.
3191 typedef int mpo_proc_check_sched_t(
3196 @brief Access control check for setting audit information
3197 @param cred Subject credential
3198 @param ai Audit information
3200 Determine whether the subject identified by the credential can set
3201 audit information such as the the preselection mask, the terminal ID
3202 and the audit session ID, using the setaudit() system call.
3204 @return Return 0 if access is granted, otherwise an appropriate value for
3205 errno should be returned.
3207 typedef int mpo_proc_check_setaudit_t(
3209 struct auditinfo_addr
*ai
3212 @brief Access control check for setting audit user ID
3213 @param cred Subject credential
3214 @param auid Audit user ID
3216 Determine whether the subject identified by the credential can set
3217 the user identity used by the auditing system, using the setauid()
3220 @return Return 0 if access is granted, otherwise an appropriate value for
3221 errno should be returned.
3223 typedef int mpo_proc_check_setauid_t(
3228 @brief Access control check for setting the Login Context
3229 @param p0 Calling process
3230 @param p Effected process
3231 @param pid syscall PID argument
3232 @param lcid syscall LCID argument
3234 Determine if setlcid(2) system call is permitted.
3236 See xnu/bsd/kern/kern_prot.c:setlcid() implementation for example of
3237 decoding syscall arguments to determine action desired by caller.
3239 Five distinct actions are possible: CREATE JOIN LEAVE ADOPT ORPHAN
3241 @return Return 0 if access is granted, otherwise an appropriate value for
3242 errno should be returned.
3244 typedef int mpo_proc_check_setlcid_t(
3251 @brief Access control check for delivering signal
3252 @param cred Subject credential
3253 @param proc Object process
3254 @param signum Signal number; see kill(2)
3256 Determine whether the subject identified by the credential can deliver
3257 the passed signal to the passed process.
3259 @warning Programs typically expect to be able to send and receive
3260 signals as part or their normal process lifecycle; caution should be
3261 exercised when implementing access controls over signal events.
3263 @return Return 0 if access is granted, otherwise an appropriate value for
3264 errno should be returned. Suggested failure: EACCES for label mismatch,
3265 EPERM for lack of privilege, or ESRCH to limit visibility.
3267 typedef int mpo_proc_check_signal_t(
3273 @brief Access control check for wait
3274 @param cred Subject credential
3275 @param proc Object process
3277 Determine whether the subject identified by the credential can wait
3278 for process termination.
3280 @warning Caution should be exercised when implementing access
3281 controls for wait, since programs often wait for child processes to
3282 exit. Failure to be notified of a child process terminating may
3283 cause the parent process to hang, or may produce zombie processes.
3285 @return Return 0 if access is granted, otherwise an appropriate value for
3286 errno should be returned.
3288 typedef int mpo_proc_check_wait_t(
3293 @brief Destroy process label
3294 @param label The label to be destroyed
3296 Destroy a process label. Since the object is going
3297 out of scope, policy modules should free any internal storage
3298 associated with the label so that it may be destroyed.
3300 typedef void mpo_proc_label_destroy_t(
3304 @brief Initialize process label
3305 @param label New label to initialize
3306 @see mpo_cred_label_init_t
3308 Initialize the label for a newly instantiated BSD process structure.
3309 Normally, security policies will store the process label in the user
3310 credential rather than here in the process structure. However,
3311 there are some floating label policies that may need to temporarily
3312 store a label in the process structure until it is safe to update
3313 the user credential label. Sleeping is permitted.
3315 typedef void mpo_proc_label_init_t(
3319 @brief Access control check for socket accept
3320 @param cred Subject credential
3321 @param socket Object socket
3322 @param socklabel Policy label for socket
3324 Determine whether the subject identified by the credential can accept()
3325 a new connection on the socket from the host specified by addr.
3327 @return Return 0 if access if granted, otherwise an appropriate
3328 value for errno should be returned.
3330 typedef int mpo_socket_check_accept_t(
3333 struct label
*socklabel
3336 @brief Access control check for a pending socket accept
3337 @param cred Subject credential
3338 @param so Object socket
3339 @param socklabel Policy label for socket
3340 @param addr Address of the listening socket (coming soon)
3342 Determine whether the subject identified by the credential can accept()
3343 a pending connection on the socket from the host specified by addr.
3345 @return Return 0 if access if granted, otherwise an appropriate
3346 value for errno should be returned.
3348 typedef int mpo_socket_check_accepted_t(
3351 struct label
*socklabel
,
3352 struct sockaddr
*addr
3355 @brief Access control check for socket bind
3356 @param cred Subject credential
3357 @param so Object socket
3358 @param socklabel Policy label for socket
3359 @param addr Name to assign to the socket
3361 Determine whether the subject identified by the credential can bind()
3362 the name (addr) to the socket.
3364 @return Return 0 if access if granted, otherwise an appropriate
3365 value for errno should be returned.
3367 typedef int mpo_socket_check_bind_t(
3370 struct label
*socklabel
,
3371 struct sockaddr
*addr
3374 @brief Access control check for socket connect
3375 @param cred Subject credential
3376 @param so Object socket
3377 @param socklabel Policy label for socket
3378 @param addr Name to assign to the socket
3380 Determine whether the subject identified by the credential can
3381 connect() the passed socket to the remote host specified by addr.
3383 @return Return 0 if access if granted, otherwise an appropriate
3384 value for errno should be returned.
3386 typedef int mpo_socket_check_connect_t(
3389 struct label
*socklabel
,
3390 struct sockaddr
*addr
3393 @brief Access control check for socket() system call.
3394 @param cred Subject credential
3395 @param domain communication domain
3396 @param type socket type
3397 @param protocol socket protocol
3399 Determine whether the subject identified by the credential can
3400 make the socket() call.
3402 @return Return 0 if access if granted, otherwise an appropriate
3403 value for errno should be returned.
3405 typedef int mpo_socket_check_create_t(
3412 @brief Access control check for delivering data to a user's receieve queue
3413 @param so The socket data is being delivered to
3414 @param so_label The label of so
3415 @param m The mbuf whose data will be deposited into the receive queue
3416 @param m_label The label of the sender of the data.
3418 A socket has a queue for receiving incoming data. When a packet arrives
3419 on the wire, it eventually gets deposited into this queue, which the
3420 owner of the socket drains when they read from the socket's file descriptor.
3422 This function determines whether the socket can receive data from
3423 the sender specified by m_label.
3425 @warning There is an outstanding design issue surrounding the placement
3426 of this function. The check must be placed either before or after the
3427 TCP sequence and ACK counters are updated. Placing the check before
3428 the counters are updated causes the incoming packet to be resent by
3429 the remote if the check rejects it. Placing the check after the counters
3430 are updated results in a completely silent drop. As far as each TCP stack
3431 is concerned the packet was received, however, the data will not be in the
3432 socket's receive queue. Another consideration is that the current design
3433 requires using the "failed label" occasionally. In that case, on rejection,
3434 we want the remote TCP to resend the data. Because of this, we chose to
3435 place this check before the counters are updated, so rejected packets will be
3436 resent by the remote host.
3438 If a policy keeps rejecting the same packet, eventually the connection will
3439 be dropped. Policies have several options if this design causes problems.
3440 For example, one options is to sanitize the mbuf such that it is acceptable,
3441 then accept it. That may require negotiation between policies as the
3442 Framework will not know to re-check the packet.
3444 The policy must handle NULL MBUF labels. This will likely be the case
3445 for non-local TCP sockets for example.
3447 @return Return 0 if access if granted, otherwise an appropriate
3448 value for errno should be returned.
3450 typedef int mpo_socket_check_deliver_t(
3452 struct label
*so_label
,
3454 struct label
*m_label
3457 @brief Access control check for socket kqfilter
3458 @param cred Subject credential
3459 @param kn Object knote
3460 @param so Object socket
3461 @param socklabel Policy label for socket
3463 Determine whether the subject identified by the credential can
3464 receive the knote on the passed socket.
3466 @return Return 0 if access if granted, otherwise an appropriate
3467 value for errno should be returned.
3469 typedef int mpo_socket_check_kqfilter_t(
3473 struct label
*socklabel
3476 @brief Access control check for socket relabel
3477 @param cred Subject credential
3478 @param so Object socket
3479 @param so_label The current label of so
3480 @param newlabel The label to be assigned to so
3482 Determine whether the subject identified by the credential can
3483 change the label on the socket.
3485 @return Return 0 if access if granted, otherwise an appropriate
3486 value for errno should be returned.
3488 typedef int mpo_socket_check_label_update_t(
3491 struct label
*so_label
,
3492 struct label
*newlabel
3495 @brief Access control check for socket listen
3496 @param cred Subject credential
3497 @param so Object socket
3498 @param socklabel Policy label for socket
3500 Determine whether the subject identified by the credential can
3501 listen() on the passed socket.
3503 @return Return 0 if access if granted, otherwise an appropriate
3504 value for errno should be returned.
3506 typedef int mpo_socket_check_listen_t(
3509 struct label
*socklabel
3512 @brief Access control check for socket receive
3513 @param cred Subject credential
3514 @param so Object socket
3515 @param socklabel Policy label for socket
3517 Determine whether the subject identified by the credential can
3518 receive data from the socket.
3520 @return Return 0 if access if granted, otherwise an appropriate
3521 value for errno should be returned.
3523 typedef int mpo_socket_check_receive_t(
3526 struct label
*socklabel
3530 @brief Access control check for socket receive
3531 @param cred Subject credential
3532 @param socket Object socket
3533 @param socklabel Policy label for socket
3534 @param addr Name of the remote socket
3536 Determine whether the subject identified by the credential can
3537 receive data from the remote host specified by addr.
3539 @return Return 0 if access if granted, otherwise an appropriate
3540 value for errno should be returned.
3542 typedef int mpo_socket_check_received_t(
3544 struct socket
*sock
,
3545 struct label
*socklabel
,
3546 struct sockaddr
*saddr
3551 @brief Access control check for socket select
3552 @param cred Subject credential
3553 @param so Object socket
3554 @param socklabel Policy label for socket
3555 @param which The operation selected on: FREAD or FWRITE
3557 Determine whether the subject identified by the credential can use the
3558 socket in a call to select().
3560 @return Return 0 if access if granted, otherwise an appropriate
3561 value for errno should be returned.
3563 typedef int mpo_socket_check_select_t(
3566 struct label
*socklabel
,
3570 @brief Access control check for socket send
3571 @param cred Subject credential
3572 @param so Object socket
3573 @param socklabel Policy label for socket
3574 @param addr Address being sent to
3576 Determine whether the subject identified by the credential can send
3579 @return Return 0 if access if granted, otherwise an appropriate
3580 value for errno should be returned.
3582 typedef int mpo_socket_check_send_t(
3585 struct label
*socklabel
,
3586 struct sockaddr
*addr
3589 @brief Access control check for retrieving socket status
3590 @param cred Subject credential
3591 @param so Object socket
3592 @param socklabel Policy label for so
3594 Determine whether the subject identified by the credential can
3595 execute the stat() system call on the given socket.
3597 @return Return 0 if access if granted, otherwise an appropriate
3598 value for errno should be returned.
3600 typedef int mpo_socket_check_stat_t(
3603 struct label
*socklabel
3606 @brief Access control check for setting socket options
3607 @param cred Subject credential
3608 @param so Object socket
3609 @param socklabel Policy label for so
3610 @param sopt The options being set
3612 Determine whether the subject identified by the credential can
3613 execute the setsockopt system call on the given socket.
3615 @return Return 0 if access if granted, otherwise an appropriate
3616 value for errno should be returned.
3618 typedef int mpo_socket_check_setsockopt_t(
3621 struct label
*socklabel
,
3622 struct sockopt
*sopt
3625 @brief Access control check for getting socket options
3626 @param cred Subject credential
3627 @param so Object socket
3628 @param socklabel Policy label for so
3629 @param sopt The options to get
3631 Determine whether the subject identified by the credential can
3632 execute the getsockopt system call on the given socket.
3634 @return Return 0 if access if granted, otherwise an appropriate
3635 value for errno should be returned.
3637 typedef int mpo_socket_check_getsockopt_t(
3640 struct label
*socklabel
,
3641 struct sockopt
*sopt
3644 @brief Label a socket
3645 @param oldsock Listening socket
3646 @param oldlabel Policy label associated with oldsock
3647 @param newsock New socket
3648 @param newlabel Policy label associated with newsock
3650 A new socket is created when a connection is accept(2)ed. This
3651 function labels the new socket based on the existing listen(2)ing
3654 typedef void mpo_socket_label_associate_accept_t(
3656 struct label
*oldlabel
,
3658 struct label
*newlabel
3661 @brief Assign a label to a new socket
3662 @param cred Credential of the owning process
3663 @param so The socket being labeled
3664 @param solabel The label
3665 @warning cred can be NULL
3667 Set the label on a newly created socket from the passed subject
3668 credential. This call is made when a socket is created. The
3669 credentials may be null if the socket is being created by the
3672 typedef void mpo_socket_label_associate_t(
3675 struct label
*solabel
3678 @brief Copy a socket label
3679 @param src Source label
3680 @param dest Destination label
3682 Copy the socket label information in src into dest.
3684 typedef void mpo_socket_label_copy_t(
3689 @brief Destroy socket label
3690 @param label The label to be destroyed
3692 Destroy a socket label. Since the object is going out of
3693 scope, policy modules should free any internal storage associated
3694 with the label so that it may be destroyed.
3696 typedef void mpo_socket_label_destroy_t(
3700 @brief Externalize a socket label
3701 @param label Label to be externalized
3702 @param element_name Name of the label namespace for which labels should be
3704 @param sb String buffer to be filled with a text representation of label
3706 Produce an externalized socket label based on the label structure passed.
3707 An externalized label consists of a text representation of the label
3708 contents that can be used with userland applications and read by the
3709 user. If element_name does not match a namespace managed by the policy,
3710 simply return 0. Only return nonzero if an error occurs while externalizing
3713 @return In the event of an error, an appropriate value for errno
3714 should be returned, otherwise return 0 upon success.
3716 typedef int mpo_socket_label_externalize_t(
3717 struct label
*label
,
3722 @brief Initialize socket label
3723 @param label New label to initialize
3724 @param waitok Malloc flags
3726 Initialize the label of a newly instantiated socket. The waitok
3727 field may be one of M_WAITOK and M_NOWAIT, and should be employed to
3728 avoid performing a sleeping malloc(9) during this initialization
3729 call. It it not always safe to sleep during this entry point.
3731 @warning Since it is possible for the waitok flags to be set to
3732 M_NOWAIT, the malloc operation may fail.
3734 @return In the event of an error, an appropriate value for errno
3735 should be returned, otherwise return 0 upon success.
3737 typedef int mpo_socket_label_init_t(
3738 struct label
*label
,
3742 @brief Internalize a socket label
3743 @param label Label to be filled in
3744 @param element_name Name of the label namespace for which the label should
3746 @param element_data Text data to be internalized
3748 Produce an internal socket label structure based on externalized label
3749 data in text format.
3751 The policy's internalize entry points will be called only if the
3752 policy has registered interest in the label namespace.
3754 @return In the event of an error, an appropriate value for errno
3755 should be returned, otherwise return 0 upon success.
3757 typedef int mpo_socket_label_internalize_t(
3758 struct label
*label
,
3763 @brief Relabel socket
3764 @param cred Subject credential
3765 @param so Object; socket
3766 @param so_label Current label of the socket
3767 @param newlabel The label to be assigned to so
3769 The subject identified by the credential has previously requested
3770 and was authorized to relabel the socket; this entry point allows
3771 policies to perform the actual label update operation.
3773 @warning XXX This entry point will likely change in future versions.
3775 typedef void mpo_socket_label_update_t(
3778 struct label
*so_label
,
3779 struct label
*newlabel
3782 @brief Set the peer label on a socket from mbuf
3783 @param m Mbuf chain received on socket so
3784 @param m_label Label for m
3785 @param so Current label for the socket
3786 @param so_label Policy label to be filled out for the socket
3788 Set the peer label of a socket based on the label of the sender of the
3791 This is called for every TCP/IP packet received. The first call for a given
3792 socket operates on a newly initialized label, and subsequent calls operate
3793 on existing label data.
3795 @warning Because this can affect performance significantly, it has
3796 different sematics than other 'set' operations. Typically, 'set' operations
3797 operate on newly initialzed labels and policies do not need to worry about
3798 clobbering existing values. In this case, it is too inefficient to
3799 initialize and destroy a label every time data is received for the socket.
3800 Instead, it is up to the policies to determine how to replace the label data.
3801 Most policies should be able to replace the data inline.
3803 typedef void mpo_socketpeer_label_associate_mbuf_t(
3805 struct label
*m_label
,
3807 struct label
*so_label
3810 @brief Set the peer label on a socket from socket
3811 @param source Local socket
3812 @param sourcelabel Policy label for source
3813 @param target Peer socket
3814 @param targetlabel Policy label to fill in for target
3816 Set the peer label on a stream UNIX domain socket from the passed
3817 remote socket endpoint. This call will be made when the socket pair
3818 is connected, and will be made for both endpoints.
3820 Note that this call is only made on connection; it is currently not updated
3821 during communication.
3823 typedef void mpo_socketpeer_label_associate_socket_t(
3825 struct label
*sourcelabel
,
3827 struct label
*targetlabel
3830 @brief Destroy socket peer label
3831 @param label The peer label to be destroyed
3833 Destroy a socket peer label. Since the object is going out of
3834 scope, policy modules should free any internal storage associated
3835 with the label so that it may be destroyed.
3837 typedef void mpo_socketpeer_label_destroy_t(
3841 @brief Externalize a socket peer label
3842 @param label Label to be externalized
3843 @param element_name Name of the label namespace for which labels should be
3845 @param sb String buffer to be filled with a text representation of label
3847 Produce an externalized socket peer label based on the label structure
3848 passed. An externalized label consists of a text representation of the
3849 label contents that can be used with userland applications and read by the
3850 user. If element_name does not match a namespace managed by the policy,
3851 simply return 0. Only return nonzero if an error occurs while externalizing
3854 @return In the event of an error, an appropriate value for errno
3855 should be returned, otherwise return 0 upon success.
3857 typedef int mpo_socketpeer_label_externalize_t(
3858 struct label
*label
,
3863 @brief Initialize socket peer label
3864 @param label New label to initialize
3865 @param waitok Malloc flags
3867 Initialize the peer label of a newly instantiated socket. The
3868 waitok field may be one of M_WAITOK and M_NOWAIT, and should be
3869 employed to avoid performing a sleeping malloc(9) during this
3870 initialization call. It it not always safe to sleep during this
3873 @warning Since it is possible for the waitok flags to be set to
3874 M_NOWAIT, the malloc operation may fail.
3876 @return In the event of an error, an appropriate value for errno
3877 should be returned, otherwise return 0 upon success.
3879 typedef int mpo_socketpeer_label_init_t(
3880 struct label
*label
,
3884 @brief Access control check for enabling accounting
3885 @param cred Subject credential
3886 @param vp Accounting file
3887 @param vlabel Label associated with vp
3889 Determine whether the subject should be allowed to enable accounting,
3890 based on its label and the label of the accounting log file. See
3891 acct(5) for more information.
3893 As accounting is disabled by passing NULL to the acct(2) system call,
3894 the policy should be prepared for both 'vp' and 'vlabel' to be NULL.
3896 @return Return 0 if access is granted, otherwise an appropriate value for
3897 errno should be returned.
3899 typedef int mpo_system_check_acct_t(
3902 struct label
*vlabel
3905 @brief Access control check for audit
3906 @param cred Subject credential
3907 @param record Audit record
3908 @param length Audit record length
3910 Determine whether the subject identified by the credential can submit
3911 an audit record for inclusion in the audit log via the audit() system call.
3913 @return Return 0 if access is granted, otherwise an appropriate value for
3914 errno should be returned.
3916 typedef int mpo_system_check_audit_t(
3922 @brief Access control check for controlling audit
3923 @param cred Subject credential
3924 @param vp Audit file
3925 @param vl Label associated with vp
3927 Determine whether the subject should be allowed to enable auditing using
3928 the auditctl() system call, based on its label and the label of the proposed
3931 @return Return 0 if access is granted, otherwise an appropriate value for
3932 errno should be returned.
3934 typedef int mpo_system_check_auditctl_t(
3940 @brief Access control check for manipulating auditing
3941 @param cred Subject credential
3942 @param cmd Audit control command
3944 Determine whether the subject identified by the credential can perform
3945 the audit subsystem control operation cmd via the auditon() system call.
3947 @return Return 0 if access is granted, otherwise an appropriate value for
3948 errno should be returned.
3950 typedef int mpo_system_check_auditon_t(
3955 @brief Access control check for using CHUD facilities
3956 @param cred Subject credential
3958 Determine whether the subject identified by the credential can perform
3959 performance-related tasks using the CHUD system call.
3961 @return Return 0 if access is granted, otherwise an appropriate value for
3962 errno should be returned.
3964 typedef int mpo_system_check_chud_t(
3968 @brief Access control check for obtaining the host control port
3969 @param cred Subject credential
3971 Determine whether the subject identified by the credential can
3972 obtain the host control port.
3974 @return Return 0 if access is granted, or non-zero otherwise.
3976 typedef int mpo_system_check_host_priv_t(
3980 @brief Access control check for calling NFS services
3981 @param cred Subject credential
3983 Determine whether the subject identified by the credential should be
3984 allowed to call nfssrv(2).
3986 @return Return 0 if access is granted, otherwise an appropriate value for
3987 errno should be returned.
3989 typedef int mpo_system_check_nfsd_t(
3993 @brief Access control check for reboot
3994 @param cred Subject credential
3995 @param howto howto parameter from reboot(2)
3997 Determine whether the subject identified by the credential should be
3998 allowed to reboot the system in the specified manner.
4000 @return Return 0 if access is granted, otherwise an appropriate value for
4001 errno should be returned.
4003 typedef int mpo_system_check_reboot_t(
4008 @brief Access control check for setting system clock
4009 @param cred Subject credential
4011 Determine whether the subject identified by the credential should be
4012 allowed to set the system clock.
4014 @return Return 0 if access is granted, otherwise an appropriate value for
4015 errno should be returned.
4017 typedef int mpo_system_check_settime_t(
4021 @brief Access control check for removing swap devices
4022 @param cred Subject credential
4023 @param vp Swap device
4024 @param label Label associated with vp
4026 Determine whether the subject identified by the credential should be
4027 allowed to remove vp as a swap device.
4029 @return Return 0 if access is granted, otherwise an appropriate value for
4030 errno should be returned.
4032 typedef int mpo_system_check_swapoff_t(
4038 @brief Access control check for adding swap devices
4039 @param cred Subject credential
4040 @param vp Swap device
4041 @param label Label associated with vp
4043 Determine whether the subject identified by the credential should be
4044 allowed to add vp as a swap device.
4046 @return Return 0 if access is granted, otherwise an appropriate value for
4047 errno should be returned.
4049 typedef int mpo_system_check_swapon_t(
4055 @brief Access control check for sysctl
4056 @param cred Subject credential
4057 @param name Integer name; see sysctl(3)
4058 @param namelen Length of name array of integers; see sysctl(3)
4059 @param old 0 or address where to store old value; see sysctl(3)
4060 @param oldlenp Pointer to length of old buffer; see sysctl(3)
4061 @param inkernel Boolean; 1 if called from kernel
4062 @param newvalue 0 or address of new value; see sysctl(3)
4063 @param newlen Length of new buffer; see sysctl(3)
4065 Determine whether the subject identified by the credential should be
4066 allowed to make the specified sysctl(3) transaction.
4068 The sysctl(3) call specifies that if the old value is not desired,
4069 oldp and oldlenp should be set to NULL. Likewise, if a new value is
4070 not to be set, newp should be set to NULL and newlen set to 0.
4072 @return Return 0 if access is granted, otherwise an appropriate value for
4073 errno should be returned.
4075 typedef int mpo_system_check_sysctl_t(
4079 user_addr_t old
, /* NULLOK */
4080 user_addr_t oldlenp
, /* NULLOK */
4082 user_addr_t newvalue
, /* NULLOK */
4086 @brief Create a System V message label
4087 @param cred Subject credential
4088 @param msqkptr The message queue the message will be placed in
4089 @param msqlabel The label of the message queue
4090 @param msgptr The message
4091 @param msglabel The label of the message
4093 Label the message as its placed in the message queue.
4095 typedef void mpo_sysvmsg_label_associate_t(
4097 struct msqid_kernel
*msqptr
,
4098 struct label
*msqlabel
,
4100 struct label
*msglabel
4103 @brief Destroy System V message label
4104 @param label The label to be destroyed
4106 Destroy a System V message label. Since the object is
4107 going out of scope, policy modules should free any internal storage
4108 associated with the label so that it may be destroyed.
4110 typedef void mpo_sysvmsg_label_destroy_t(
4114 @brief Initialize System V message label
4115 @param label New label to initialize
4117 Initialize the label for a newly instantiated System V message.
4119 typedef void mpo_sysvmsg_label_init_t(
4123 @brief Clean up a System V message label
4124 @param label The label to be destroyed
4126 Clean up a System V message label. Darwin pre-allocates
4127 messages at system boot time and re-uses them rather than
4128 allocating new ones. Before messages are returned to the "free
4129 pool", policies can cleanup or overwrite any information present in
4132 typedef void mpo_sysvmsg_label_recycle_t(
4136 @brief Access control check for System V message enqueuing
4137 @param cred Subject credential
4138 @param msgptr The message
4139 @param msglabel The message's label
4140 @param msqkptr The message queue
4141 @param msqlabel The message queue's label
4143 Determine whether the subject identified by the credential can add the
4144 given message to the given message queue.
4146 @return Return 0 if access is granted, otherwise an appropriate value for
4147 errno should be returned.
4149 typedef int mpo_sysvmsq_check_enqueue_t(
4152 struct label
*msglabel
,
4153 struct msqid_kernel
*msqptr
,
4154 struct label
*msqlabel
4157 @brief Access control check for System V message reception
4158 @param cred The credential of the intended recipient
4159 @param msgptr The message
4160 @param msglabel The message's label
4162 Determine whether the subject identified by the credential can receive
4165 @return Return 0 if access is granted, otherwise an appropriate value for
4166 errno should be returned.
4168 typedef int mpo_sysvmsq_check_msgrcv_t(
4171 struct label
*msglabel
4174 @brief Access control check for System V message queue removal
4175 @param cred The credential of the caller
4176 @param msgptr The message
4177 @param msglabel The message's label
4179 System V message queues are removed using the msgctl() system call.
4180 The system will iterate over each messsage in the queue, calling this
4181 function for each, to determine whether the caller has the appropriate
4184 @return Return 0 if access is granted, otherwise an appropriate value for
4185 errno should be returned.
4187 typedef int mpo_sysvmsq_check_msgrmid_t(
4190 struct label
*msglabel
4193 @brief Access control check for msgctl()
4194 @param cred The credential of the caller
4195 @param msqptr The message queue
4196 @param msqlabel The message queue's label
4198 This access check is performed to validate calls to msgctl().
4200 @return Return 0 if access is granted, otherwise an appropriate value for
4201 errno should be returned.
4203 typedef int mpo_sysvmsq_check_msqctl_t(
4205 struct msqid_kernel
*msqptr
,
4206 struct label
*msqlabel
,
4210 @brief Access control check to get a System V message queue
4211 @param cred The credential of the caller
4212 @param msqptr The message queue requested
4213 @param msqlabel The message queue's label
4215 On a call to msgget(), if the queue requested already exists,
4216 and it is a public queue, this check will be performed before the
4217 queue's ID is returned to the user.
4219 @return Return 0 if access is granted, otherwise an appropriate value for
4220 errno should be returned.
4222 typedef int mpo_sysvmsq_check_msqget_t(
4224 struct msqid_kernel
*msqptr
,
4225 struct label
*msqlabel
4228 @brief Access control check to receive a System V message from the given queue
4229 @param cred The credential of the caller
4230 @param msqptr The message queue to receive from
4231 @param msqlabel The message queue's label
4233 On a call to msgrcv(), this check is performed to determine whether the
4234 caller has receive rights on the given queue.
4236 @return Return 0 if access is granted, otherwise an appropriate value for
4237 errno should be returned.
4239 typedef int mpo_sysvmsq_check_msqrcv_t(
4241 struct msqid_kernel
*msqptr
,
4242 struct label
*msqlabel
4245 @brief Access control check to send a System V message to the given queue
4246 @param cred The credential of the caller
4247 @param msqptr The message queue to send to
4248 @param msqlabel The message queue's label
4250 On a call to msgsnd(), this check is performed to determine whether the
4251 caller has send rights on the given queue.
4253 @return Return 0 if access is granted, otherwise an appropriate value for
4254 errno should be returned.
4256 typedef int mpo_sysvmsq_check_msqsnd_t(
4258 struct msqid_kernel
*msqptr
,
4259 struct label
*msqlabel
4262 @brief Create a System V message queue label
4263 @param cred Subject credential
4264 @param msqkptr The message queue
4265 @param msqlabel The label of the message queue
4268 typedef void mpo_sysvmsq_label_associate_t(
4270 struct msqid_kernel
*msqptr
,
4271 struct label
*msqlabel
4274 @brief Destroy System V message queue label
4275 @param label The label to be destroyed
4277 Destroy a System V message queue label. Since the object is
4278 going out of scope, policy modules should free any internal storage
4279 associated with the label so that it may be destroyed.
4281 typedef void mpo_sysvmsq_label_destroy_t(
4285 @brief Initialize System V message queue label
4286 @param label New label to initialize
4288 Initialize the label for a newly instantiated System V message queue.
4290 typedef void mpo_sysvmsq_label_init_t(
4294 @brief Clean up a System V message queue label
4295 @param label The label to be destroyed
4297 Clean up a System V message queue label. Darwin pre-allocates
4298 message queues at system boot time and re-uses them rather than
4299 allocating new ones. Before message queues are returned to the "free
4300 pool", policies can cleanup or overwrite any information present in
4303 typedef void mpo_sysvmsq_label_recycle_t(
4307 @brief Access control check for System V semaphore control operation
4308 @param cred Subject credential
4309 @param semakptr Pointer to semaphore identifier
4310 @param semaklabel Label associated with semaphore
4311 @param cmd Control operation to be performed; see semctl(2)
4313 Determine whether the subject identified by the credential can perform
4314 the operation indicated by cmd on the System V semaphore semakptr.
4316 @return Return 0 if access is granted, otherwise an appropriate value for
4317 errno should be returned.
4319 typedef int mpo_sysvsem_check_semctl_t(
4321 struct semid_kernel
*semakptr
,
4322 struct label
*semaklabel
,
4326 @brief Access control check for obtaining a System V semaphore
4327 @param cred Subject credential
4328 @param semakptr Pointer to semaphore identifier
4329 @param semaklabel Label to associate with the semaphore
4331 Determine whether the subject identified by the credential can
4332 obtain a System V semaphore.
4334 @return Return 0 if access is granted, otherwise an appropriate value for
4335 errno should be returned.
4337 typedef int mpo_sysvsem_check_semget_t(
4339 struct semid_kernel
*semakptr
,
4340 struct label
*semaklabel
4343 @brief Access control check for System V semaphore operations
4344 @param cred Subject credential
4345 @param semakptr Pointer to semaphore identifier
4346 @param semaklabel Label associated with the semaphore
4347 @param accesstype Flags to indicate access (read and/or write)
4349 Determine whether the subject identified by the credential can
4350 perform the operations on the System V semaphore indicated by
4351 semakptr. The accesstype flags hold the maximum set of permissions
4352 from the sem_op array passed to the semop system call. It may
4353 contain SEM_R for read-only operations or SEM_A for read/write
4356 @return Return 0 if access is granted, otherwise an appropriate value for
4357 errno should be returned.
4359 typedef int mpo_sysvsem_check_semop_t(
4361 struct semid_kernel
*semakptr
,
4362 struct label
*semaklabel
,
4366 @brief Create a System V semaphore label
4367 @param cred Subject credential
4368 @param semakptr The semaphore being created
4369 @param semalabel Label to associate with the new semaphore
4371 Label a new System V semaphore. The label was previously
4372 initialized and associated with the semaphore. At this time, an
4373 appropriate initial label value should be assigned to the object and
4374 stored in semalabel.
4376 typedef void mpo_sysvsem_label_associate_t(
4378 struct semid_kernel
*semakptr
,
4379 struct label
*semalabel
4382 @brief Destroy System V semaphore label
4383 @param label The label to be destroyed
4385 Destroy a System V semaphore label. Since the object is
4386 going out of scope, policy modules should free any internal storage
4387 associated with the label so that it may be destroyed.
4389 typedef void mpo_sysvsem_label_destroy_t(
4393 @brief Initialize System V semaphore label
4394 @param label New label to initialize
4396 Initialize the label for a newly instantiated System V semaphore. Sleeping
4399 typedef void mpo_sysvsem_label_init_t(
4403 @brief Clean up a System V semaphore label
4404 @param label The label to be cleaned
4406 Clean up a System V semaphore label. Darwin pre-allocates
4407 semaphores at system boot time and re-uses them rather than
4408 allocating new ones. Before semaphores are returned to the "free
4409 pool", policies can cleanup or overwrite any information present in
4412 typedef void mpo_sysvsem_label_recycle_t(
4416 @brief Access control check for mapping System V shared memory
4417 @param cred Subject credential
4418 @param shmsegptr Pointer to shared memory segment identifier
4419 @param shmseglabel Label associated with the shared memory segment
4420 @param shmflg shmat flags; see shmat(2)
4422 Determine whether the subject identified by the credential can map
4423 the System V shared memory segment associated with shmsegptr.
4425 @return Return 0 if access is granted, otherwise an appropriate value for
4426 errno should be returned.
4428 typedef int mpo_sysvshm_check_shmat_t(
4430 struct shmid_kernel
*shmsegptr
,
4431 struct label
*shmseglabel
,
4435 @brief Access control check for System V shared memory control operation
4436 @param cred Subject credential
4437 @param shmsegptr Pointer to shared memory segment identifier
4438 @param shmseglabel Label associated with the shared memory segment
4439 @param cmd Control operation to be performed; see shmctl(2)
4441 Determine whether the subject identified by the credential can perform
4442 the operation indicated by cmd on the System V shared memory segment
4445 @return Return 0 if access is granted, otherwise an appropriate value for
4446 errno should be returned.
4448 typedef int mpo_sysvshm_check_shmctl_t(
4450 struct shmid_kernel
*shmsegptr
,
4451 struct label
*shmseglabel
,
4455 @brief Access control check for unmapping System V shared memory
4456 @param cred Subject credential
4457 @param shmsegptr Pointer to shared memory segment identifier
4458 @param shmseglabel Label associated with the shared memory segment
4460 Determine whether the subject identified by the credential can unmap
4461 the System V shared memory segment associated with shmsegptr.
4463 @return Return 0 if access is granted, otherwise an appropriate value for
4464 errno should be returned.
4466 typedef int mpo_sysvshm_check_shmdt_t(
4468 struct shmid_kernel
*shmsegptr
,
4469 struct label
*shmseglabel
4472 @brief Access control check obtaining System V shared memory identifier
4473 @param cred Subject credential
4474 @param shmsegptr Pointer to shared memory segment identifier
4475 @param shmseglabel Label associated with the shared memory segment
4476 @param shmflg shmget flags; see shmget(2)
4478 Determine whether the subject identified by the credential can get
4479 the System V shared memory segment address.
4481 @return Return 0 if access is granted, otherwise an appropriate value for
4482 errno should be returned.
4484 typedef int mpo_sysvshm_check_shmget_t(
4486 struct shmid_kernel
*shmsegptr
,
4487 struct label
*shmseglabel
,
4491 @brief Create a System V shared memory region label
4492 @param cred Subject credential
4493 @param shmsegptr The shared memory region being created
4494 @param shmlabel Label to associate with the new shared memory region
4496 Label a new System V shared memory region. The label was previously
4497 initialized and associated with the shared memory region. At this
4498 time, an appropriate initial label value should be assigned to the
4499 object and stored in shmlabel.
4501 typedef void mpo_sysvshm_label_associate_t(
4503 struct shmid_kernel
*shmsegptr
,
4504 struct label
*shmlabel
4507 @brief Destroy System V shared memory label
4508 @param label The label to be destroyed
4510 Destroy a System V shared memory region label. Since the
4511 object is going out of scope, policy modules should free any
4512 internal storage associated with the label so that it may be
4515 typedef void mpo_sysvshm_label_destroy_t(
4519 @brief Initialize System V Shared Memory region label
4520 @param label New label to initialize
4522 Initialize the label for a newly instantiated System V Shared Memory
4523 region. Sleeping is permitted.
4525 typedef void mpo_sysvshm_label_init_t(
4529 @brief Clean up a System V Share Memory Region label
4530 @param shmlabel The label to be cleaned
4532 Clean up a System V Shared Memory Region label. Darwin
4533 pre-allocates these objects at system boot time and re-uses them
4534 rather than allocating new ones. Before the memory regions are
4535 returned to the "free pool", policies can cleanup or overwrite any
4536 information present in the label.
4538 typedef void mpo_sysvshm_label_recycle_t(
4539 struct label
*shmlabel
4542 @brief Access control check for getting a process's task name
4543 @param cred Subject credential
4544 @param proc Object process
4546 Determine whether the subject identified by the credential can get
4547 the passed process's task name port.
4548 This call is used by the task_name_for_pid(2) API.
4550 @return Return 0 if access is granted, otherwise an appropriate value for
4551 errno should be returned. Suggested failure: EACCES for label mismatch,
4552 EPERM for lack of privilege, or ESRCH to hide visibility of the target.
4554 typedef int mpo_proc_check_get_task_name_t(
4559 @brief Access control check for getting a process's task port
4560 @param cred Subject credential
4561 @param proc Object process
4563 Determine whether the subject identified by the credential can get
4564 the passed process's task control port.
4565 This call is used by the task_for_pid(2) API.
4567 @return Return 0 if access is granted, otherwise an appropriate value for
4568 errno should be returned. Suggested failure: EACCES for label mismatch,
4569 EPERM for lack of privilege, or ESRCH to hide visibility of the target.
4571 typedef int mpo_proc_check_get_task_t(
4576 @brief Privilege check for a process to run invalid
4577 @param proc Object process
4579 Determine whether the process may execute even though the system determined
4580 that it is untrusted (eg unidentified / modified code).
4582 @return Return 0 if access is granted, otherwise an appropriate value for
4583 errno should be returned.
4585 typedef int mac_proc_check_run_cs_invalid_t(
4591 @brief Assign a label to a new kernelspace Mach task
4592 @param kproc New task
4593 @param tasklabel Label for new task
4594 @param portlabel Label for new task port
4595 @see mpo_cred_label_associate_kernel_t
4597 Assign labels to a new kernel task and its task port. Both the task and
4598 task port labels should be specified. Both new labels are initialized.
4599 If there is an associated BSD process structure, it will be labelled
4600 with calls to mpo_cred_label_associate_kernel.
4602 typedef void mpo_task_label_associate_kernel_t(
4604 struct label
*tasklabel
,
4605 struct label
*portlabel
4608 @brief Assign a label to a new (userspace) Mach task
4609 @param parent Parent task
4610 @param child New (child) task
4611 @param parentlabel Label of parent task
4612 @param childlabel Label for new task
4613 @param childportlabel Label for new task's task port
4615 Assign labels to a new task and its task port. Both the task and task port
4616 labels should be specified. Both new labels are initialized. If the task
4617 will have an associated BSD process, that information will be made available
4618 by the task_label_update and port_label_update_cred entry points.
4620 typedef void mpo_task_label_associate_t(
4621 struct task
*parent
,
4623 struct label
*parentlabel
,
4624 struct label
*childlabel
,
4625 struct label
*childportlabel
4628 @brief Copy a Mach task label
4629 @param src Source task label
4630 @param dest Destination task label
4632 Copy the Mach task label information from src to dest. This is used
4633 when duplicating label handles to implement copy-on-write semantics.
4635 typedef void mpo_task_label_copy_t(
4640 @brief Destroy Mach task label
4641 @param label The label to be destroyed
4643 Destroy a Mach task label. Since the object is going out of
4644 scope, policy modules should free any internal storage associated
4645 with the label so that it may be destroyed.
4647 typedef void mpo_task_label_destroy_t(
4651 @brief Externalize a task label
4652 @param label Label to be externalized
4653 @param element_name Name of the label namespace for which labels should be
4655 @param sb String buffer to be filled with a text representation of the label
4657 Produce an external representation of the label on a task. An
4658 externalized label consists of a text representation of the label
4659 contents that can be used with user applications. Policy-agnostic
4660 user space tools will display this externalized version.
4662 @return 0 on success, return non-zero if an error occurs while
4663 externalizing the label data.
4666 typedef int mpo_task_label_externalize_t(
4667 struct label
*label
,
4672 @brief Initialize Mach task label
4673 @param label New label to initialize
4675 Initialize the label for a newly instantiated Mach task. Sleeping
4678 typedef void mpo_task_label_init_t(
4682 @brief Internalize a task label
4683 @param label Label to be internalized
4684 @param element_name Name of the label namespace for which the label should
4686 @param element_data Text data to be internalized
4688 Produce a task label from an external representation. An
4689 externalized label consists of a text representation of the label
4690 contents that can be used with user applications. Policy-agnostic
4691 user space tools will forward text version to the kernel for
4692 processing by individual policy modules.
4694 The policy's internalize entry points will be called only if the
4695 policy has registered interest in the label namespace.
4697 @return 0 on success, Otherwise, return non-zero if an error occurs
4698 while internalizing the label data.
4701 typedef int mpo_task_label_internalize_t(
4702 struct label
*label
,
4707 @brief Update a Mach task label
4708 @param cred User credential label to be used as the source
4709 @param task Mach task label to be used as the destination
4710 @see mpo_cred_label_update_t
4711 @see mpo_cred_label_update_execve_t
4713 Update the label on a Mach task, using the supplied user credential
4714 label. When a mac_cred_label_update_execve or a mac_cred_label_update operation
4715 causes the label on a user credential to change, the Mach task label
4716 also needs to be updated to reflect the change. Both labels are
4717 already valid (initialized and created).
4719 @warning XXX We may change the name of this entry point in a future
4720 version of the MAC framework.
4722 typedef void mpo_task_label_update_t(
4727 @brief Check vnode access
4728 @param cred Subject credential
4729 @param vp Object vnode
4730 @param label Label for vp
4731 @param acc_mode access(2) flags
4733 Determine how invocations of access(2) and related calls by the
4734 subject identified by the credential should return when performed
4735 on the passed vnode using the passed access flags. This should
4736 generally be implemented using the same semantics used in
4737 mpo_vnode_check_open.
4739 @return Return 0 if access is granted, otherwise an appropriate value for
4740 errno should be returned. Suggested failure: EACCES for label mismatch or
4741 EPERM for lack of privilege.
4743 typedef int mpo_vnode_check_access_t(
4746 struct label
*label
,
4750 @brief Access control check for changing working directory
4751 @param cred Subject credential
4752 @param dvp Object; vnode to chdir(2) into
4753 @param dlabel Policy label for dvp
4755 Determine whether the subject identified by the credential can change
4756 the process working directory to the passed vnode.
4758 @return Return 0 if access is granted, otherwise an appropriate value for
4759 errno should be returned. Suggested failure: EACCES for label mismatch or
4760 EPERM for lack of privilege.
4762 typedef int mpo_vnode_check_chdir_t(
4765 struct label
*dlabel
4768 @brief Access control check for changing root directory
4769 @param cred Subject credential
4770 @param dvp Directory vnode
4771 @param dlabel Policy label associated with dvp
4772 @param cnp Component name for dvp
4774 Determine whether the subject identified by the credential should be
4775 allowed to chroot(2) into the specified directory (dvp).
4777 @return In the event of an error, an appropriate value for errno
4778 should be returned, otherwise return 0 upon success.
4780 typedef int mpo_vnode_check_chroot_t(
4783 struct label
*dlabel
,
4784 struct componentname
*cnp
4787 @brief Access control check for creating vnode
4788 @param cred Subject credential
4789 @param dvp Directory vnode
4790 @param dlabel Policy label for dvp
4791 @param cnp Component name for dvp
4792 @param vap vnode attributes for vap
4794 Determine whether the subject identified by the credential can create
4795 a vnode with the passed parent directory, passed name information,
4796 and passed attribute information. This call may be made in a number of
4797 situations, including as a result of calls to open(2) with O_CREAT,
4798 mknod(2), mkfifo(2), and others.
4800 @return Return 0 if access is granted, otherwise an appropriate value for
4801 errno should be returned. Suggested failure: EACCES for label mismatch or
4802 EPERM for lack of privilege.
4804 typedef int mpo_vnode_check_create_t(
4807 struct label
*dlabel
,
4808 struct componentname
*cnp
,
4809 struct vnode_attr
*vap
4812 @brief Access control check for deleting extended attribute
4813 @param cred Subject credential
4814 @param vp Object vnode
4815 @param vlabel Label associated with vp
4816 @param name Extended attribute name
4818 Determine whether the subject identified by the credential can delete
4819 the extended attribute from the passed vnode.
4821 @return Return 0 if access is granted, otherwise an appropriate value for
4822 errno should be returned. Suggested failure: EACCES for label mismatch or
4823 EPERM for lack of privilege.
4825 typedef int mpo_vnode_check_deleteextattr_t(
4828 struct label
*vlabel
,
4832 @brief Access control check for exchanging file data
4833 @param cred Subject credential
4834 @param v1 vnode 1 to swap
4835 @param vl1 Policy label for v1
4836 @param v2 vnode 2 to swap
4837 @param vl2 Policy label for v2
4839 Determine whether the subject identified by the credential can swap the data
4840 in the two supplied vnodes.
4842 @return Return 0 if access is granted, otherwise an appropriate value for
4843 errno should be returned. Suggested failure: EACCES for label mismatch or
4844 EPERM for lack of privilege.
4846 typedef int mpo_vnode_check_exchangedata_t(
4854 @brief Access control check for executing the vnode
4855 @param cred Subject credential
4856 @param vp Object vnode to execute
4857 @param label Policy label for vp
4858 @param execlabel Userspace provided execution label
4859 @param cnp Component name for file being executed
4861 Determine whether the subject identified by the credential can execute
4862 the passed vnode. Determination of execute privilege is made separately
4863 from decisions about any process label transitioning event.
4865 The final label, execlabel, corresponds to a label supplied by a
4866 user space application through the use of the mac_execve system call.
4867 This label will be NULL if the user application uses the the vendor
4868 execve(2) call instead of the MAC Framework mac_execve() call.
4870 @return Return 0 if access is granted, otherwise an appropriate value for
4871 errno should be returned. Suggested failure: EACCES for label mismatch or
4872 EPERM for lack of privilege.
4874 typedef int mpo_vnode_check_exec_t(
4877 struct label
*label
,
4878 struct label
*execlabel
, /* NULLOK */
4879 struct componentname
*cnp
,
4883 @brief Access control check for fsgetpath
4884 @param cred Subject credential
4885 @param vp Vnode for which a path will be returned
4886 @param label Label associated with the vnode
4888 Determine whether the subject identified by the credential can get the path
4889 of the given vnode with fsgetpath.
4891 @return Return 0 if access is granted, otherwise an appropriate value for
4892 errno should be returned.
4894 typedef int mpo_vnode_check_fsgetpath_t(
4900 @brief Access control check after determining the code directory hash
4902 typedef int mpo_vnode_check_signature_t(struct vnode
*vp
, struct label
*label
,
4903 unsigned char *sha1
, void *signature
,
4907 @brief Access control check for retrieving file attributes
4908 @param cred Subject credential
4909 @param vp Object vnode
4910 @param vlabel Policy label for vp
4911 @param alist List of attributes to retrieve
4913 Determine whether the subject identified by the credential can read
4914 various attributes of the specified vnode, or the filesystem or volume on
4915 which that vnode resides. See <sys/attr.h> for definitions of the
4918 @return Return 0 if access is granted, otherwise an appropriate value for
4919 errno should be returned. Suggested failure: EACCES for label mismatch or
4920 EPERM for lack of privilege. Access control covers all attributes requested
4921 with this call; the security policy is not permitted to change the set of
4922 attributes requested.
4924 typedef int mpo_vnode_check_getattrlist_t(
4927 struct label
*vlabel
,
4928 struct attrlist
*alist
4931 @brief Access control check for retrieving an extended attribute
4932 @param cred Subject credential
4933 @param vp Object vnode
4934 @param label Policy label for vp
4935 @param name Extended attribute name
4936 @param uio I/O structure pointer
4938 Determine whether the subject identified by the credential can retrieve
4939 the extended attribute from the passed vnode. The uio parameter
4940 will be NULL when the getxattr(2) call has been made with a NULL data
4941 value; this is done to request the size of the data only.
4943 @return Return 0 if access is granted, otherwise an appropriate value for
4944 errno should be returned. Suggested failure: EACCES for label mismatch or
4945 EPERM for lack of privilege.
4947 typedef int mpo_vnode_check_getextattr_t(
4950 struct label
*label
, /* NULLOK */
4952 struct uio
*uio
/* NULLOK */
4955 @brief Access control check for ioctl
4956 @param cred Subject credential
4957 @param vp Object vnode
4958 @param label Policy label for vp
4959 @param com Device-dependent request code; see ioctl(2)
4961 Determine whether the subject identified by the credential can perform
4962 the ioctl operation indicated by com.
4964 @warning Since ioctl data is opaque from the standpoint of the MAC
4965 framework, and since ioctls can affect many aspects of system
4966 operation, policies must exercise extreme care when implementing
4967 access control checks.
4969 @return Return 0 if access is granted, otherwise an appropriate value for
4970 errno should be returned.
4972 typedef int mpo_vnode_check_ioctl_t(
4975 struct label
*label
,
4979 @brief Access control check for vnode kqfilter
4980 @param cred Subject credential
4981 @param kn Object knote
4982 @param vp Object vnode
4983 @param label Policy label for vp
4985 Determine whether the subject identified by the credential can
4986 receive the knote on the passed vnode.
4988 @return Return 0 if access if granted, otherwise an appropriate
4989 value for errno should be returned.
4991 typedef int mpo_vnode_check_kqfilter_t(
4992 kauth_cred_t active_cred
,
4993 kauth_cred_t file_cred
, /* NULLOK */
4999 @brief Access control check for relabel
5000 @param cred Subject credential
5001 @param vp Object vnode
5002 @param vnodelabel Existing policy label for vp
5003 @param newlabel Policy label update to later be applied to vp
5004 @see mpo_relable_vnode_t
5006 Determine whether the subject identified by the credential can relabel
5007 the passed vnode to the passed label update. If all policies permit
5008 the label change, the actual relabel entry point (mpo_vnode_label_update)
5011 @return Return 0 if access is granted, otherwise an appropriate value for
5012 errno should be returned.
5014 typedef int mpo_vnode_check_label_update_t(
5017 struct label
*vnodelabel
,
5018 struct label
*newlabel
5021 @brief Access control check for creating link
5022 @param cred Subject credential
5023 @param dvp Directory vnode
5024 @param dlabel Policy label associated with dvp
5025 @param vp Link destination vnode
5026 @param label Policy label associated with vp
5027 @param cnp Component name for the link being created
5029 Determine whether the subject identified by the credential should be
5030 allowed to create a link to the vnode vp with the name specified by cnp.
5032 @return Return 0 if access is granted, otherwise an appropriate value for
5033 errno should be returned.
5035 typedef int mpo_vnode_check_link_t(
5038 struct label
*dlabel
,
5040 struct label
*label
,
5041 struct componentname
*cnp
5044 @brief Access control check for listing extended attributes
5045 @param cred Subject credential
5046 @param vp Object vnode
5047 @param vlabel Policy label associated with vp
5049 Determine whether the subject identified by the credential can retrieve
5050 a list of named extended attributes from a vnode.
5052 @return Return 0 if access is granted, otherwise an appropriate value for
5053 errno should be returned.
5055 typedef int mpo_vnode_check_listextattr_t(
5058 struct label
*vlabel
5061 @brief Access control check for lookup
5062 @param cred Subject credential
5063 @param dvp Object vnode
5064 @param dlabel Policy label for dvp
5065 @param cnp Component name being looked up
5067 Determine whether the subject identified by the credential can perform
5068 a lookup in the passed directory vnode for the passed name (cnp).
5070 @return Return 0 if access is granted, otherwise an appropriate value for
5071 errno should be returned. Suggested failure: EACCES for label mismatch or
5072 EPERM for lack of privilege.
5074 typedef int mpo_vnode_check_lookup_t(
5077 struct label
*dlabel
,
5078 struct componentname
*cnp
5081 @brief Access control check for open
5082 @param cred Subject credential
5083 @param vp Object vnode
5084 @param label Policy label associated with vp
5085 @param acc_mode open(2) access mode
5087 Determine whether the subject identified by the credential can perform
5088 an open operation on the passed vnode with the passed access mode.
5090 @return Return 0 if access is granted, otherwise an appropriate value for
5091 errno should be returned. Suggested failure: EACCES for label mismatch or
5092 EPERM for lack of privilege.
5094 typedef int mpo_vnode_check_open_t(
5097 struct label
*label
,
5101 @brief Access control check for read
5102 @param active_cred Subject credential
5103 @param file_cred Credential associated with the struct fileproc
5104 @param vp Object vnode
5105 @param label Policy label for vp
5107 Determine whether the subject identified by the credential can perform
5108 a read operation on the passed vnode. The active_cred hold the credentials
5109 of the subject performing the operation, and file_cred holds the
5110 credentials of the subject that originally opened the file.
5112 @return Return 0 if access is granted, otherwise an appropriate value for
5113 errno should be returned. Suggested failure: EACCES for label mismatch or
5114 EPERM for lack of privilege.
5116 typedef int mpo_vnode_check_read_t(
5117 kauth_cred_t active_cred
, /* SUBJECT */
5118 kauth_cred_t file_cred
, /* NULLOK */
5119 struct vnode
*vp
, /* OBJECT */
5120 struct label
*label
/* LABEL */
5123 @brief Access control check for read directory
5124 @param cred Subject credential
5125 @param dvp Object directory vnode
5126 @param dlabel Policy label for dvp
5128 Determine whether the subject identified by the credential can
5129 perform a readdir operation on the passed directory vnode.
5131 @return Return 0 if access is granted, otherwise an appropriate value for
5132 errno should be returned. Suggested failure: EACCES for label mismatch or
5133 EPERM for lack of privilege.
5135 typedef int mpo_vnode_check_readdir_t(
5136 kauth_cred_t cred
, /* SUBJECT */
5137 struct vnode
*dvp
, /* OBJECT */
5138 struct label
*dlabel
/* LABEL */
5141 @brief Access control check for read link
5142 @param cred Subject credential
5143 @param vp Object vnode
5144 @param label Policy label for vp
5146 Determine whether the subject identified by the credential can perform
5147 a readlink operation on the passed symlink vnode. This call can be made
5148 in a number of situations, including an explicit readlink call by the
5149 user process, or as a result of an implicit readlink during a name
5150 lookup by the process.
5152 @return Return 0 if access is granted, otherwise an appropriate value for
5153 errno should be returned. Suggested failure: EACCES for label mismatch or
5154 EPERM for lack of privilege.
5156 typedef int mpo_vnode_check_readlink_t(
5162 @brief Access control check for rename from
5163 @param cred Subject credential
5164 @param dvp Directory vnode
5165 @param dlabel Policy label associated with dvp
5166 @param vp vnode to be renamed
5167 @param label Policy label associated with vp
5168 @param cnp Component name for vp
5169 @see mpo_vnode_check_rename_to_t
5171 Determine whether the subject identified by the credential should be
5172 allowed to rename the vnode vp to something else.
5174 Due to VFS locking constraints (to make sure proper vnode locks are
5175 held during this entry point), the vnode relabel checks had to be
5176 split into two parts: relabel_from and relabel to.
5178 @return Return 0 if access is granted, otherwise an appropriate value for
5179 errno should be returned.
5181 typedef int mpo_vnode_check_rename_from_t(
5184 struct label
*dlabel
,
5186 struct label
*label
,
5187 struct componentname
*cnp
5190 @brief Access control check for rename to
5191 @param cred Subject credential
5192 @param dvp Directory vnode
5193 @param dlabel Policy label associated with dvp
5194 @param vp Overwritten vnode
5195 @param label Policy label associated with vp
5196 @param samedir Boolean; 1 if the source and destination directories are the same
5197 @param cnp Destination component name
5198 @see mpo_vnode_check_rename_from_t
5200 Determine whether the subject identified by the credential should be
5201 allowed to rename to the vnode vp, into the directory dvp, or to the
5202 name represented by cnp. If there is no existing file to overwrite,
5203 vp and label will be NULL.
5205 Due to VFS locking constraints (to make sure proper vnode locks are
5206 held during this entry point), the vnode relabel checks had to be
5207 split into two parts: relabel_from and relabel to.
5209 @return Return 0 if access is granted, otherwise an appropriate value for
5210 errno should be returned.
5212 typedef int mpo_vnode_check_rename_to_t(
5215 struct label
*dlabel
,
5216 struct vnode
*vp
, /* NULLOK */
5217 struct label
*label
, /* NULLOK */
5219 struct componentname
*cnp
5222 @brief Access control check for revoke
5223 @param cred Subject credential
5224 @param vp Object vnode
5225 @param label Policy label for vp
5227 Determine whether the subject identified by the credential can revoke
5228 access to the passed vnode.
5230 @return Return 0 if access is granted, otherwise an appropriate value for
5231 errno should be returned. Suggested failure: EACCES for label mismatch or
5232 EPERM for lack of privilege.
5234 typedef int mpo_vnode_check_revoke_t(
5240 @brief Access control check for searchfs
5241 @param cred Subject credential
5242 @param vp Object vnode
5243 @param vlabel Policy label for vp
5244 @param alist List of attributes used as search criteria
5246 Determine whether the subject identified by the credential can search the
5247 vnode using the searchfs system call.
5249 @return Return 0 if access is granted, otherwise an appropriate value for
5250 errno should be returned.
5252 typedef int mpo_vnode_check_searchfs_t(
5255 struct label
*vlabel
,
5256 struct attrlist
*alist
5259 @brief Access control check for select
5260 @param cred Subject credential
5261 @param vp Object vnode
5262 @param label Policy label for vp
5263 @param which The operation selected on: FREAD or FWRITE
5265 Determine whether the subject identified by the credential can select
5268 @return Return 0 if access is granted, otherwise an appropriate value for
5269 errno should be returned.
5271 typedef int mpo_vnode_check_select_t(
5274 struct label
*label
,
5278 @brief Access control check for setting file attributes
5279 @param cred Subject credential
5280 @param vp Object vnode
5281 @param vlabel Policy label for vp
5282 @param alist List of attributes to set
5284 Determine whether the subject identified by the credential can set
5285 various attributes of the specified vnode, or the filesystem or volume on
5286 which that vnode resides. See <sys/attr.h> for definitions of the
5289 @return Return 0 if access is granted, otherwise an appropriate value for
5290 errno should be returned. Suggested failure: EACCES for label mismatch or
5291 EPERM for lack of privilege. Access control covers all attributes requested
5294 typedef int mpo_vnode_check_setattrlist_t(
5297 struct label
*vlabel
,
5298 struct attrlist
*alist
5301 @brief Access control check for setting extended attribute
5302 @param cred Subject credential
5303 @param vp Object vnode
5304 @param label Policy label for vp
5305 @param name Extended attribute name
5306 @param uio I/O structure pointer
5308 Determine whether the subject identified by the credential can set the
5309 extended attribute of passed name and passed namespace on the passed
5310 vnode. Policies implementing security labels backed into extended
5311 attributes may want to provide additional protections for those
5312 attributes. Additionally, policies should avoid making decisions based
5313 on the data referenced from uio, as there is a potential race condition
5314 between this check and the actual operation. The uio may also be NULL
5315 if a delete operation is being performed.
5317 @return Return 0 if access is granted, otherwise an appropriate value for
5318 errno should be returned. Suggested failure: EACCES for label mismatch or
5319 EPERM for lack of privilege.
5321 typedef int mpo_vnode_check_setextattr_t(
5324 struct label
*label
,
5329 @brief Access control check for setting flags
5330 @param cred Subject credential
5331 @param vp Object vnode
5332 @param label Policy label for vp
5333 @param flags File flags; see chflags(2)
5335 Determine whether the subject identified by the credential can set
5336 the passed flags on the passed vnode.
5338 @return Return 0 if access is granted, otherwise an appropriate value for
5339 errno should be returned. Suggested failure: EACCES for label mismatch or
5340 EPERM for lack of privilege.
5342 typedef int mpo_vnode_check_setflags_t(
5345 struct label
*label
,
5349 @brief Access control check for setting mode
5350 @param cred Subject credential
5351 @param vp Object vnode
5352 @param label Policy label for vp
5353 @param mode File mode; see chmod(2)
5355 Determine whether the subject identified by the credential can set
5356 the passed mode on the passed vnode.
5358 @return Return 0 if access is granted, otherwise an appropriate value for
5359 errno should be returned. Suggested failure: EACCES for label mismatch or
5360 EPERM for lack of privilege.
5362 typedef int mpo_vnode_check_setmode_t(
5365 struct label
*label
,
5369 @brief Access control check for setting uid and gid
5370 @param cred Subject credential
5371 @param vp Object vnode
5372 @param label Policy label for vp
5376 Determine whether the subject identified by the credential can set
5377 the passed uid and passed gid as file uid and file gid on the passed
5378 vnode. The IDs may be set to (-1) to request no update.
5380 @return Return 0 if access is granted, otherwise an appropriate value for
5381 errno should be returned. Suggested failure: EACCES for label mismatch or
5382 EPERM for lack of privilege.
5384 typedef int mpo_vnode_check_setowner_t(
5387 struct label
*label
,
5392 @brief Access control check for setting timestamps
5393 @param cred Subject credential
5394 @param vp Object vnode
5395 @param label Policy label for vp
5396 @param atime Access time; see utimes(2)
5397 @param mtime Modification time; see utimes(2)
5399 Determine whether the subject identified by the credential can set
5400 the passed access timestamps on the passed vnode.
5402 @return Return 0 if access is granted, otherwise an appropriate value for
5403 errno should be returned. Suggested failure: EACCES for label mismatch or
5404 EPERM for lack of privilege.
5406 typedef int mpo_vnode_check_setutimes_t(
5409 struct label
*label
,
5410 struct timespec atime
,
5411 struct timespec mtime
5414 @brief Access control check for stat
5415 @param active_cred Subject credential
5416 @param file_cred Credential associated with the struct fileproc
5417 @param vp Object vnode
5418 @param label Policy label for vp
5420 Determine whether the subject identified by the credential can stat
5421 the passed vnode. See stat(2) for more information. The active_cred
5422 hold the credentials of the subject performing the operation, and
5423 file_cred holds the credentials of the subject that originally
5426 @return Return 0 if access is granted, otherwise an appropriate value for
5427 errno should be returned. Suggested failure: EACCES for label mismatch or
5428 EPERM for lack of privilege.
5430 typedef int mpo_vnode_check_stat_t(
5431 struct ucred
*active_cred
,
5432 struct ucred
*file_cred
, /* NULLOK */
5437 @brief Access control check for truncate/ftruncate
5438 @param active_cred Subject credential
5439 @param file_cred Credential associated with the struct fileproc
5440 @param vp Object vnode
5441 @param label Policy label for vp
5443 Determine whether the subject identified by the credential can
5444 perform a truncate operation on the passed vnode. The active_cred hold
5445 the credentials of the subject performing the operation, and
5446 file_cred holds the credentials of the subject that originally
5449 @return Return 0 if access is granted, otherwise an appropriate value for
5450 errno should be returned. Suggested failure: EACCES for label mismatch or
5451 EPERM for lack of privilege.
5453 typedef int mpo_vnode_check_truncate_t(
5454 kauth_cred_t active_cred
,
5455 kauth_cred_t file_cred
, /* NULLOK */
5460 @brief Access control check for binding UNIX domain socket
5461 @param cred Subject credential
5462 @param dvp Directory vnode
5463 @param dlabel Policy label for dvp
5464 @param cnp Component name for dvp
5465 @param vap vnode attributes for vap
5467 Determine whether the subject identified by the credential can perform a
5468 bind operation on a UNIX domain socket with the passed parent directory,
5469 passed name information, and passed attribute information.
5471 @return Return 0 if access is granted, otherwise an appropriate value for
5472 errno should be returned. Suggested failure: EACCES for label mismatch or
5473 EPERM for lack of privilege.
5475 typedef int mpo_vnode_check_uipc_bind_t(
5478 struct label
*dlabel
,
5479 struct componentname
*cnp
,
5480 struct vnode_attr
*vap
5483 @brief Access control check for connecting UNIX domain socket
5484 @param cred Subject credential
5485 @param vp Object vnode
5486 @param label Policy label associated with vp
5488 Determine whether the subject identified by the credential can perform a
5489 connect operation on the passed UNIX domain socket vnode.
5491 @return Return 0 if access is granted, otherwise an appropriate value for
5492 errno should be returned. Suggested failure: EACCES for label mismatch or
5493 EPERM for lack of privilege.
5495 typedef int mpo_vnode_check_uipc_connect_t(
5501 @brief Access control check for deleting vnode
5502 @param cred Subject credential
5503 @param dvp Parent directory vnode
5504 @param dlabel Policy label for dvp
5505 @param vp Object vnode to delete
5506 @param label Policy label for vp
5507 @param cnp Component name for vp
5508 @see mpo_check_rename_to_t
5510 Determine whether the subject identified by the credential can delete
5511 a vnode from the passed parent directory and passed name information.
5512 This call may be made in a number of situations, including as a
5513 results of calls to unlink(2) and rmdir(2). Policies implementing
5514 this entry point should also implement mpo_check_rename_to to
5515 authorize deletion of objects as a result of being the target of a rename.
5517 @return Return 0 if access is granted, otherwise an appropriate value for
5518 errno should be returned. Suggested failure: EACCES for label mismatch or
5519 EPERM for lack of privilege.
5521 typedef int mpo_vnode_check_unlink_t(
5524 struct label
*dlabel
,
5526 struct label
*label
,
5527 struct componentname
*cnp
5530 @brief Access control check for write
5531 @param active_cred Subject credential
5532 @param file_cred Credential associated with the struct fileproc
5533 @param vp Object vnode
5534 @param label Policy label for vp
5536 Determine whether the subject identified by the credential can
5537 perform a write operation on the passed vnode. The active_cred hold
5538 the credentials of the subject performing the operation, and
5539 file_cred holds the credentials of the subject that originally
5542 @return Return 0 if access is granted, otherwise an appropriate value for
5543 errno should be returned. Suggested failure: EACCES for label mismatch or
5544 EPERM for lack of privilege.
5546 typedef int mpo_vnode_check_write_t(
5547 kauth_cred_t active_cred
,
5548 kauth_cred_t file_cred
, /* NULLOK */
5553 @brief Associate a vnode with a devfs entry
5554 @param mp Devfs mount point
5555 @param mntlabel Devfs mount point label
5556 @param de Devfs directory entry
5557 @param delabel Label associated with de
5558 @param vp vnode associated with de
5559 @param vlabel Label associated with vp
5561 Fill in the label (vlabel) for a newly created devfs vnode. The
5562 label is typically derived from the label on the devfs directory
5563 entry or the label on the filesystem, supplied as parameters.
5565 typedef void mpo_vnode_label_associate_devfs_t(
5567 struct label
*mntlabel
,
5569 struct label
*delabel
,
5571 struct label
*vlabel
5574 @brief Associate a label with a vnode
5575 @param mp File system mount point
5576 @param mntlabel File system mount point label
5577 @param vp Vnode to label
5578 @param vlabel Label associated with vp
5580 Attempt to retrieve label information for the vnode, vp, from the
5581 file system extended attribute store. The label should be stored in
5582 the supplied vlabel parameter. If a policy cannot retrieve an
5583 extended attribute, sometimes it is acceptible to fallback to using
5586 If the policy requires vnodes to have a valid label elsewhere it
5587 MUST NOT return other than temporary errors, and must always provide
5588 a valid label of some sort. Returning an error will cause vnode
5589 labeling to be retried at a later access. Failure to handle policy
5590 centric errors internally (corrupt labels etc.) will result in
5593 @return In the event of an error, an appropriate value for errno
5594 should be returned, otherwise return 0 upon success.
5596 typedef int mpo_vnode_label_associate_extattr_t(
5598 struct label
*mntlabel
,
5600 struct label
*vlabel
5603 @brief Associate a file label with a vnode
5604 @param cred User credential
5605 @param mp Fdesc mount point
5606 @param mntlabel Fdesc mount point label
5607 @param fg Fileglob structure
5608 @param label Policy label for fg
5609 @param vp Vnode to label
5610 @param vlabel Label associated with vp
5612 Associate label information for the vnode, vp, with the label of
5613 the open file descriptor described by fg.
5614 The label should be stored in the supplied vlabel parameter.
5616 typedef void mpo_vnode_label_associate_file_t(
5619 struct label
*mntlabel
,
5620 struct fileglob
*fg
,
5621 struct label
*label
,
5623 struct label
*vlabel
5626 @brief Associate a pipe label with a vnode
5627 @param cred User credential for the process that opened the pipe
5628 @param cpipe Pipe structure
5629 @param pipelabel Label associated with pipe
5630 @param vp Vnode to label
5631 @param vlabel Label associated with vp
5633 Associate label information for the vnode, vp, with the label of
5634 the pipe described by the pipe structure cpipe.
5635 The label should be stored in the supplied vlabel parameter.
5637 typedef void mpo_vnode_label_associate_pipe_t(
5640 struct label
*pipelabel
,
5642 struct label
*vlabel
5645 @brief Associate a POSIX semaphore label with a vnode
5646 @param cred User credential for the process that create psem
5647 @param psem POSIX semaphore structure
5648 @param psemlabel Label associated with psem
5649 @param vp Vnode to label
5650 @param vlabel Label associated with vp
5652 Associate label information for the vnode, vp, with the label of
5653 the POSIX semaphore described by psem.
5654 The label should be stored in the supplied vlabel parameter.
5656 typedef void mpo_vnode_label_associate_posixsem_t(
5658 struct pseminfo
*psem
,
5659 struct label
*psemlabel
,
5661 struct label
*vlabel
5664 @brief Associate a POSIX shared memory label with a vnode
5665 @param cred User credential for the process that created pshm
5666 @param pshm POSIX shared memory structure
5667 @param pshmlabel Label associated with pshm
5668 @param vp Vnode to label
5669 @param vlabel Label associated with vp
5671 Associate label information for the vnode, vp, with the label of
5672 the POSIX shared memory region described by pshm.
5673 The label should be stored in the supplied vlabel parameter.
5675 typedef void mpo_vnode_label_associate_posixshm_t(
5677 struct pshminfo
*pshm
,
5678 struct label
*pshmlabel
,
5680 struct label
*vlabel
5683 @brief Associate a label with a vnode
5684 @param mp File system mount point
5685 @param mntlabel File system mount point label
5686 @param vp Vnode to label
5687 @param vlabel Label associated with vp
5689 On non-multilabel file systems, set the label for a vnode. The
5690 label will most likely be based on the file system label.
5692 typedef void mpo_vnode_label_associate_singlelabel_t(
5694 struct label
*mntlabel
,
5696 struct label
*vlabel
5699 @brief Associate a socket label with a vnode
5700 @param cred User credential for the process that opened the socket
5701 @param so Socket structure
5702 @param solabel Label associated with so
5703 @param vp Vnode to label
5704 @param vlabel Label associated with vp
5706 Associate label information for the vnode, vp, with the label of
5707 the open socket described by the socket structure so.
5708 The label should be stored in the supplied vlabel parameter.
5710 typedef void mpo_vnode_label_associate_socket_t(
5713 struct label
*solabel
,
5715 struct label
*vlabel
5718 @brief Copy a vnode label
5719 @param src Source vnode label
5720 @param dest Destination vnode label
5722 Copy the vnode label information from src to dest. On Darwin, this
5723 is currently only necessary when executing interpreted scripts, but
5724 will later be used if vnode label externalization cannot be an
5727 typedef void mpo_vnode_label_copy_t(
5732 @brief Destroy vnode label
5733 @param label The label to be destroyed
5735 Destroy a vnode label. Since the object is going out of scope,
5736 policy modules should free any internal storage associated with the
5737 label so that it may be destroyed.
5739 typedef void mpo_vnode_label_destroy_t(
5743 @brief Externalize a vnode label for auditing
5744 @param label Label to be externalized
5745 @param element_name Name of the label namespace for which labels should be
5747 @param sb String buffer to be filled with a text representation of the label
5749 Produce an external representation of the label on a vnode suitable for
5750 inclusion in an audit record. An externalized label consists of a text
5751 representation of the label contents that will be added to the audit record
5752 as part of a text token. Policy-agnostic user space tools will display
5753 this externalized version.
5755 @return 0 on success, return non-zero if an error occurs while
5756 externalizing the label data.
5759 typedef int mpo_vnode_label_externalize_audit_t(
5760 struct label
*label
,
5765 @brief Externalize a vnode label
5766 @param label Label to be externalized
5767 @param element_name Name of the label namespace for which labels should be
5769 @param sb String buffer to be filled with a text representation of the label
5771 Produce an external representation of the label on a vnode. An
5772 externalized label consists of a text representation of the label
5773 contents that can be used with user applications. Policy-agnostic
5774 user space tools will display this externalized version.
5776 @return 0 on success, return non-zero if an error occurs while
5777 externalizing the label data.
5780 typedef int mpo_vnode_label_externalize_t(
5781 struct label
*label
,
5786 @brief Initialize vnode label
5787 @param label New label to initialize
5789 Initialize label storage for use with a newly instantiated vnode, or
5790 for temporary storage associated with the copying in or out of a
5791 vnode label. While it is necessary to allocate space for a
5792 kernel-resident vnode label, it is not yet necessary to link this vnode
5793 with persistent label storage facilities, such as extended attributes.
5794 Sleeping is permitted.
5796 typedef void mpo_vnode_label_init_t(
5800 @brief Internalize a vnode label
5801 @param label Label to be internalized
5802 @param element_name Name of the label namespace for which the label should
5804 @param element_data Text data to be internalized
5806 Produce a vnode label from an external representation. An
5807 externalized label consists of a text representation of the label
5808 contents that can be used with user applications. Policy-agnostic
5809 user space tools will forward text version to the kernel for
5810 processing by individual policy modules.
5812 The policy's internalize entry points will be called only if the
5813 policy has registered interest in the label namespace.
5815 @return 0 on success, Otherwise, return non-zero if an error occurs
5816 while internalizing the label data.
5818 typedef int mpo_vnode_label_internalize_t(
5819 struct label
*label
,
5824 @brief Clean up a vnode label
5825 @param label The label to be cleaned for re-use
5827 Clean up a vnode label. Darwin (Tiger, 8.x) allocates vnodes on demand, but
5828 typically never frees them. Before vnodes are placed back on free lists for
5829 re-use, policies can cleanup or overwrite any information present in the label.
5831 typedef void mpo_vnode_label_recycle_t(
5835 @brief Write a label to a extended attribute
5836 @param cred Subject credential
5837 @param vp The vnode for which the label is being stored
5838 @param vlabel Label associated with vp
5839 @param intlabel The new label to store
5841 Store a new label in the extended attribute corresponding to the
5842 supplied vnode. The policy has already authorized the operation;
5843 this call must be implemented in order to perform the actual
5846 @return In the event of an error, an appropriate value for errno
5847 should be returned, otherwise return 0 upon success.
5849 @warning XXX After examining the extended attribute implementation on
5850 Apple's future release, this entry point may be changed.
5852 typedef int mpo_vnode_label_store_t(
5855 struct label
*vlabel
,
5856 struct label
*intlabel
5859 @brief Update vnode label from extended attributes
5860 @param mp File system mount point
5861 @param mntlabel Mount point label
5862 @param vp Vnode to label
5863 @param vlabel Label associated with vp
5864 @param name Name of the xattr
5865 @see mpo_vnode_check_setextattr_t
5867 When an extended attribute is updated via the Vendor attribute management
5868 functions, the MAC vnode label might also require an update.
5869 Policies should first determine if 'name' matches their xattr label
5870 name. If it does, the kernel is has either replaced or removed the
5871 named extended attribute that was previously associated with the
5872 vnode. Normally labels should only be modified via MAC Framework label
5873 management calls, but sometimes the user space components will directly
5874 modify extended attributes. For example, 'cp', 'tar', etc. manage
5875 extended attributes in userspace, not the kernel.
5877 This entry point is called after the label update has occurred, so
5878 it cannot return a failure. However, the operation is preceded by
5879 the mpo_vnode_check_setextattr() access control check.
5881 If the vnode label needs to be updated the policy should return
5882 a non-zero value. The vnode label will be marked for re-association
5885 typedef int mpo_vnode_label_update_extattr_t(
5887 struct label
*mntlabel
,
5889 struct label
*vlabel
,
5893 @brief Update a vnode label
5894 @param cred Subject credential
5895 @param vp The vnode to relabel
5896 @param vnodelabel Existing vnode label
5897 @param label New label to replace existing label
5898 @see mpo_vnode_check_label_update_t
5900 The subject identified by the credential has previously requested
5901 and was authorized to relabel the vnode; this entry point allows
5902 policies to perform the actual relabel operation. Policies should
5903 update vnodelabel using the label stored in the label parameter.
5905 typedef void mpo_vnode_label_update_t(
5908 struct label
*vnodelabel
,
5912 @brief Create a new vnode, backed by extended attributes
5913 @param cred User credential for the creating process
5914 @param mp File system mount point
5915 @param mntlabel File system mount point label
5916 @param dvp Parent directory vnode
5917 @param dlabel Parent directory vnode label
5918 @param vp Newly created vnode
5919 @param vlabel Label to associate with the new vnode
5920 @param cnp Component name for vp
5922 Write out the label for the newly created vnode, most likely storing
5923 the results in a file system extended attribute. Most policies will
5924 derive the new vnode label using information from a combination
5925 of the subject (user) credential, the file system label, the parent
5926 directory label, and potentially the path name component.
5928 @return If the operation succeeds, store the new label in vlabel and
5929 return 0. Otherwise, return an appropriate errno value.
5931 typedef int mpo_vnode_notify_create_t(
5934 struct label
*mntlabel
,
5936 struct label
*dlabel
,
5938 struct label
*vlabel
,
5939 struct componentname
*cnp
5943 @brief Inform MAC policies that a vnode has been renamed
5944 @param cred User credential for the renaming process
5945 @param vp Vnode that's being renamed
5946 @param label Policy label for vp
5947 @param dvp Parent directory for the destination
5948 @param dlabel Policy label for dvp
5949 @param cnp Component name for the destination
5951 Inform MAC policies that a vnode has been renamed.
5953 typedef void mpo_vnode_notify_rename_t(
5956 struct label
*label
,
5958 struct label
*dlabel
,
5959 struct componentname
*cnp
5963 * Placeholder for future events that may need mac hooks.
5965 typedef void mpo_reserved_hook_t(void);
5968 \struct mac_policy_ops
5970 #define MAC_POLICY_OPS_VERSION 11 /* inc when new reserved slots are taken */
5971 struct mac_policy_ops
{
5972 mpo_audit_check_postselect_t
*mpo_audit_check_postselect
;
5973 mpo_audit_check_preselect_t
*mpo_audit_check_preselect
;
5974 mpo_bpfdesc_label_associate_t
*mpo_bpfdesc_label_associate
;
5975 mpo_bpfdesc_label_destroy_t
*mpo_bpfdesc_label_destroy
;
5976 mpo_bpfdesc_label_init_t
*mpo_bpfdesc_label_init
;
5977 mpo_bpfdesc_check_receive_t
*mpo_bpfdesc_check_receive
;
5978 mpo_cred_check_label_update_execve_t
*mpo_cred_check_label_update_execve
;
5979 mpo_cred_check_label_update_t
*mpo_cred_check_label_update
;
5980 mpo_cred_check_visible_t
*mpo_cred_check_visible
;
5981 mpo_cred_label_associate_fork_t
*mpo_cred_label_associate_fork
;
5982 mpo_cred_label_associate_kernel_t
*mpo_cred_label_associate_kernel
;
5983 mpo_cred_label_associate_t
*mpo_cred_label_associate
;
5984 mpo_cred_label_associate_user_t
*mpo_cred_label_associate_user
;
5985 mpo_cred_label_destroy_t
*mpo_cred_label_destroy
;
5986 mpo_cred_label_externalize_audit_t
*mpo_cred_label_externalize_audit
;
5987 mpo_cred_label_externalize_t
*mpo_cred_label_externalize
;
5988 mpo_cred_label_init_t
*mpo_cred_label_init
;
5989 mpo_cred_label_internalize_t
*mpo_cred_label_internalize
;
5990 mpo_cred_label_update_execve_t
*mpo_cred_label_update_execve
;
5991 mpo_cred_label_update_t
*mpo_cred_label_update
;
5992 mpo_devfs_label_associate_device_t
*mpo_devfs_label_associate_device
;
5993 mpo_devfs_label_associate_directory_t
*mpo_devfs_label_associate_directory
;
5994 mpo_devfs_label_copy_t
*mpo_devfs_label_copy
;
5995 mpo_devfs_label_destroy_t
*mpo_devfs_label_destroy
;
5996 mpo_devfs_label_init_t
*mpo_devfs_label_init
;
5997 mpo_devfs_label_update_t
*mpo_devfs_label_update
;
5998 mpo_file_check_change_offset_t
*mpo_file_check_change_offset
;
5999 mpo_file_check_create_t
*mpo_file_check_create
;
6000 mpo_file_check_dup_t
*mpo_file_check_dup
;
6001 mpo_file_check_fcntl_t
*mpo_file_check_fcntl
;
6002 mpo_file_check_get_offset_t
*mpo_file_check_get_offset
;
6003 mpo_file_check_get_t
*mpo_file_check_get
;
6004 mpo_file_check_inherit_t
*mpo_file_check_inherit
;
6005 mpo_file_check_ioctl_t
*mpo_file_check_ioctl
;
6006 mpo_file_check_lock_t
*mpo_file_check_lock
;
6007 mpo_file_check_mmap_downgrade_t
*mpo_file_check_mmap_downgrade
;
6008 mpo_file_check_mmap_t
*mpo_file_check_mmap
;
6009 mpo_file_check_receive_t
*mpo_file_check_receive
;
6010 mpo_file_check_set_t
*mpo_file_check_set
;
6011 mpo_file_label_init_t
*mpo_file_label_init
;
6012 mpo_file_label_destroy_t
*mpo_file_label_destroy
;
6013 mpo_file_label_associate_t
*mpo_file_label_associate
;
6014 mpo_ifnet_check_label_update_t
*mpo_ifnet_check_label_update
;
6015 mpo_ifnet_check_transmit_t
*mpo_ifnet_check_transmit
;
6016 mpo_ifnet_label_associate_t
*mpo_ifnet_label_associate
;
6017 mpo_ifnet_label_copy_t
*mpo_ifnet_label_copy
;
6018 mpo_ifnet_label_destroy_t
*mpo_ifnet_label_destroy
;
6019 mpo_ifnet_label_externalize_t
*mpo_ifnet_label_externalize
;
6020 mpo_ifnet_label_init_t
*mpo_ifnet_label_init
;
6021 mpo_ifnet_label_internalize_t
*mpo_ifnet_label_internalize
;
6022 mpo_ifnet_label_update_t
*mpo_ifnet_label_update
;
6023 mpo_ifnet_label_recycle_t
*mpo_ifnet_label_recycle
;
6024 mpo_inpcb_check_deliver_t
*mpo_inpcb_check_deliver
;
6025 mpo_inpcb_label_associate_t
*mpo_inpcb_label_associate
;
6026 mpo_inpcb_label_destroy_t
*mpo_inpcb_label_destroy
;
6027 mpo_inpcb_label_init_t
*mpo_inpcb_label_init
;
6028 mpo_inpcb_label_recycle_t
*mpo_inpcb_label_recycle
;
6029 mpo_inpcb_label_update_t
*mpo_inpcb_label_update
;
6030 mpo_iokit_check_device_t
*mpo_iokit_check_device
;
6031 mpo_ipq_label_associate_t
*mpo_ipq_label_associate
;
6032 mpo_ipq_label_compare_t
*mpo_ipq_label_compare
;
6033 mpo_ipq_label_destroy_t
*mpo_ipq_label_destroy
;
6034 mpo_ipq_label_init_t
*mpo_ipq_label_init
;
6035 mpo_ipq_label_update_t
*mpo_ipq_label_update
;
6036 mpo_lctx_check_label_update_t
*mpo_lctx_check_label_update
;
6037 mpo_lctx_label_destroy_t
*mpo_lctx_label_destroy
;
6038 mpo_lctx_label_externalize_t
*mpo_lctx_label_externalize
;
6039 mpo_lctx_label_init_t
*mpo_lctx_label_init
;
6040 mpo_lctx_label_internalize_t
*mpo_lctx_label_internalize
;
6041 mpo_lctx_label_update_t
*mpo_lctx_label_update
;
6042 mpo_lctx_notify_create_t
*mpo_lctx_notify_create
;
6043 mpo_lctx_notify_join_t
*mpo_lctx_notify_join
;
6044 mpo_lctx_notify_leave_t
*mpo_lctx_notify_leave
;
6045 mpo_mbuf_label_associate_bpfdesc_t
*mpo_mbuf_label_associate_bpfdesc
;
6046 mpo_mbuf_label_associate_ifnet_t
*mpo_mbuf_label_associate_ifnet
;
6047 mpo_mbuf_label_associate_inpcb_t
*mpo_mbuf_label_associate_inpcb
;
6048 mpo_mbuf_label_associate_ipq_t
*mpo_mbuf_label_associate_ipq
;
6049 mpo_mbuf_label_associate_linklayer_t
*mpo_mbuf_label_associate_linklayer
;
6050 mpo_mbuf_label_associate_multicast_encap_t
*mpo_mbuf_label_associate_multicast_encap
;
6051 mpo_mbuf_label_associate_netlayer_t
*mpo_mbuf_label_associate_netlayer
;
6052 mpo_mbuf_label_associate_socket_t
*mpo_mbuf_label_associate_socket
;
6053 mpo_mbuf_label_copy_t
*mpo_mbuf_label_copy
;
6054 mpo_mbuf_label_destroy_t
*mpo_mbuf_label_destroy
;
6055 mpo_mbuf_label_init_t
*mpo_mbuf_label_init
;
6056 mpo_mount_check_fsctl_t
*mpo_mount_check_fsctl
;
6057 mpo_mount_check_getattr_t
*mpo_mount_check_getattr
;
6058 mpo_mount_check_label_update_t
*mpo_mount_check_label_update
;
6059 mpo_mount_check_mount_t
*mpo_mount_check_mount
;
6060 mpo_mount_check_remount_t
*mpo_mount_check_remount
;
6061 mpo_mount_check_setattr_t
*mpo_mount_check_setattr
;
6062 mpo_mount_check_stat_t
*mpo_mount_check_stat
;
6063 mpo_mount_check_umount_t
*mpo_mount_check_umount
;
6064 mpo_mount_label_associate_t
*mpo_mount_label_associate
;
6065 mpo_mount_label_destroy_t
*mpo_mount_label_destroy
;
6066 mpo_mount_label_externalize_t
*mpo_mount_label_externalize
;
6067 mpo_mount_label_init_t
*mpo_mount_label_init
;
6068 mpo_mount_label_internalize_t
*mpo_mount_label_internalize
;
6069 mpo_netinet_fragment_t
*mpo_netinet_fragment
;
6070 mpo_netinet_icmp_reply_t
*mpo_netinet_icmp_reply
;
6071 mpo_netinet_tcp_reply_t
*mpo_netinet_tcp_reply
;
6072 mpo_pipe_check_ioctl_t
*mpo_pipe_check_ioctl
;
6073 mpo_pipe_check_kqfilter_t
*mpo_pipe_check_kqfilter
;
6074 mpo_pipe_check_label_update_t
*mpo_pipe_check_label_update
;
6075 mpo_pipe_check_read_t
*mpo_pipe_check_read
;
6076 mpo_pipe_check_select_t
*mpo_pipe_check_select
;
6077 mpo_pipe_check_stat_t
*mpo_pipe_check_stat
;
6078 mpo_pipe_check_write_t
*mpo_pipe_check_write
;
6079 mpo_pipe_label_associate_t
*mpo_pipe_label_associate
;
6080 mpo_pipe_label_copy_t
*mpo_pipe_label_copy
;
6081 mpo_pipe_label_destroy_t
*mpo_pipe_label_destroy
;
6082 mpo_pipe_label_externalize_t
*mpo_pipe_label_externalize
;
6083 mpo_pipe_label_init_t
*mpo_pipe_label_init
;
6084 mpo_pipe_label_internalize_t
*mpo_pipe_label_internalize
;
6085 mpo_pipe_label_update_t
*mpo_pipe_label_update
;
6086 mpo_policy_destroy_t
*mpo_policy_destroy
;
6087 mpo_policy_init_t
*mpo_policy_init
;
6088 mpo_policy_initbsd_t
*mpo_policy_initbsd
;
6089 mpo_policy_syscall_t
*mpo_policy_syscall
;
6090 mpo_port_check_copy_send_t
*mpo_port_check_copy_send
;
6091 mpo_port_check_hold_receive_t
*mpo_port_check_hold_receive
;
6092 mpo_port_check_hold_send_once_t
*mpo_port_check_hold_send_once
;
6093 mpo_port_check_hold_send_t
*mpo_port_check_hold_send
;
6094 mpo_port_check_label_update_t
*mpo_port_check_label_update
;
6095 mpo_port_check_make_send_once_t
*mpo_port_check_make_send_once
;
6096 mpo_port_check_make_send_t
*mpo_port_check_make_send
;
6097 mpo_port_check_method_t
*mpo_port_check_method
;
6098 mpo_port_check_move_receive_t
*mpo_port_check_move_receive
;
6099 mpo_port_check_move_send_once_t
*mpo_port_check_move_send_once
;
6100 mpo_port_check_move_send_t
*mpo_port_check_move_send
;
6101 mpo_port_check_receive_t
*mpo_port_check_receive
;
6102 mpo_port_check_send_t
*mpo_port_check_send
;
6103 mpo_port_check_service_t
*mpo_port_check_service
;
6104 mpo_port_label_associate_kernel_t
*mpo_port_label_associate_kernel
;
6105 mpo_port_label_associate_t
*mpo_port_label_associate
;
6106 mpo_port_label_compute_t
*mpo_port_label_compute
;
6107 mpo_port_label_copy_t
*mpo_port_label_copy
;
6108 mpo_port_label_destroy_t
*mpo_port_label_destroy
;
6109 mpo_port_label_init_t
*mpo_port_label_init
;
6110 mpo_port_label_update_cred_t
*mpo_port_label_update_cred
;
6111 mpo_port_label_update_kobject_t
*mpo_port_label_update_kobject
;
6112 mpo_posixsem_check_create_t
*mpo_posixsem_check_create
;
6113 mpo_posixsem_check_open_t
*mpo_posixsem_check_open
;
6114 mpo_posixsem_check_post_t
*mpo_posixsem_check_post
;
6115 mpo_posixsem_check_unlink_t
*mpo_posixsem_check_unlink
;
6116 mpo_posixsem_check_wait_t
*mpo_posixsem_check_wait
;
6117 mpo_posixsem_label_associate_t
*mpo_posixsem_label_associate
;
6118 mpo_posixsem_label_destroy_t
*mpo_posixsem_label_destroy
;
6119 mpo_posixsem_label_init_t
*mpo_posixsem_label_init
;
6120 mpo_posixshm_check_create_t
*mpo_posixshm_check_create
;
6121 mpo_posixshm_check_mmap_t
*mpo_posixshm_check_mmap
;
6122 mpo_posixshm_check_open_t
*mpo_posixshm_check_open
;
6123 mpo_posixshm_check_stat_t
*mpo_posixshm_check_stat
;
6124 mpo_posixshm_check_truncate_t
*mpo_posixshm_check_truncate
;
6125 mpo_posixshm_check_unlink_t
*mpo_posixshm_check_unlink
;
6126 mpo_posixshm_label_associate_t
*mpo_posixshm_label_associate
;
6127 mpo_posixshm_label_destroy_t
*mpo_posixshm_label_destroy
;
6128 mpo_posixshm_label_init_t
*mpo_posixshm_label_init
;
6129 mpo_proc_check_debug_t
*mpo_proc_check_debug
;
6130 mpo_proc_check_fork_t
*mpo_proc_check_fork
;
6131 mpo_proc_check_get_task_name_t
*mpo_proc_check_get_task_name
;
6132 mpo_proc_check_get_task_t
*mpo_proc_check_get_task
;
6133 mpo_proc_check_getaudit_t
*mpo_proc_check_getaudit
;
6134 mpo_proc_check_getauid_t
*mpo_proc_check_getauid
;
6135 mpo_proc_check_getlcid_t
*mpo_proc_check_getlcid
;
6136 mpo_proc_check_mprotect_t
*mpo_proc_check_mprotect
;
6137 mpo_proc_check_sched_t
*mpo_proc_check_sched
;
6138 mpo_proc_check_setaudit_t
*mpo_proc_check_setaudit
;
6139 mpo_proc_check_setauid_t
*mpo_proc_check_setauid
;
6140 mpo_proc_check_setlcid_t
*mpo_proc_check_setlcid
;
6141 mpo_proc_check_signal_t
*mpo_proc_check_signal
;
6142 mpo_proc_check_wait_t
*mpo_proc_check_wait
;
6143 mpo_proc_label_destroy_t
*mpo_proc_label_destroy
;
6144 mpo_proc_label_init_t
*mpo_proc_label_init
;
6145 mpo_socket_check_accept_t
*mpo_socket_check_accept
;
6146 mpo_socket_check_accepted_t
*mpo_socket_check_accepted
;
6147 mpo_socket_check_bind_t
*mpo_socket_check_bind
;
6148 mpo_socket_check_connect_t
*mpo_socket_check_connect
;
6149 mpo_socket_check_create_t
*mpo_socket_check_create
;
6150 mpo_socket_check_deliver_t
*mpo_socket_check_deliver
;
6151 mpo_socket_check_kqfilter_t
*mpo_socket_check_kqfilter
;
6152 mpo_socket_check_label_update_t
*mpo_socket_check_label_update
;
6153 mpo_socket_check_listen_t
*mpo_socket_check_listen
;
6154 mpo_socket_check_receive_t
*mpo_socket_check_receive
;
6155 mpo_socket_check_received_t
*mpo_socket_check_received
;
6156 mpo_socket_check_select_t
*mpo_socket_check_select
;
6157 mpo_socket_check_send_t
*mpo_socket_check_send
;
6158 mpo_socket_check_stat_t
*mpo_socket_check_stat
;
6159 mpo_socket_check_setsockopt_t
*mpo_socket_check_setsockopt
;
6160 mpo_socket_check_getsockopt_t
*mpo_socket_check_getsockopt
;
6161 mpo_socket_label_associate_accept_t
*mpo_socket_label_associate_accept
;
6162 mpo_socket_label_associate_t
*mpo_socket_label_associate
;
6163 mpo_socket_label_copy_t
*mpo_socket_label_copy
;
6164 mpo_socket_label_destroy_t
*mpo_socket_label_destroy
;
6165 mpo_socket_label_externalize_t
*mpo_socket_label_externalize
;
6166 mpo_socket_label_init_t
*mpo_socket_label_init
;
6167 mpo_socket_label_internalize_t
*mpo_socket_label_internalize
;
6168 mpo_socket_label_update_t
*mpo_socket_label_update
;
6169 mpo_socketpeer_label_associate_mbuf_t
*mpo_socketpeer_label_associate_mbuf
;
6170 mpo_socketpeer_label_associate_socket_t
*mpo_socketpeer_label_associate_socket
;
6171 mpo_socketpeer_label_destroy_t
*mpo_socketpeer_label_destroy
;
6172 mpo_socketpeer_label_externalize_t
*mpo_socketpeer_label_externalize
;
6173 mpo_socketpeer_label_init_t
*mpo_socketpeer_label_init
;
6174 mpo_system_check_acct_t
*mpo_system_check_acct
;
6175 mpo_system_check_audit_t
*mpo_system_check_audit
;
6176 mpo_system_check_auditctl_t
*mpo_system_check_auditctl
;
6177 mpo_system_check_auditon_t
*mpo_system_check_auditon
;
6178 mpo_system_check_host_priv_t
*mpo_system_check_host_priv
;
6179 mpo_system_check_nfsd_t
*mpo_system_check_nfsd
;
6180 mpo_system_check_reboot_t
*mpo_system_check_reboot
;
6181 mpo_system_check_settime_t
*mpo_system_check_settime
;
6182 mpo_system_check_swapoff_t
*mpo_system_check_swapoff
;
6183 mpo_system_check_swapon_t
*mpo_system_check_swapon
;
6184 mpo_system_check_sysctl_t
*mpo_system_check_sysctl
;
6185 mpo_sysvmsg_label_associate_t
*mpo_sysvmsg_label_associate
;
6186 mpo_sysvmsg_label_destroy_t
*mpo_sysvmsg_label_destroy
;
6187 mpo_sysvmsg_label_init_t
*mpo_sysvmsg_label_init
;
6188 mpo_sysvmsg_label_recycle_t
*mpo_sysvmsg_label_recycle
;
6189 mpo_sysvmsq_check_enqueue_t
*mpo_sysvmsq_check_enqueue
;
6190 mpo_sysvmsq_check_msgrcv_t
*mpo_sysvmsq_check_msgrcv
;
6191 mpo_sysvmsq_check_msgrmid_t
*mpo_sysvmsq_check_msgrmid
;
6192 mpo_sysvmsq_check_msqctl_t
*mpo_sysvmsq_check_msqctl
;
6193 mpo_sysvmsq_check_msqget_t
*mpo_sysvmsq_check_msqget
;
6194 mpo_sysvmsq_check_msqrcv_t
*mpo_sysvmsq_check_msqrcv
;
6195 mpo_sysvmsq_check_msqsnd_t
*mpo_sysvmsq_check_msqsnd
;
6196 mpo_sysvmsq_label_associate_t
*mpo_sysvmsq_label_associate
;
6197 mpo_sysvmsq_label_destroy_t
*mpo_sysvmsq_label_destroy
;
6198 mpo_sysvmsq_label_init_t
*mpo_sysvmsq_label_init
;
6199 mpo_sysvmsq_label_recycle_t
*mpo_sysvmsq_label_recycle
;
6200 mpo_sysvsem_check_semctl_t
*mpo_sysvsem_check_semctl
;
6201 mpo_sysvsem_check_semget_t
*mpo_sysvsem_check_semget
;
6202 mpo_sysvsem_check_semop_t
*mpo_sysvsem_check_semop
;
6203 mpo_sysvsem_label_associate_t
*mpo_sysvsem_label_associate
;
6204 mpo_sysvsem_label_destroy_t
*mpo_sysvsem_label_destroy
;
6205 mpo_sysvsem_label_init_t
*mpo_sysvsem_label_init
;
6206 mpo_sysvsem_label_recycle_t
*mpo_sysvsem_label_recycle
;
6207 mpo_sysvshm_check_shmat_t
*mpo_sysvshm_check_shmat
;
6208 mpo_sysvshm_check_shmctl_t
*mpo_sysvshm_check_shmctl
;
6209 mpo_sysvshm_check_shmdt_t
*mpo_sysvshm_check_shmdt
;
6210 mpo_sysvshm_check_shmget_t
*mpo_sysvshm_check_shmget
;
6211 mpo_sysvshm_label_associate_t
*mpo_sysvshm_label_associate
;
6212 mpo_sysvshm_label_destroy_t
*mpo_sysvshm_label_destroy
;
6213 mpo_sysvshm_label_init_t
*mpo_sysvshm_label_init
;
6214 mpo_sysvshm_label_recycle_t
*mpo_sysvshm_label_recycle
;
6215 mpo_task_label_associate_kernel_t
*mpo_task_label_associate_kernel
;
6216 mpo_task_label_associate_t
*mpo_task_label_associate
;
6217 mpo_task_label_copy_t
*mpo_task_label_copy
;
6218 mpo_task_label_destroy_t
*mpo_task_label_destroy
;
6219 mpo_task_label_externalize_t
*mpo_task_label_externalize
;
6220 mpo_task_label_init_t
*mpo_task_label_init
;
6221 mpo_task_label_internalize_t
*mpo_task_label_internalize
;
6222 mpo_task_label_update_t
*mpo_task_label_update
;
6223 mpo_iokit_check_hid_control_t
*mpo_iokit_check_hid_control
;
6224 mpo_vnode_check_access_t
*mpo_vnode_check_access
;
6225 mpo_vnode_check_chdir_t
*mpo_vnode_check_chdir
;
6226 mpo_vnode_check_chroot_t
*mpo_vnode_check_chroot
;
6227 mpo_vnode_check_create_t
*mpo_vnode_check_create
;
6228 mpo_vnode_check_deleteextattr_t
*mpo_vnode_check_deleteextattr
;
6229 mpo_vnode_check_exchangedata_t
*mpo_vnode_check_exchangedata
;
6230 mpo_vnode_check_exec_t
*mpo_vnode_check_exec
;
6231 mpo_vnode_check_getattrlist_t
*mpo_vnode_check_getattrlist
;
6232 mpo_vnode_check_getextattr_t
*mpo_vnode_check_getextattr
;
6233 mpo_vnode_check_ioctl_t
*mpo_vnode_check_ioctl
;
6234 mpo_vnode_check_kqfilter_t
*mpo_vnode_check_kqfilter
;
6235 mpo_vnode_check_label_update_t
*mpo_vnode_check_label_update
;
6236 mpo_vnode_check_link_t
*mpo_vnode_check_link
;
6237 mpo_vnode_check_listextattr_t
*mpo_vnode_check_listextattr
;
6238 mpo_vnode_check_lookup_t
*mpo_vnode_check_lookup
;
6239 mpo_vnode_check_open_t
*mpo_vnode_check_open
;
6240 mpo_vnode_check_read_t
*mpo_vnode_check_read
;
6241 mpo_vnode_check_readdir_t
*mpo_vnode_check_readdir
;
6242 mpo_vnode_check_readlink_t
*mpo_vnode_check_readlink
;
6243 mpo_vnode_check_rename_from_t
*mpo_vnode_check_rename_from
;
6244 mpo_vnode_check_rename_to_t
*mpo_vnode_check_rename_to
;
6245 mpo_vnode_check_revoke_t
*mpo_vnode_check_revoke
;
6246 mpo_vnode_check_select_t
*mpo_vnode_check_select
;
6247 mpo_vnode_check_setattrlist_t
*mpo_vnode_check_setattrlist
;
6248 mpo_vnode_check_setextattr_t
*mpo_vnode_check_setextattr
;
6249 mpo_vnode_check_setflags_t
*mpo_vnode_check_setflags
;
6250 mpo_vnode_check_setmode_t
*mpo_vnode_check_setmode
;
6251 mpo_vnode_check_setowner_t
*mpo_vnode_check_setowner
;
6252 mpo_vnode_check_setutimes_t
*mpo_vnode_check_setutimes
;
6253 mpo_vnode_check_stat_t
*mpo_vnode_check_stat
;
6254 mpo_vnode_check_truncate_t
*mpo_vnode_check_truncate
;
6255 mpo_vnode_check_unlink_t
*mpo_vnode_check_unlink
;
6256 mpo_vnode_check_write_t
*mpo_vnode_check_write
;
6257 mpo_vnode_label_associate_devfs_t
*mpo_vnode_label_associate_devfs
;
6258 mpo_vnode_label_associate_extattr_t
*mpo_vnode_label_associate_extattr
;
6259 mpo_vnode_label_associate_file_t
*mpo_vnode_label_associate_file
;
6260 mpo_vnode_label_associate_pipe_t
*mpo_vnode_label_associate_pipe
;
6261 mpo_vnode_label_associate_posixsem_t
*mpo_vnode_label_associate_posixsem
;
6262 mpo_vnode_label_associate_posixshm_t
*mpo_vnode_label_associate_posixshm
;
6263 mpo_vnode_label_associate_singlelabel_t
*mpo_vnode_label_associate_singlelabel
;
6264 mpo_vnode_label_associate_socket_t
*mpo_vnode_label_associate_socket
;
6265 mpo_vnode_label_copy_t
*mpo_vnode_label_copy
;
6266 mpo_vnode_label_destroy_t
*mpo_vnode_label_destroy
;
6267 mpo_vnode_label_externalize_audit_t
*mpo_vnode_label_externalize_audit
;
6268 mpo_vnode_label_externalize_t
*mpo_vnode_label_externalize
;
6269 mpo_vnode_label_init_t
*mpo_vnode_label_init
;
6270 mpo_vnode_label_internalize_t
*mpo_vnode_label_internalize
;
6271 mpo_vnode_label_recycle_t
*mpo_vnode_label_recycle
;
6272 mpo_vnode_label_store_t
*mpo_vnode_label_store
;
6273 mpo_vnode_label_update_extattr_t
*mpo_vnode_label_update_extattr
;
6274 mpo_vnode_label_update_t
*mpo_vnode_label_update
;
6275 mpo_vnode_notify_create_t
*mpo_vnode_notify_create
;
6276 mpo_vnode_check_signature_t
*mpo_vnode_check_signature
;
6277 mpo_vnode_check_uipc_bind_t
*mpo_vnode_check_uipc_bind
;
6278 mpo_vnode_check_uipc_connect_t
*mpo_vnode_check_uipc_connect
;
6279 mac_proc_check_run_cs_invalid_t
*mpo_proc_check_run_cs_invalid
;
6280 mpo_proc_check_suspend_resume_t
*mpo_proc_check_suspend_resume
;
6281 mpo_reserved_hook_t
*mpo_reserved12
;
6282 mpo_iokit_check_set_properties_t
*mpo_iokit_check_set_properties
;
6283 mpo_system_check_chud_t
*mpo_system_check_chud
;
6284 mpo_vnode_check_searchfs_t
*mpo_vnode_check_searchfs
;
6285 mpo_priv_check_t
*mpo_priv_check
;
6286 mpo_priv_grant_t
*mpo_priv_grant
;
6287 mpo_proc_check_map_anon_t
*mpo_proc_check_map_anon
;
6288 mpo_vnode_check_fsgetpath_t
*mpo_vnode_check_fsgetpath
;
6289 mpo_iokit_check_open_t
*mpo_iokit_check_open
;
6290 mpo_vnode_notify_rename_t
*mpo_vnode_notify_rename
;
6291 mpo_reserved_hook_t
*mpo_reserved14
;
6292 mpo_reserved_hook_t
*mpo_reserved15
;
6293 mpo_reserved_hook_t
*mpo_reserved16
;
6294 mpo_reserved_hook_t
*mpo_reserved17
;
6295 mpo_reserved_hook_t
*mpo_reserved18
;
6296 mpo_reserved_hook_t
*mpo_reserved19
;
6297 mpo_reserved_hook_t
*mpo_reserved20
;
6298 mpo_reserved_hook_t
*mpo_reserved21
;
6299 mpo_reserved_hook_t
*mpo_reserved22
;
6300 mpo_reserved_hook_t
*mpo_reserved23
;
6301 mpo_reserved_hook_t
*mpo_reserved24
;
6302 mpo_reserved_hook_t
*mpo_reserved25
;
6303 mpo_reserved_hook_t
*mpo_reserved26
;
6304 mpo_reserved_hook_t
*mpo_reserved27
;
6305 mpo_reserved_hook_t
*mpo_reserved28
;
6306 mpo_reserved_hook_t
*mpo_reserved29
;
6310 @brief MAC policy handle type
6312 The MAC handle is used to uniquely identify a loaded policy within
6315 A variable of this type is set by mac_policy_register().
6317 typedef unsigned int mac_policy_handle_t
;
6319 #define mpc_t struct mac_policy_conf *
6322 @brief Mac policy configuration
6324 This structure specifies the configuration information for a
6325 MAC policy module. A policy module developer must supply
6326 a short unique policy name, a more descriptive full name, a list of label
6327 namespaces and count, a pointer to the registered enty point operations,
6328 any load time flags, and optionally, a pointer to a label slot identifier.
6330 The Framework will update the runtime flags (mpc_runtime_flags) to
6331 indicate that the module has been registered.
6333 If the label slot identifier (mpc_field_off) is NULL, the Framework
6334 will not provide label storage for the policy. Otherwise, the
6335 Framework will store the label location (slot) in this field.
6337 The mpc_list field is used by the Framework and should not be
6338 modified by policies.
6340 /* XXX - reorder these for better aligment on 64bit platforms */
6341 struct mac_policy_conf
{
6342 const char *mpc_name
; /** policy name */
6343 const char *mpc_fullname
; /** full name */
6344 const char **mpc_labelnames
; /** managed label namespaces */
6345 unsigned int mpc_labelname_count
; /** number of managed label namespaces */
6346 struct mac_policy_ops
*mpc_ops
; /** operation vector */
6347 int mpc_loadtime_flags
; /** load time flags */
6348 int *mpc_field_off
; /** label slot */
6349 int mpc_runtime_flags
; /** run time flags */
6350 mpc_t mpc_list
; /** List reference */
6351 void *mpc_data
; /** module data */
6355 @brief MAC policy module registration routine
6357 This function is called to register a policy with the
6358 MAC framework. A policy module will typically call this from the
6359 Darwin KEXT registration routine.
6361 int mac_policy_register(struct mac_policy_conf
*mpc
,
6362 mac_policy_handle_t
*handlep
, void *xd
);
6365 @brief MAC policy module de-registration routine
6367 This function is called to de-register a policy with theD
6368 MAC framework. A policy module will typically call this from the
6369 Darwin KEXT de-registration routine.
6371 int mac_policy_unregister(mac_policy_handle_t handle
);
6374 * Framework entry points for the policies to add audit data.
6376 int mac_audit_text(char *text
, mac_policy_handle_t handle
);
6379 * Calls to assist with use of Apple XATTRs within policy modules.
6381 int mac_vnop_setxattr(struct vnode
*, const char *, char *, size_t);
6382 int mac_vnop_getxattr(struct vnode
*, const char *, char *, size_t,
6384 int mac_vnop_removexattr(struct vnode
*, const char *);
6387 * Arbitrary limit on how much data will be logged by the audit
6388 * entry points above.
6390 #define MAC_AUDIT_DATA_LIMIT 1024
6393 * Values returned by mac_audit_{pre,post}select. To combine the responses
6394 * of the security policies into a single decision,
6395 * mac_audit_{pre,post}select() choose the greatest value returned.
6397 #define MAC_AUDIT_DEFAULT 0 /* use system behavior */
6398 #define MAC_AUDIT_NO 1 /* force not auditing this event */
6399 #define MAC_AUDIT_YES 2 /* force auditing this event */
6401 // \defgroup mpc_loadtime_flags Flags for the mpc_loadtime_flags field
6404 @name Flags for the mpc_loadtime_flags field
6405 @see mac_policy_conf
6407 This is the complete list of flags that are supported by the
6408 mpc_loadtime_flags field of the mac_policy_conf structure. These
6409 flags specify the load time behavior of MAC Framework policy
6416 @brief Flag to indicate registration preference
6418 This flag indicates that the policy module must be loaded and
6419 initialized early in the boot process. If the flag is specified,
6420 attempts to register the module following boot will be rejected. The
6421 flag may be used by policies that require pervasive labeling of all
6422 system objects, and cannot handle objects that have not been
6423 properly initialized by the policy.
6425 #define MPC_LOADTIME_FLAG_NOTLATE 0x00000001
6428 @brief Flag to indicate unload preference
6430 This flag indicates that the policy module may be unloaded. If this
6431 flag is not set, then the policy framework will reject requests to
6432 unload the module. This flag might be used by modules that allocate
6433 label state and are unable to free that state at runtime, or for
6434 modules that simply do not want to permit unload operations.
6436 #define MPC_LOADTIME_FLAG_UNLOADOK 0x00000002
6441 XXX This flag is not yet supported.
6443 #define MPC_LOADTIME_FLAG_LABELMBUFS 0x00000004
6446 @brief Flag to indicate a base policy
6448 This flag indicates that the policy module is a base policy. Only
6449 one module can declare itself as base, otherwise the boot process
6452 #define MPC_LOADTIME_BASE_POLICY 0x00000008
6457 @brief Policy registration flag
6458 @see mac_policy_conf
6460 This flag indicates that the policy module has been successfully
6461 registered with the TrustedBSD MAC Framework. The Framework will
6462 set this flag in the mpc_runtime_flags field of the policy's
6463 mac_policy_conf structure after registering the policy.
6465 #define MPC_RUNTIME_FLAG_REGISTERED 0x00000001
6468 * Depends on POLICY_VER
6472 #define POLICY_VER 1.0
6475 #define MAC_POLICY_SET(handle, mpops, mpname, mpfullname, lnames, lcount, slot, lflags, rflags) \
6476 static struct mac_policy_conf mpname##_mac_policy_conf = { \
6477 .mpc_name = #mpname, \
6478 .mpc_fullname = mpfullname, \
6479 .mpc_labelnames = lnames, \
6480 .mpc_labelname_count = lcount, \
6482 .mpc_loadtime_flags = lflags, \
6483 .mpc_field_off = slot, \
6484 .mpc_runtime_flags = rflags \
6487 static kern_return_t \
6488 kmod_start(kmod_info_t *ki, void *xd) \
6490 return mac_policy_register(&mpname##_mac_policy_conf, \
6494 static kern_return_t \
6495 kmod_stop(kmod_info_t *ki, void *xd) \
6497 return mac_policy_unregister(handle); \
6500 extern kern_return_t _start(kmod_info_t *ki, void *data); \
6501 extern kern_return_t _stop(kmod_info_t *ki, void *data); \
6503 KMOD_EXPLICIT_DECL(security.mpname, POLICY_VER, _start, _stop) \
6504 kmod_start_func_t *_realmain = kmod_start; \
6505 kmod_stop_func_t *_antimain = kmod_stop; \
6506 int _kext_apple_cc = __APPLE_CC__
6509 #define LABEL_TO_SLOT(l, s) (l)->l_perpolicy[s]
6512 * Policy interface to map a struct label pointer to per-policy data.
6513 * Typically, policies wrap this in their own accessor macro that casts an
6514 * intptr_t to a policy-specific data type.
6516 intptr_t mac_label_get(struct label
*l
, int slot
);
6517 void mac_label_set(struct label
*l
, int slot
, intptr_t v
);
6519 #define mac_get_mpc(h) (mac_policy_list.entries[h].mpc)
6522 @name Flags for MAC allocator interfaces
6524 These flags are passed to the Darwin kernel allocator routines to
6525 indicate whether the allocation is permitted to block or not.
6526 Caution should be taken; some operations are not permitted to sleep,
6527 and some types of locks cannot be held when sleeping.
6533 @brief Allocation operations may block
6535 If memory is not immediately available, the allocation routine
6536 will block (typically sleeping) until memory is available.
6538 @warning Inappropriate use of this flag may cause kernel panics.
6540 #define MAC_WAITOK 0
6543 @brief Allocation operations may not block
6545 Rather than blocking, the allocator may return an error if memory
6546 is not immediately available. This type of allocation will not
6547 sleep, preserving locking semantics.
6549 #define MAC_NOWAIT 1
6553 #endif /* !_SECURITY_MAC_POLICY_H_ */