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_
84 #warning "MAC policy is not KPI, see Technical Q&A QA1574, this header will be removed in next version"
87 #include <security/_label.h>
98 struct mac_module_data
;
99 struct mac_policy_conf
;
122 #ifndef _KAUTH_CRED_T
123 #define _KAUTH_CRED_T
124 typedef struct ucred
*kauth_cred_t
;
125 #endif /* !_KAUTH_CRED_T */
127 #ifndef __IOKIT_PORTS_DEFINED__
128 #define __IOKIT_PORTS_DEFINED__
131 typedef OSObject
*io_object_t
;
134 typedef struct OSObject
*io_object_t
;
136 #endif /* __IOKIT_PORTS_DEFINED__ */
139 * MAC entry points are generally named using the following template:
141 * mpo_<object>_<operation>()
145 * mpo_<object>_check_<operation>()
147 * Entry points are sorted by object type.
149 * It may be desirable also to consider some subsystems as "objects", such
150 * as system, iokit, etc.
154 @name Entry Points for Label Management
156 These are the entry points corresponding to the life cycle events for
157 kernel objects, such as initialization, creation, and destruction.
159 Most policies (that use labels) will initialize labels by allocating
160 space for policy-specific data. In most cases, it is permitted to
161 sleep during label initialization operations; it will be noted when
164 Initialization usually will not require doing more than allocating a
165 generic label for the given object. What follows initialization is
166 creation, where a label is made specific to the object it is associated
167 with. Destruction occurs when the label is no longer needed, such as
168 when the corresponding object is destroyed. All necessary cleanup should
169 be performed in label destroy operations.
171 Where possible, the label entry points have identical parameters. If
172 the policy module does not require structure-specific label
173 information, the same function may be registered in the policy
174 operation vector. Many policies will implement two such generic
175 allocation calls: one to handle sleepable requests, and one to handle
176 potentially non-sleepable requests.
181 @brief Audit event postselection
182 @param cred Subject credential
183 @param syscode Syscall number
184 @param args Syscall arguments
185 @param error Syscall errno
186 @param retval Syscall return value
188 This is the MAC Framework audit postselect, which is called before
189 exiting a syscall to determine if an audit event should be committed.
190 A return value of MAC_AUDIT_NO forces the audit record to be suppressed.
191 Any other return value results in the audit record being committed.
193 @warning The suppression behavior will probably go away in Apple's
194 future version of the audit implementation.
196 @return Return MAC_AUDIT_NO to force suppression of the audit record.
197 Any other value results in the audit record being committed.
200 typedef int mpo_audit_check_postselect_t(
202 unsigned short syscode
,
208 @brief Audit event preselection
209 @param cred Subject credential
210 @param syscode Syscall number
211 @param args Syscall arguments
213 This is the MAC Framework audit preselect, which is called before a
214 syscall is entered to determine if an audit event should be created.
215 If the MAC policy forces the syscall to be audited, MAC_AUDIT_YES should be
216 returned. A return value of MAC_AUDIT_NO causes the audit record to
217 be suppressed. Returning MAC_POLICY_DEFAULT indicates that the policy wants
218 to defer to the system's existing preselection mechanism.
220 When policies return different preferences, the Framework decides what action
221 to take based on the following policy. If any policy returns MAC_AUDIT_YES,
222 then create an audit record, else if any policy returns MAC_AUDIT_NO, then
223 suppress the creations of an audit record, else defer to the system's
224 existing preselection mechanism.
226 @warning The audit implementation in Apple's current version is
227 incomplete, so the MAC policies have priority over the system's existing
228 mechanisms. This will probably change in the future version where
229 the audit implementation is more complete.
231 @return Return MAC_AUDIT_YES to force auditing of the syscall,
232 MAC_AUDIT_NO to force no auditing of the syscall, MAC_AUDIT_DEFAULT
233 to allow auditing mechanisms to determine if the syscall is audited.
236 typedef int mpo_audit_check_preselect_t(
238 unsigned short syscode
,
242 @brief Initialize BPF descriptor label
243 @param label New label to initialize
245 Initialize the label for a newly instantiated BPF descriptor.
246 Sleeping is permitted.
248 typedef void mpo_bpfdesc_label_init_t(
252 @brief Destroy BPF descriptor label
253 @param label The label to be destroyed
255 Destroy a BPF descriptor label. Since the BPF descriptor
256 is going out of scope, policy modules should free any internal
257 storage associated with the label so that it may be destroyed.
259 typedef void mpo_bpfdesc_label_destroy_t(
263 @brief Associate a BPF descriptor with a label
264 @param cred User credential creating the BPF descriptor
265 @param bpf_d The BPF descriptor
266 @param bpflabel The new label
268 Set the label on a newly created BPF descriptor from the passed
269 subject credential. This call will be made when a BPF device node
270 is opened by a process with the passed subject credential.
272 typedef void mpo_bpfdesc_label_associate_t(
275 struct label
*bpflabel
278 @brief Check whether BPF can read from a network interface
279 @param bpf_d Subject; the BPF descriptor
280 @param bpflabel Policy label for bpf_d
281 @param ifp Object; the network interface
282 @param ifnetlabel Policy label for ifp
284 Determine whether the MAC framework should permit datagrams from
285 the passed network interface to be delivered to the buffers of
286 the passed BPF descriptor. Return (0) for success, or an errno
287 value for failure. Suggested failure: EACCES for label mismatches,
288 EPERM for lack of privilege.
290 typedef int mpo_bpfdesc_check_receive_t(
292 struct label
*bpflabel
,
294 struct label
*ifnetlabel
297 @brief Indicate desire to change the process label at exec time
298 @param old Existing subject credential
299 @param vp File being executed
300 @param offset Offset of binary within file being executed
301 @param scriptvp Script being executed by interpreter, if any.
302 @param vnodelabel Label corresponding to vp
303 @param scriptvnodelabel Script vnode label
304 @param execlabel Userspace provided execution label
305 @param proc Object process
306 @param macpolicyattr MAC policy-specific spawn attribute data
307 @param macpolicyattrlen Length of policy-specific spawn attribute data
309 @see mpo_cred_label_update_execve_t
310 @see mpo_vnode_check_exec_t
312 Indicate whether this policy intends to update the label of a newly
313 created credential from the existing subject credential (old). This
314 call occurs when a process executes the passed vnode. If a policy
315 returns success from this entry point, the mpo_cred_label_update_execve
316 entry point will later be called with the same parameters. Access
317 has already been checked via the mpo_vnode_check_exec entry point,
318 this entry point is necessary to preserve kernel locking constraints
319 during program execution.
321 The supplied vnode and vnodelabel correspond with the file actually
322 being executed; in the case that the file is interpreted (for
323 example, a script), the label of the original exec-time vnode has
324 been preserved in scriptvnodelabel.
326 The final label, execlabel, corresponds to a label supplied by a
327 user space application through the use of the mac_execve system call.
329 The vnode lock is held during this operation. No changes should be
330 made to the old credential structure.
332 @warning Even if a policy returns 0, it should behave correctly in
333 the presence of an invocation of mpo_cred_label_update_execve, as that
334 call may happen as a result of another policy requesting a transition.
336 @return Non-zero if a transition is required, 0 otherwise.
338 typedef int mpo_cred_check_label_update_execve_t(
342 struct vnode
*scriptvp
,
343 struct label
*vnodelabel
,
344 struct label
*scriptvnodelabel
,
345 struct label
*execlabel
,
348 size_t macpolicyattrlen
351 @brief Access control check for relabelling processes
352 @param cred Subject credential
353 @param newlabel New label to apply to the user credential
354 @see mpo_cred_label_update_t
357 Determine whether the subject identified by the credential can relabel
358 itself to the supplied new label (newlabel). This access control check
359 is called when the mac_set_proc system call is invoked. A user space
360 application will supply a new value, the value will be internalized
361 and provided in newlabel.
363 @return Return 0 if access is granted, otherwise an appropriate value for
364 errno should be returned.
366 typedef int mpo_cred_check_label_update_t(
368 struct label
*newlabel
371 @brief Access control check for visibility of other subjects
372 @param u1 Subject credential
373 @param u2 Object credential
375 Determine whether the subject identified by the credential u1 can
376 "see" other subjects with the passed subject credential u2. This call
377 may be made in a number of situations, including inter-process status
378 sysctls used by ps, and in procfs lookups.
380 @return Return 0 if access is granted, otherwise an appropriate value for
381 errno should be returned. Suggested failure: EACCES for label mismatch,
382 EPERM for lack of privilege, or ESRCH to hide visibility.
384 typedef int mpo_cred_check_visible_t(
389 @brief Associate a credential with a new process at fork
390 @param cred credential to inherited by new process
391 @param proc the new process
393 Allow a process to associate the credential with a new
394 process for reference countng purposes.
395 NOTE: the credential can be dis-associated in ways other
396 than exit - so this strategy is flawed - should just
397 catch label destroy callback.
399 typedef void mpo_cred_label_associate_fork_t(
404 @brief Create the first process
405 @param cred Subject credential to be labeled
407 Create the subject credential of process 0, the parent of all BSD
408 kernel processes. Policies should update the label in the
409 previously initialized credential structure.
411 typedef void mpo_cred_label_associate_kernel_t(
415 @brief Create a credential label
416 @param parent_cred Parent credential
417 @param child_cred Child credential
419 Set the label of a newly created credential, most likely using the
420 information in the supplied parent credential.
422 @warning This call is made when crcopy or crdup is invoked on a
423 newly created struct ucred, and should not be confused with a
424 process fork or creation event.
426 typedef void mpo_cred_label_associate_t(
427 kauth_cred_t parent_cred
,
428 kauth_cred_t child_cred
431 @brief Create the first process
432 @param cred Subject credential to be labeled
434 Create the subject credential of process 1, the parent of all BSD
435 user processes. Policies should update the label in the previously
436 initialized credential structure. This is the 'init' process.
438 typedef void mpo_cred_label_associate_user_t(
442 @brief Destroy credential label
443 @param label The label to be destroyed
445 Destroy a user credential label. Since the user credential
446 is going out of scope, policy modules should free any internal
447 storage associated with the label so that it may be destroyed.
449 typedef void mpo_cred_label_destroy_t(
453 @brief Externalize a user credential label for auditing
454 @param label Label to be externalized
455 @param element_name Name of the label namespace for which labels should be
457 @param sb String buffer to be filled with a text representation of the label
459 Produce an external representation of the label on a user credential for
460 inclusion in an audit record. An externalized label consists of a text
461 representation of the label contents that will be added to the audit record
462 as part of a text token. Policy-agnostic user space tools will display
463 this externalized version.
465 @return 0 on success, return non-zero if an error occurs while
466 externalizing the label data.
469 typedef int mpo_cred_label_externalize_audit_t(
475 @brief Externalize a user credential label
476 @param label Label to be externalized
477 @param element_name Name of the label namespace for which labels should be
479 @param sb String buffer to be filled with a text representation of the label
481 Produce an external representation of the label on a user
482 credential. An externalized label consists of a text representation
483 of the label contents that can be used with user applications.
484 Policy-agnostic user space tools will display this externalized
487 @return 0 on success, return non-zero if an error occurs while
488 externalizing the label data.
491 typedef int mpo_cred_label_externalize_t(
497 @brief Initialize user credential label
498 @param label New label to initialize
500 Initialize the label for a newly instantiated user credential.
501 Sleeping is permitted.
503 typedef void mpo_cred_label_init_t(
507 @brief Internalize a user credential label
508 @param label Label to be internalized
509 @param element_name Name of the label namespace for which the label should
511 @param element_data Text data to be internalized
513 Produce a user credential label from an external representation. An
514 externalized label consists of a text representation of the label
515 contents that can be used with user applications. Policy-agnostic
516 user space tools will forward text version to the kernel for
517 processing by individual policy modules.
519 The policy's internalize entry points will be called only if the
520 policy has registered interest in the label namespace.
522 @return 0 on success, Otherwise, return non-zero if an error occurs
523 while internalizing the label data.
526 typedef int mpo_cred_label_internalize_t(
532 @brief Update credential at exec time
533 @param old_cred Existing subject credential
534 @param new_cred New subject credential to be labeled
535 @param p Object process.
536 @param vp File being executed
537 @param offset Offset of binary within file being executed
538 @param scriptvp Script being executed by interpreter, if any.
539 @param vnodelabel Label corresponding to vp
540 @param scriptvnodelabel Script vnode label
541 @param execlabel Userspace provided execution label
542 @param csflags Code signing flags to be set after exec
543 @param macpolicyattr MAC policy-specific spawn attribute data.
544 @param macpolicyattrlen Length of policy-specific spawn attribute data.
546 @see mpo_cred_check_label_update_execve_t
547 @see mpo_vnode_check_exec_t
549 Update the label of a newly created credential (new) from the
550 existing subject credential (old). This call occurs when a process
551 executes the passed vnode and one of the loaded policy modules has
552 returned success from the mpo_cred_check_label_update_execve entry point.
553 Access has already been checked via the mpo_vnode_check_exec entry
554 point, this entry point is only used to update any policy state.
556 The supplied vnode and vnodelabel correspond with the file actually
557 being executed; in the case that the file is interpreted (for
558 example, a script), the label of the original exec-time vnode has
559 been preserved in scriptvnodelabel.
561 The final label, execlabel, corresponds to a label supplied by a
562 user space application through the use of the mac_execve system call.
564 If non-NULL, the value pointed to by disjointp will be set to 0 to
565 indicate that the old and new credentials are not disjoint, or 1 to
566 indicate that they are.
568 The vnode lock is held during this operation. No changes should be
569 made to the old credential structure.
570 @return 0 on success, Otherwise, return non-zero if update results in
571 termination of child.
573 typedef int mpo_cred_label_update_execve_t(
574 kauth_cred_t old_cred
,
575 kauth_cred_t new_cred
,
579 struct vnode
*scriptvp
,
580 struct label
*vnodelabel
,
581 struct label
*scriptvnodelabel
,
582 struct label
*execlabel
,
585 size_t macpolicyattrlen
,
589 @brief Update a credential label
590 @param cred The existing credential
591 @param newlabel A new label to apply to the credential
592 @see mpo_cred_check_label_update_t
595 Update the label on a user credential, using the supplied new label.
596 This is called as a result of a process relabel operation. Access
597 control was already confirmed by mpo_cred_check_label_update.
599 typedef void mpo_cred_label_update_t(
601 struct label
*newlabel
604 @brief Create a new devfs device
605 @param dev Major and minor numbers of special file
606 @param de "inode" of new device file
607 @param label Destination label
608 @param fullpath Path relative to mount (e.g. /dev) of new device file
610 This entry point labels a new devfs device. The label will likely be based
611 on the path to the device, or the major and minor numbers.
612 The policy should store an appropriate label into 'label'.
614 typedef void mpo_devfs_label_associate_device_t(
621 @brief Create a new devfs directory
622 @param dirname Name of new directory
623 @param dirnamelen Length of 'dirname'
624 @param de "inode" of new directory
625 @param label Destination label
626 @param fullpath Path relative to mount (e.g. /dev) of new directory
628 This entry point labels a new devfs directory. The label will likely be
629 based on the path of the new directory. The policy should store an appropriate
630 label into 'label'. The devfs root directory is labelled in this way.
632 typedef void mpo_devfs_label_associate_directory_t(
640 @brief Copy a devfs label
641 @param src Source devfs label
642 @param dest Destination devfs label
644 Copy the label information from src to dest. The devfs file system
645 often duplicates (splits) existing device nodes rather than creating
648 typedef void mpo_devfs_label_copy_t(
653 @brief Destroy devfs label
654 @param label The label to be destroyed
656 Destroy a devfs entry label. Since the object is going out
657 of scope, policy modules should free any internal storage associated
658 with the label so that it may be destroyed.
660 typedef void mpo_devfs_label_destroy_t(
664 @brief Initialize devfs label
665 @param label New label to initialize
667 Initialize the label for a newly instantiated devfs entry. Sleeping
670 typedef void mpo_devfs_label_init_t(
674 @brief Update a devfs label after relabelling its vnode
675 @param mp Devfs mount point
676 @param de Affected devfs directory entry
677 @param delabel Label of devfs directory entry
678 @param vp Vnode associated with de
679 @param vnodelabel New label of vnode
681 Update a devfs label when its vnode is manually relabelled,
682 for example with setfmac(1). Typically, this will simply copy
683 the vnode label into the devfs label.
685 typedef void mpo_devfs_label_update_t(
688 struct label
*delabel
,
690 struct label
*vnodelabel
693 @brief Access control for changing the offset of a file descriptor
694 @param cred Subject credential
695 @param fg Fileglob structure
696 @param label Policy label for fg
698 Determine whether the subject identified by the credential can
699 change the offset of the file represented by fg.
701 @return Return 0 if access if granted, otherwise an appropriate
702 value for errno should be returned.
704 typedef int mpo_file_check_change_offset_t(
710 @brief Access control for creating a file descriptor
711 @param cred Subject credential
713 Determine whether the subject identified by the credential can
714 allocate a new file descriptor.
716 @return Return 0 if access if granted, otherwise an appropriate
717 value for errno should be returned.
719 typedef int mpo_file_check_create_t(
723 @brief Access control for duplicating a file descriptor
724 @param cred Subject credential
725 @param fg Fileglob structure
726 @param label Policy label for fg
727 @param newfd New file descriptor number
729 Determine whether the subject identified by the credential can
730 duplicate the fileglob structure represented by fg and as file
731 descriptor number newfd.
733 @return Return 0 if access if granted, otherwise an appropriate
734 value for errno should be returned.
736 typedef int mpo_file_check_dup_t(
743 @brief Access control check for fcntl
744 @param cred Subject credential
745 @param fg Fileglob structure
746 @param label Policy label for fg
747 @param cmd Control operation to be performed; see fcntl(2)
748 @param arg fcnt arguments; see fcntl(2)
750 Determine whether the subject identified by the credential can perform
751 the file control operation indicated by cmd.
753 @return Return 0 if access is granted, otherwise an appropriate value for
754 errno should be returned.
756 typedef int mpo_file_check_fcntl_t(
764 @brief Access control check for mac_get_fd
765 @param cred Subject credential
766 @param fg Fileglob structure
767 @param elements Element buffer
768 @param len Length of buffer
770 Determine whether the subject identified by the credential should be allowed
771 to get an externalized version of the label on the object indicated by fd.
773 @return Return 0 if access is granted, otherwise an appropriate value for
774 errno should be returned.
776 typedef int mpo_file_check_get_t(
783 @brief Access control for getting the offset of a file descriptor
784 @param cred Subject credential
785 @param fg Fileglob structure
786 @param label Policy label for fg
788 Determine whether the subject identified by the credential can
789 get the offset of the file represented by fg.
791 @return Return 0 if access if granted, otherwise an appropriate
792 value for errno should be returned.
794 typedef int mpo_file_check_get_offset_t(
800 @brief Access control for inheriting a file descriptor
801 @param cred Subject credential
802 @param fg Fileglob structure
803 @param label Policy label for fg
805 Determine whether the subject identified by the credential can
806 inherit the fileglob structure represented by fg.
808 @return Return 0 if access if granted, otherwise an appropriate
809 value for errno should be returned.
811 typedef int mpo_file_check_inherit_t(
817 @brief Access control check for file ioctl
818 @param cred Subject credential
819 @param fg Fileglob structure
820 @param label Policy label for fg
821 @param cmd The ioctl command; see ioctl(2)
823 Determine whether the subject identified by the credential can perform
824 the ioctl operation indicated by cmd.
826 @warning Since ioctl data is opaque from the standpoint of the MAC
827 framework, policies must exercise extreme care when implementing
828 access control checks.
830 @return Return 0 if access is granted, otherwise an appropriate value for
831 errno should be returned.
834 typedef int mpo_file_check_ioctl_t(
841 @brief Access control check for file locking
842 @param cred Subject credential
843 @param fg Fileglob structure
844 @param label Policy label for fg
845 @param op The lock operation (F_GETLK, F_SETLK, F_UNLK)
846 @param fl The flock structure
848 Determine whether the subject identified by the credential can perform
849 the lock operation indicated by op and fl on the file represented by fg.
851 @return Return 0 if access is granted, otherwise an appropriate value for
852 errno should be returned.
855 typedef int mpo_file_check_lock_t(
863 @brief Access control check for mapping a file
864 @param cred Subject credential
865 @param fg fileglob representing file to map
866 @param label Policy label associated with vp
867 @param prot mmap protections; see mmap(2)
868 @param flags Type of mapped object; see mmap(2)
869 @param maxprot Maximum rights
871 Determine whether the subject identified by the credential should be
872 allowed to map the file represented by fg with the protections specified
873 in prot. The maxprot field holds the maximum permissions on the new
874 mapping, a combination of VM_PROT_READ, VM_PROT_WRITE, and VM_PROT_EXECUTE.
875 To avoid overriding prior access control checks, a policy should only
876 remove flags from maxprot.
878 @return Return 0 if access is granted, otherwise an appropriate value for
879 errno should be returned. Suggested failure: EACCES for label mismatch or
880 EPERM for lack of privilege.
882 typedef int mpo_file_check_mmap_t(
892 @brief Downgrade the mmap protections
893 @param cred Subject credential
894 @param fg file to map
895 @param label Policy label associated with vp
896 @param prot mmap protections to be downgraded
898 Downgrade the mmap protections based on the subject and object labels.
900 typedef void mpo_file_check_mmap_downgrade_t(
907 @brief Access control for receiving a file descriptor
908 @param cred Subject credential
909 @param fg Fileglob structure
910 @param label Policy label for fg
912 Determine whether the subject identified by the credential can
913 receive the fileglob structure represented by fg.
915 @return Return 0 if access if granted, otherwise an appropriate
916 value for errno should be returned.
918 typedef int mpo_file_check_receive_t(
924 @brief Access control check for mac_set_fd
925 @param cred Subject credential
926 @param fg Fileglob structure
927 @param elements Elements buffer
928 @param len Length of elements buffer
930 Determine whether the subject identified by the credential can
931 perform the mac_set_fd operation. The mac_set_fd operation is used
932 to associate a MAC label with a file.
934 @return Return 0 if access is granted, otherwise an appropriate value for
935 errno should be returned.
937 typedef int mpo_file_check_set_t(
944 @brief Create file label
945 @param cred Subject credential
946 @param fg Fileglob structure
947 @param label Policy label for fg
949 typedef void mpo_file_label_associate_t(
955 @brief Destroy file label
956 @param label The label to be destroyed
958 Destroy the label on a file descriptor. In this entry point, a
959 policy module should free any internal storage associated with
960 label so that it may be destroyed.
962 typedef void mpo_file_label_destroy_t(
966 @brief Initialize file label
967 @param label New label to initialize
969 typedef void mpo_file_label_init_t(
973 @brief Access control check for relabeling network interfaces
974 @param cred Subject credential
975 @param ifp network interface being relabeled
976 @param ifnetlabel Current label of the network interfaces
977 @param newlabel New label to apply to the network interfaces
978 @see mpo_ifnet_label_update_t
980 Determine whether the subject identified by the credential can
981 relabel the network interface represented by ifp to the supplied
982 new label (newlabel).
984 @return Return 0 if access is granted, otherwise an appropriate value for
985 errno should be returned.
987 typedef int mpo_ifnet_check_label_update_t(
990 struct label
*ifnetlabel
,
991 struct label
*newlabel
994 @brief Access control check for relabeling network interfaces
995 @param ifp Network interface mbuf will be transmitted through
996 @param ifnetlabel Label of the network interfaces
997 @param m The mbuf to be transmitted
998 @param mbuflabel Label of the mbuf to be transmitted
999 @param family Address Family, AF_*
1000 @param type Type of socket, SOCK_{STREAM,DGRAM,RAW}
1002 Determine whether the mbuf with label mbuflabel may be transmitted
1003 through the network interface represented by ifp that has the
1006 @return Return 0 if access is granted, otherwise an appropriate value for
1007 errno should be returned.
1009 typedef int mpo_ifnet_check_transmit_t(
1011 struct label
*ifnetlabel
,
1013 struct label
*mbuflabel
,
1018 @brief Create a network interface label
1019 @param ifp Network interface labeled
1020 @param ifnetlabel Label for the network interface
1022 Set the label of a newly created network interface, most likely
1023 using the information in the supplied network interface struct.
1025 typedef void mpo_ifnet_label_associate_t(
1027 struct label
*ifnetlabel
1030 @brief Copy an ifnet label
1031 @param src Source ifnet label
1032 @param dest Destination ifnet label
1034 Copy the label information from src to dest.
1036 typedef void mpo_ifnet_label_copy_t(
1041 @brief Destroy ifnet label
1042 @param label The label to be destroyed
1044 Destroy the label on an ifnet label. In this entry point, a
1045 policy module should free any internal storage associated with
1046 label so that it may be destroyed.
1048 typedef void mpo_ifnet_label_destroy_t(
1052 @brief Externalize an ifnet label
1053 @param label Label to be externalized
1054 @param element_name Name of the label namespace for which labels should be
1056 @param sb String buffer to be filled with a text representation of the label
1058 Produce an external representation of the label on an interface.
1059 An externalized label consists of a text representation of the
1060 label contents that can be used with user applications.
1061 Policy-agnostic user space tools will display this externalized
1064 @return 0 on success, return non-zero if an error occurs while
1065 externalizing the label data.
1068 typedef int mpo_ifnet_label_externalize_t(
1069 struct label
*label
,
1074 @brief Initialize ifnet label
1075 @param label New label to initialize
1077 typedef void mpo_ifnet_label_init_t(
1081 @brief Internalize an interface label
1082 @param label Label to be internalized
1083 @param element_name Name of the label namespace for which the label should
1085 @param element_data Text data to be internalized
1087 Produce an interface label from an external representation. An
1088 externalized label consists of a text representation of the label
1089 contents that can be used with user applications. Policy-agnostic
1090 user space tools will forward text version to the kernel for
1091 processing by individual policy modules.
1093 The policy's internalize entry points will be called only if the
1094 policy has registered interest in the label namespace.
1096 @return 0 on success, Otherwise, return non-zero if an error occurs
1097 while internalizing the label data.
1100 typedef int mpo_ifnet_label_internalize_t(
1101 struct label
*label
,
1106 @brief Recycle up a network interface label
1107 @param label The label to be recycled
1109 Recycle a network interface label. Darwin caches the struct ifnet
1110 of detached ifnets in a "free pool". Before ifnets are returned
1111 to the "free pool", policies can cleanup or overwrite any information
1112 present in the label.
1114 typedef void mpo_ifnet_label_recycle_t(
1118 @brief Update a network interface label
1119 @param cred Subject credential
1120 @param ifp The network interface to be relabeled
1121 @param ifnetlabel The current label of the network interface
1122 @param newlabel A new label to apply to the network interface
1123 @see mpo_ifnet_check_label_update_t
1125 Update the label on a network interface, using the supplied new label.
1127 typedef void mpo_ifnet_label_update_t(
1130 struct label
*ifnetlabel
,
1131 struct label
*newlabel
1134 @brief Access control check for delivering a packet to a socket
1135 @param inp inpcb the socket is associated with
1136 @param inplabel Label of the inpcb
1137 @param m The mbuf being received
1138 @param mbuflabel Label of the mbuf being received
1139 @param family Address family, AF_*
1140 @param type Type of socket, SOCK_{STREAM,DGRAM,RAW}
1142 Determine whether the mbuf with label mbuflabel may be received
1143 by the socket associated with inpcb that has the label inplabel.
1145 @return Return 0 if access is granted, otherwise an appropriate value for
1146 errno should be returned.
1148 typedef int mpo_inpcb_check_deliver_t(
1150 struct label
*inplabel
,
1152 struct label
*mbuflabel
,
1157 @brief Create an inpcb label
1158 @param so Socket containing the inpcb to be labeled
1159 @param solabel Label of the socket
1160 @param inp inpcb to be labeled
1161 @param inplabel Label for the inpcb
1163 Set the label of a newly created inpcb, most likely
1164 using the information in the socket and/or socket label.
1166 typedef void mpo_inpcb_label_associate_t(
1168 struct label
*solabel
,
1170 struct label
*inplabel
1173 @brief Destroy inpcb label
1174 @param label The label to be destroyed
1176 Destroy the label on an inpcb label. In this entry point, a
1177 policy module should free any internal storage associated with
1178 label so that it may be destroyed.
1180 typedef void mpo_inpcb_label_destroy_t(
1184 @brief Initialize inpcb label
1185 @param label New label to initialize
1186 @param flag M_WAITOK or M_NOWAIT
1188 typedef int mpo_inpcb_label_init_t(
1189 struct label
*label
,
1193 @brief Recycle up an inpcb label
1194 @param label The label to be recycled
1196 Recycle an inpcb label. Darwin allocates the inpcb as part of
1197 the socket structure in some cases. For this case we must recycle
1198 rather than destroy the inpcb as it will be reused later.
1200 typedef void mpo_inpcb_label_recycle_t(
1204 @brief Update an inpcb label from a socket label
1205 @param so Socket containing the inpcb to be relabeled
1206 @param solabel New label of the socket
1207 @param inp inpcb to be labeled
1208 @param inplabel Label for the inpcb
1210 Set the label of a newly created inpcb due to a change in the
1211 underlying socket label.
1213 typedef void mpo_inpcb_label_update_t(
1215 struct label
*solabel
,
1217 struct label
*inplabel
1220 @brief Device hardware access control
1221 @param devtype Type of device connected
1222 @param properties XML-formatted property list
1223 @param proplen Length of the property list
1225 This is the MAC Framework device access control, which is called by the I/O
1226 Kit when a new device is connected to the system to determine whether that
1227 device should be trusted. A list of properties associated with the device
1228 is passed as an XML-formatted string. The routine should examine these
1229 properties to determine the trustworthiness of the device. A return value
1230 of EPERM forces the device to be claimed by a special device driver that
1231 will prevent its operation.
1233 @warning This is an experimental interface and may change in the future.
1235 @return Return EPERM to indicate that the device is untrusted and should
1236 not be allowed to operate. Return zero to indicate that the device is
1237 trusted and should be allowed to operate normally.
1240 typedef int mpo_iokit_check_device_t(
1242 struct mac_module_data
*mdata
1245 @brief Access control check for opening an I/O Kit device
1246 @param cred Subject credential
1247 @param device_path Device path
1248 @param user_client User client instance
1249 @param user_client_type User client type
1251 Determine whether the subject identified by the credential can open an
1252 I/O Kit device at the passed path of the passed user client class and
1255 @return Return 0 if access is granted, or an appropriate value for
1256 errno should be returned.
1258 typedef int mpo_iokit_check_open_t(
1260 io_object_t user_client
,
1261 unsigned int user_client_type
1264 @brief Access control check for setting I/O Kit device properties
1265 @param cred Subject credential
1266 @param entry Target device
1267 @param properties Property list
1269 Determine whether the subject identified by the credential can set
1270 properties on an I/O Kit device.
1272 @return Return 0 if access is granted, or an appropriate value for
1273 errno should be returned.
1275 typedef int mpo_iokit_check_set_properties_t(
1278 io_object_t properties
1281 @brief Indicate desire to filter I/O Kit devices properties
1282 @param cred Subject credential
1283 @param entry Target device
1284 @see mpo_iokit_check_get_property_t
1286 Indicate whether this policy may restrict the subject credential
1287 from reading properties of the target device.
1288 If a policy returns success from this entry point, the
1289 mpo_iokit_check_get_property entry point will later be called
1290 for each property that the subject credential tries to read from
1293 This entry point is primarilly to optimize bulk property reads
1294 by skipping calls to the mpo_iokit_check_get_property entry point
1295 for credentials / devices no MAC policy is interested in.
1297 @warning Even if a policy returns 0, it should behave correctly in
1298 the presence of an invocation of mpo_iokit_check_get_property, as that
1299 call may happen as a result of another policy requesting a transition.
1301 @return Non-zero if a transition is required, 0 otherwise.
1303 typedef int mpo_iokit_check_filter_properties_t(
1308 @brief Access control check for getting I/O Kit device properties
1309 @param cred Subject credential
1310 @param entry Target device
1311 @param name Property name
1313 Determine whether the subject identified by the credential can get
1314 properties on an I/O Kit device.
1316 @return Return 0 if access is granted, or an appropriate value for
1319 typedef int mpo_iokit_check_get_property_t(
1325 @brief Access control check for software HID control
1326 @param cred Subject credential
1328 Determine whether the subject identified by the credential can
1329 control the HID (Human Interface Device) subsystem, such as to
1330 post synthetic keypresses, pointer movement and clicks.
1332 @return Return 0 if access is granted, or an appropriate value for
1335 typedef int mpo_iokit_check_hid_control_t(
1339 @brief Create an IP reassembly queue label
1340 @param fragment First received IP fragment
1341 @param fragmentlabel Policy label for fragment
1342 @param ipq IP reassembly queue to be labeled
1343 @param ipqlabel Policy label to be filled in for ipq
1345 Set the label on a newly created IP reassembly queue from
1346 the mbuf header of the first received fragment.
1348 typedef void mpo_ipq_label_associate_t(
1349 struct mbuf
*fragment
,
1350 struct label
*fragmentlabel
,
1352 struct label
*ipqlabel
1355 @brief Compare an mbuf header label to an ipq label
1356 @param fragment IP datagram fragment
1357 @param fragmentlabel Policy label for fragment
1358 @param ipq IP fragment reassembly queue
1359 @param ipqlabel Policy label for ipq
1361 Compare the label of the mbuf header containing an IP datagram
1362 (fragment) fragment with the label of the passed IP fragment
1363 reassembly queue (ipq). Return (1) for a successful match, or (0)
1364 for no match. This call is made when the IP stack attempts to
1365 find an existing fragment reassembly queue for a newly received
1366 fragment; if this fails, a new fragment reassembly queue may be
1367 instantiated for the fragment. Policies may use this entry point
1368 to prevent the reassembly of otherwise matching IP fragments if
1369 policy does not permit them to be reassembled based on the label
1370 or other information.
1372 typedef int mpo_ipq_label_compare_t(
1373 struct mbuf
*fragment
,
1374 struct label
*fragmentlabel
,
1376 struct label
*ipqlabel
1379 @brief Destroy IP reassembly queue label
1380 @param label The label to be destroyed
1382 Destroy the label on an IP fragment queue. In this entry point, a
1383 policy module should free any internal storage associated with
1384 label so that it may be destroyed.
1386 typedef void mpo_ipq_label_destroy_t(
1390 @brief Initialize IP reassembly queue label
1391 @param label New label to initialize
1392 @param flag M_WAITOK or M_NOWAIT
1394 Initialize the label on a newly instantiated IP fragment reassembly
1395 queue. The flag field may be one of M_WAITOK and M_NOWAIT, and
1396 should be employed to avoid performing a sleeping malloc(9) during
1397 this initialization call. IP fragment reassembly queue allocation
1398 frequently occurs in performance sensitive environments, and the
1399 implementation should be careful to avoid sleeping or long-lived
1400 operations. This entry point is permitted to fail resulting in
1401 the failure to allocate the IP fragment reassembly queue.
1403 typedef int mpo_ipq_label_init_t(
1404 struct label
*label
,
1408 @brief Update the label on an IP fragment reassembly queue
1409 @param fragment IP fragment
1410 @param fragmentlabel Policy label for fragment
1411 @param ipq IP fragment reassembly queue
1412 @param ipqlabel Policy label to be updated for ipq
1414 Update the label on an IP fragment reassembly queue (ipq) based
1415 on the acceptance of the passed IP fragment mbuf header (fragment).
1417 typedef void mpo_ipq_label_update_t(
1418 struct mbuf
*fragment
,
1419 struct label
*fragmentlabel
,
1421 struct label
*ipqlabel
1424 @brief Assign a label to a new mbuf
1425 @param bpf_d BPF descriptor
1426 @param b_label Policy label for bpf_d
1427 @param m Object; mbuf
1428 @param m_label Policy label to fill in for m
1430 Set the label on the mbuf header of a newly created datagram
1431 generated using the passed BPF descriptor. This call is made when
1432 a write is performed to the BPF device associated with the passed
1435 typedef void mpo_mbuf_label_associate_bpfdesc_t(
1436 struct bpf_d
*bpf_d
,
1437 struct label
*b_label
,
1439 struct label
*m_label
1442 @brief Assign a label to a new mbuf
1443 @param ifp Interface descriptor
1444 @param i_label Existing label of ifp
1445 @param m Object; mbuf
1446 @param m_label Policy label to fill in for m
1448 Label an mbuf based on the interface from which it was received.
1450 typedef void mpo_mbuf_label_associate_ifnet_t(
1452 struct label
*i_label
,
1454 struct label
*m_label
1457 @brief Assign a label to a new mbuf
1458 @param inp inpcb structure
1459 @param i_label Existing label of inp
1460 @param m Object; mbuf
1461 @param m_label Policy label to fill in for m
1463 Label an mbuf based on the inpcb from which it was derived.
1465 typedef void mpo_mbuf_label_associate_inpcb_t(
1467 struct label
*i_label
,
1469 struct label
*m_label
1472 @brief Set the label on a newly reassembled IP datagram
1473 @param ipq IP fragment reassembly queue
1474 @param ipqlabel Policy label for ipq
1475 @param mbuf IP datagram to be labeled
1476 @param mbuflabel Policy label to be filled in for mbuf
1478 Set the label on a newly reassembled IP datagram (mbuf) from the IP
1479 fragment reassembly queue (ipq) from which it was generated.
1481 typedef void mpo_mbuf_label_associate_ipq_t(
1483 struct label
*ipqlabel
,
1485 struct label
*mbuflabel
1488 @brief Assign a label to a new mbuf
1489 @param ifp Subject; network interface
1490 @param i_label Existing label of ifp
1491 @param m Object; mbuf
1492 @param m_label Policy label to fill in for m
1494 Set the label on the mbuf header of a newly created datagram
1495 generated for the purposes of a link layer response for the passed
1496 interface. This call may be made in a number of situations, including
1497 for ARP or ND6 responses in the IPv4 and IPv6 stacks.
1499 typedef void mpo_mbuf_label_associate_linklayer_t(
1501 struct label
*i_label
,
1503 struct label
*m_label
1506 @brief Assign a label to a new mbuf
1507 @param oldmbuf mbuf headerder for existing datagram for existing datagram
1508 @param oldmbuflabel Policy label for oldmbuf
1509 @param ifp Network interface
1510 @param ifplabel Policy label for ifp
1511 @param newmbuf mbuf header to be labeled for new datagram
1512 @param newmbuflabel Policy label for newmbuf
1514 Set the label on the mbuf header of a newly created datagram
1515 generated from the existing passed datagram when it is processed
1516 by the passed multicast encapsulation interface. This call is made
1517 when an mbuf is to be delivered using the virtual interface.
1519 typedef void mpo_mbuf_label_associate_multicast_encap_t(
1520 struct mbuf
*oldmbuf
,
1521 struct label
*oldmbuflabel
,
1523 struct label
*ifplabel
,
1524 struct mbuf
*newmbuf
,
1525 struct label
*newmbuflabel
1528 @brief Assign a label to a new mbuf
1529 @param oldmbuf Received datagram
1530 @param oldmbuflabel Policy label for oldmbuf
1531 @param newmbuf Newly created datagram
1532 @param newmbuflabel Policy label for newmbuf
1534 Set the label on the mbuf header of a newly created datagram generated
1535 by the IP stack in response to an existing received datagram (oldmbuf).
1536 This call may be made in a number of situations, including when responding
1537 to ICMP request datagrams.
1539 typedef void mpo_mbuf_label_associate_netlayer_t(
1540 struct mbuf
*oldmbuf
,
1541 struct label
*oldmbuflabel
,
1542 struct mbuf
*newmbuf
,
1543 struct label
*newmbuflabel
1546 @brief Assign a label to a new mbuf
1547 @param so Socket to label
1548 @param so_label Policy label for socket
1549 @param m Object; mbuf
1550 @param m_label Policy label to fill in for m
1552 An mbuf structure is used to store network traffic in transit.
1553 When an application sends data to a socket or a pipe, it is wrapped
1554 in an mbuf first. This function sets the label on a newly created mbuf header
1555 based on the socket sending the data. The contents of the label should be
1556 suitable for performing an access check on the receiving side of the
1559 Only labeled MBUFs will be presented to the policy via this entrypoint.
1561 typedef void mpo_mbuf_label_associate_socket_t(
1563 struct label
*so_label
,
1565 struct label
*m_label
1568 @brief Copy a mbuf label
1569 @param src Source label
1570 @param dest Destination label
1572 Copy the mbuf label information in src into dest.
1574 Only called when both source and destination mbufs have labels.
1576 typedef void mpo_mbuf_label_copy_t(
1581 @brief Destroy mbuf label
1582 @param label The label to be destroyed
1584 Destroy a mbuf label. Since the
1585 object is going out of scope, policy modules should free any
1586 internal storage associated with the label so that it may be
1589 typedef void mpo_mbuf_label_destroy_t(
1593 @brief Initialize mbuf label
1594 @param label New label to initialize
1595 @param flag Malloc flags
1597 Initialize the label for a newly instantiated mbuf.
1599 @warning Since it is possible for the flags to be set to
1600 M_NOWAIT, the malloc operation may fail.
1602 @return On success, 0, otherwise, an appropriate errno return value.
1604 typedef int mpo_mbuf_label_init_t(
1605 struct label
*label
,
1609 @brief Access control check for fsctl
1610 @param cred Subject credential
1611 @param mp The mount point
1612 @param label Label associated with the mount point
1613 @param com Filesystem-dependent request code; see fsctl(2)
1615 Determine whether the subject identified by the credential can perform
1616 the volume operation indicated by com.
1618 @warning The fsctl() system call is directly analogous to ioctl(); since
1619 the associated data is opaque from the standpoint of the MAC framework
1620 and since these operations can affect many aspects of system operation,
1621 policies must exercise extreme care when implementing access control checks.
1623 @return Return 0 if access is granted, otherwise an appropriate value for
1624 errno should be returned.
1626 typedef int mpo_mount_check_fsctl_t(
1629 struct label
*label
,
1633 @brief Access control check for the retrieval of file system attributes
1634 @param cred Subject credential
1635 @param mp The mount structure of the file system
1636 @param vfa The attributes requested
1638 This entry point determines whether given subject can get information
1639 about the given file system. This check happens during statfs() syscalls,
1640 but is also used by other parts within the kernel such as the audit system.
1642 @return Return 0 if access is granted, otherwise an appropriate value for
1643 errno should be returned.
1646 typedef int mpo_mount_check_getattr_t(
1649 struct label
*mp_label
,
1650 struct vfs_attr
*vfa
1653 @brief Access control check for mount point relabeling
1654 @param cred Subject credential
1655 @param mp Object file system mount point
1656 @param mntlabel Policy label for fle system mount point
1658 Determine whether the subject identified by the credential can relabel
1659 the mount point. This call is made when a file system mount is updated.
1661 @return Return 0 if access is granted, otherwise an appropriate value for
1662 errno should be returned. Suggested failure: EACCES for label mismatch
1663 or EPERM for lack of privilege.
1665 typedef int mpo_mount_check_label_update_t(
1668 struct label
*mntlabel
1671 @brief Access control check for mounting a file system
1672 @param cred Subject credential
1673 @param vp Vnode that is to be the mount point
1674 @param vlabel Label associated with the vnode
1675 @param cnp Component name for vp
1676 @param vfc_name Filesystem type name
1678 Determine whether the subject identified by the credential can perform
1679 the mount operation on the target vnode.
1681 @return Return 0 if access is granted, otherwise an appropriate value for
1682 errno should be returned.
1684 typedef int mpo_mount_check_mount_t(
1687 struct label
*vlabel
,
1688 struct componentname
*cnp
,
1689 const char *vfc_name
1692 @brief Access control check remounting a filesystem
1693 @param cred Subject credential
1694 @param mp The mount point
1695 @param mlabel Label currently associated with the mount point
1697 Determine whether the subject identified by the credential can perform
1698 the remount operation on the target vnode.
1700 @return Return 0 if access is granted, otherwise an appropriate value for
1701 errno should be returned.
1703 typedef int mpo_mount_check_remount_t(
1706 struct label
*mlabel
1709 @brief Access control check for the settting of file system attributes
1710 @param cred Subject credential
1711 @param mp The mount structure of the file system
1712 @param vfa The attributes requested
1714 This entry point determines whether given subject can set information
1715 about the given file system, for example the volume name.
1717 @return Return 0 if access is granted, otherwise an appropriate value for
1718 errno should be returned.
1721 typedef int mpo_mount_check_setattr_t(
1724 struct label
*mp_label
,
1725 struct vfs_attr
*vfa
1728 @brief Access control check for file system statistics
1729 @param cred Subject credential
1730 @param mp Object file system mount
1731 @param mntlabel Policy label for mp
1733 Determine whether the subject identified by the credential can see
1734 the results of a statfs performed on the file system. This call may
1735 be made in a number of situations, including during invocations of
1736 statfs(2) and related calls, as well as to determine what file systems
1737 to exclude from listings of file systems, such as when getfsstat(2)
1740 @return Return 0 if access is granted, otherwise an appropriate value for
1741 errno should be returned. Suggested failure: EACCES for label mismatch
1742 or EPERM for lack of privilege.
1744 typedef int mpo_mount_check_stat_t(
1747 struct label
*mntlabel
1750 @brief Access control check for unmounting a filesystem
1751 @param cred Subject credential
1752 @param mp The mount point
1753 @param mlabel Label associated with the mount point
1755 Determine whether the subject identified by the credential can perform
1756 the unmount operation on the target vnode.
1758 @return Return 0 if access is granted, otherwise an appropriate value for
1759 errno should be returned.
1761 typedef int mpo_mount_check_umount_t(
1764 struct label
*mlabel
1767 @brief Create mount labels
1768 @param cred Subject credential
1769 @param mp Mount point of file system being mounted
1770 @param mntlabel Label to associate with the new mount point
1771 @see mpo_mount_label_init_t
1773 Fill out the labels on the mount point being created by the supplied
1774 user credential. This call is made when file systems are first mounted.
1776 typedef void mpo_mount_label_associate_t(
1779 struct label
*mntlabel
1782 @brief Destroy mount label
1783 @param label The label to be destroyed
1785 Destroy a file system mount label. Since the
1786 object is going out of scope, policy modules should free any
1787 internal storage associated with the label so that it may be
1790 typedef void mpo_mount_label_destroy_t(
1794 @brief Externalize a mount point label
1795 @param label Label to be externalized
1796 @param element_name Name of the label namespace for which labels should be
1798 @param sb String buffer to be filled with a text representation of the label
1800 Produce an external representation of the mount point label. An
1801 externalized label consists of a text representation of the label
1802 contents that can be used with user applications. Policy-agnostic
1803 user space tools will display this externalized version.
1805 The policy's externalize entry points will be called only if the
1806 policy has registered interest in the label namespace.
1808 @return 0 on success, return non-zero if an error occurs while
1809 externalizing the label data.
1812 typedef int mpo_mount_label_externalize_t(
1813 struct label
*label
,
1818 @brief Initialize mount point label
1819 @param label New label to initialize
1821 Initialize the label for a newly instantiated mount structure.
1822 This label is typically used to store a default label in the case
1823 that the file system has been mounted singlelabel. Since some
1824 file systems do not support persistent labels (extended attributes)
1825 or are read-only (such as CD-ROMs), it is often necessary to store
1826 a default label separately from the label of the mount point
1827 itself. Sleeping is permitted.
1829 typedef void mpo_mount_label_init_t(
1833 @brief Internalize a mount point label
1834 @param label Label to be internalized
1835 @param element_name Name of the label namespace for which the label should
1837 @param element_data Text data to be internalized
1839 Produce a mount point file system label from an external representation.
1840 An externalized label consists of a text representation of the label
1841 contents that can be used with user applications. Policy-agnostic
1842 user space tools will forward text version to the kernel for
1843 processing by individual policy modules.
1845 The policy's internalize entry points will be called only if the
1846 policy has registered interest in the label namespace.
1848 @return 0 on success, Otherwise, return non-zero if an error occurs
1849 while internalizing the label data.
1852 typedef int mpo_mount_label_internalize_t(
1853 struct label
*label
,
1858 @brief Set the label on an IPv4 datagram fragment
1859 @param datagram Datagram being fragmented
1860 @param datagramlabel Policy label for datagram
1861 @param fragment New fragment
1862 @param fragmentlabel Policy label for fragment
1864 Called when an IPv4 datagram is fragmented into several smaller datagrams.
1865 Policies implementing mbuf labels will typically copy the label from the
1866 source datagram to the new fragment.
1868 typedef void mpo_netinet_fragment_t(
1869 struct mbuf
*datagram
,
1870 struct label
*datagramlabel
,
1871 struct mbuf
*fragment
,
1872 struct label
*fragmentlabel
1875 @brief Set the label on an ICMP reply
1876 @param m mbuf containing the ICMP reply
1877 @param mlabel Policy label for m
1879 A policy may wish to update the label of an mbuf that refers to
1880 an ICMP packet being sent in response to an IP packet. This may
1881 be called in response to a bad packet or an ICMP request.
1883 typedef void mpo_netinet_icmp_reply_t(
1885 struct label
*mlabel
1888 @brief Set the label on a TCP reply
1889 @param m mbuf containing the TCP reply
1890 @param mlabel Policy label for m
1892 Called for outgoing TCP packets not associated with an actual socket.
1894 typedef void mpo_netinet_tcp_reply_t(
1896 struct label
*mlabel
1899 @brief Access control check for pipe ioctl
1900 @param cred Subject credential
1901 @param cpipe Object to be accessed
1902 @param pipelabel The label on the pipe
1903 @param cmd The ioctl command; see ioctl(2)
1905 Determine whether the subject identified by the credential can perform
1906 the ioctl operation indicated by cmd.
1908 @warning Since ioctl data is opaque from the standpoint of the MAC
1909 framework, policies must exercise extreme care when implementing
1910 access control checks.
1912 @return Return 0 if access is granted, otherwise an appropriate value for
1913 errno should be returned.
1916 typedef int mpo_pipe_check_ioctl_t(
1919 struct label
*pipelabel
,
1923 @brief Access control check for pipe kqfilter
1924 @param cred Subject credential
1925 @param kn Object knote
1926 @param cpipe Object to be accessed
1927 @param pipelabel Policy label for the pipe
1929 Determine whether the subject identified by the credential can
1930 receive the knote on the passed pipe.
1932 @return Return 0 if access if granted, otherwise an appropriate
1933 value for errno should be returned.
1935 typedef int mpo_pipe_check_kqfilter_t(
1939 struct label
*pipelabel
1942 @brief Access control check for pipe relabel
1943 @param cred Subject credential
1944 @param cpipe Object to be accessed
1945 @param pipelabel The current label on the pipe
1946 @param newlabel The new label to be used
1948 Determine whether the subject identified by the credential can
1949 perform a relabel operation on the passed pipe. The cred object holds
1950 the credentials of the subject performing the operation.
1952 @return Return 0 if access is granted, otherwise an appropriate value for
1953 errno should be returned.
1956 typedef int mpo_pipe_check_label_update_t(
1959 struct label
*pipelabel
,
1960 struct label
*newlabel
1963 @brief Access control check for pipe read
1964 @param cred Subject credential
1965 @param cpipe Object to be accessed
1966 @param pipelabel The label on the pipe
1968 Determine whether the subject identified by the credential can
1969 perform a read operation on the passed pipe. The cred object holds
1970 the credentials of the subject performing the operation.
1972 @return Return 0 if access is granted, otherwise an appropriate value for
1973 errno should be returned.
1976 typedef int mpo_pipe_check_read_t(
1979 struct label
*pipelabel
1982 @brief Access control check for pipe select
1983 @param cred Subject credential
1984 @param cpipe Object to be accessed
1985 @param pipelabel The label on the pipe
1986 @param which The operation selected on: FREAD or FWRITE
1988 Determine whether the subject identified by the credential can
1989 perform a select operation on the passed pipe. The cred object holds
1990 the credentials of the subject performing the operation.
1992 @return Return 0 if access is granted, otherwise an appropriate value for
1993 errno should be returned.
1996 typedef int mpo_pipe_check_select_t(
1999 struct label
*pipelabel
,
2003 @brief Access control check for pipe stat
2004 @param cred Subject credential
2005 @param cpipe Object to be accessed
2006 @param pipelabel The label on the pipe
2008 Determine whether the subject identified by the credential can
2009 perform a stat operation on the passed pipe. The cred object holds
2010 the credentials of the subject performing the operation.
2012 @return Return 0 if access is granted, otherwise an appropriate value for
2013 errno should be returned.
2016 typedef int mpo_pipe_check_stat_t(
2019 struct label
*pipelabel
2022 @brief Access control check for pipe write
2023 @param cred Subject credential
2024 @param cpipe Object to be accessed
2025 @param pipelabel The label on the pipe
2027 Determine whether the subject identified by the credential can
2028 perform a write operation on the passed pipe. The cred object holds
2029 the credentials of the subject performing the operation.
2031 @return Return 0 if access is granted, otherwise an appropriate value for
2032 errno should be returned.
2035 typedef int mpo_pipe_check_write_t(
2038 struct label
*pipelabel
2041 @brief Create a pipe label
2042 @param cred Subject credential
2043 @param cpipe object to be labeled
2044 @param label Label for the pipe object
2046 Create a label for the pipe object being created by the supplied
2047 user credential. This call is made when the pipe is being created
2048 XXXPIPE(for one or both sides of the pipe?).
2051 typedef void mpo_pipe_label_associate_t(
2054 struct label
*pipelabel
2057 @brief Copy a pipe label
2058 @param src Source pipe label
2059 @param dest Destination pipe label
2061 Copy the pipe label associated with src to dest.
2062 XXXPIPE Describe when this is used: most likely during pipe creation to
2063 copy from rpipe to wpipe.
2065 typedef void mpo_pipe_label_copy_t(
2070 @brief Destroy pipe label
2071 @param label The label to be destroyed
2073 Destroy a pipe label. Since the object is going out of scope,
2074 policy modules should free any internal storage associated with the
2075 label so that it may be destroyed.
2077 typedef void mpo_pipe_label_destroy_t(
2081 @brief Externalize a pipe label
2082 @param label Label to be externalized
2083 @param element_name Name of the label namespace for which labels should be
2085 @param sb String buffer to be filled with a text representation of the label
2087 Produce an external representation of the label on a pipe.
2088 An externalized label consists of a text representation
2089 of the label contents that can be used with user applications.
2090 Policy-agnostic user space tools will display this externalized
2093 The policy's externalize entry points will be called only if the
2094 policy has registered interest in the label namespace.
2096 @return 0 on success, return non-zero if an error occurs while
2097 externalizing the label data.
2100 typedef int mpo_pipe_label_externalize_t(
2101 struct label
*label
,
2106 @brief Initialize pipe label
2107 @param label New label to initialize
2109 Initialize label storage for use with a newly instantiated pipe object.
2110 Sleeping is permitted.
2112 typedef void mpo_pipe_label_init_t(
2116 @brief Internalize a pipe label
2117 @param label Label to be internalized
2118 @param element_name Name of the label namespace for which the label should
2120 @param element_data Text data to be internalized
2122 Produce a pipe label from an external representation. An
2123 externalized label consists of a text representation of the label
2124 contents that can be used with user applications. Policy-agnostic
2125 user space tools will forward text version to the kernel for
2126 processing by individual policy modules.
2128 The policy's internalize entry points will be called only if the
2129 policy has registered interest in the label namespace.
2131 @return 0 on success, Otherwise, return non-zero if an error occurs
2132 while internalizing the label data.
2135 typedef int mpo_pipe_label_internalize_t(
2136 struct label
*label
,
2141 @brief Update a pipe label
2142 @param cred Subject credential
2143 @param cpipe Object to be labeled
2144 @param oldlabel Existing pipe label
2145 @param newlabel New label to replace existing label
2146 @see mpo_pipe_check_label_update_t
2148 The subject identified by the credential has previously requested
2149 and was authorized to relabel the pipe; this entry point allows
2150 policies to perform the actual relabel operation. Policies should
2151 update oldlabel using the label stored in the newlabel parameter.
2154 typedef void mpo_pipe_label_update_t(
2157 struct label
*oldlabel
,
2158 struct label
*newlabel
2161 @brief Policy unload event
2162 @param mpc MAC policy configuration
2164 This is the MAC Framework policy unload event. This entry point will
2165 only be called if the module's policy configuration allows unload (if
2166 the MPC_LOADTIME_FLAG_UNLOADOK is set). Most security policies won't
2167 want to be unloaded; they should set their flags to prevent this
2168 entry point from being called.
2170 @warning During this call, the mac policy list mutex is held, so
2171 sleep operations cannot be performed, and calls out to other kernel
2172 subsystems must be made with caution.
2174 @see MPC_LOADTIME_FLAG_UNLOADOK
2176 typedef void mpo_policy_destroy_t(
2177 struct mac_policy_conf
*mpc
2180 @brief Policy initialization event
2181 @param mpc MAC policy configuration
2182 @see mac_policy_register
2183 @see mpo_policy_initbsd_t
2185 This is the MAC Framework policy initialization event. This entry
2186 point is called during mac_policy_register, when the policy module
2187 is first registered with the MAC Framework. This is often done very
2188 early in the boot process, after the kernel Mach subsystem has been
2189 initialized, but prior to the BSD subsystem being initialized.
2190 Since the kernel BSD services are not yet available, it is possible
2191 that some initialization must occur later, possibly in the
2192 mpo_policy_initbsd_t policy entry point, such as registering BSD system
2193 controls (sysctls). Policy modules loaded at boot time will be
2194 registered and initialized before labeled Mach objects are created.
2196 @warning During this call, the mac policy list mutex is held, so
2197 sleep operations cannot be performed, and calls out to other kernel
2198 subsystems must be made with caution.
2200 typedef void mpo_policy_init_t(
2201 struct mac_policy_conf
*mpc
2204 @brief Policy BSD initialization event
2205 @param mpc MAC policy configuration
2206 @see mpo_policy_init_t
2208 This entry point is called after the kernel BSD subsystem has been
2209 initialized. By this point, the module should already be loaded,
2210 registered, and initialized. Since policy modules are initialized
2211 before kernel BSD services are available, this second initialization
2212 phase is necessary. At this point, BSD services (memory management,
2213 synchronization primitives, vfs, etc.) are available, but the first
2214 process has not yet been created. Mach-related objects and tasks
2215 will already be fully initialized and may be in use--policies requiring
2216 ubiquitous labeling may also want to implement mpo_policy_init_t.
2218 @warning During this call, the mac policy list mutex is held, so
2219 sleep operations cannot be performed, and calls out to other kernel
2220 subsystems must be made with caution.
2222 typedef void mpo_policy_initbsd_t(
2223 struct mac_policy_conf
*mpc
2226 @brief Policy extension service
2227 @param p Calling process
2228 @param call Policy-specific syscall number
2229 @param arg Pointer to syscall arguments
2231 This entry point provides a policy-multiplexed system call so that
2232 policies may provide additional services to user processes without
2233 registering specific system calls. The policy name provided during
2234 registration is used to demux calls from userland, and the arguments
2235 will be forwarded to this entry point. When implementing new
2236 services, security modules should be sure to invoke appropriate
2237 access control checks from the MAC framework as needed. For
2238 example, if a policy implements an augmented signal functionality,
2239 it should call the necessary signal access control checks to invoke
2240 the MAC framework and other registered policies.
2242 @warning Since the format and contents of the policy-specific
2243 arguments are unknown to the MAC Framework, modules must perform the
2244 required copyin() of the syscall data on their own. No policy
2245 mediation is performed, so policies must perform any necessary
2246 access control checks themselves. If multiple policies are loaded,
2247 they will currently be unable to mediate calls to other policies.
2249 @return In the event of an error, an appropriate value for errno
2250 should be returned, otherwise return 0 upon success.
2252 typedef int mpo_policy_syscall_t(
2258 @brief Access control check for POSIX semaphore create
2259 @param cred Subject credential
2260 @param name String name of the semaphore
2262 Determine whether the subject identified by the credential can create
2263 a POSIX semaphore specified by name.
2265 @return Return 0 if access is granted, otherwise an appropriate value for
2266 errno should be returned.
2268 typedef int mpo_posixsem_check_create_t(
2273 @brief Access control check for POSIX semaphore open
2274 @param cred Subject credential
2275 @param ps Pointer to semaphore information structure
2276 @param semlabel Label associated with the semaphore
2278 Determine whether the subject identified by the credential can open
2279 the named POSIX semaphore with label semlabel.
2281 @return Return 0 if access is granted, otherwise an appropriate value for
2282 errno should be returned.
2284 typedef int mpo_posixsem_check_open_t(
2286 struct pseminfo
*ps
,
2287 struct label
*semlabel
2290 @brief Access control check for POSIX semaphore post
2291 @param cred Subject credential
2292 @param ps Pointer to semaphore information structure
2293 @param semlabel Label associated with the semaphore
2295 Determine whether the subject identified by the credential can unlock
2296 the named POSIX semaphore with label semlabel.
2298 @return Return 0 if access is granted, otherwise an appropriate value for
2299 errno should be returned.
2301 typedef int mpo_posixsem_check_post_t(
2303 struct pseminfo
*ps
,
2304 struct label
*semlabel
2307 @brief Access control check for POSIX semaphore unlink
2308 @param cred Subject credential
2309 @param ps Pointer to semaphore information structure
2310 @param semlabel Label associated with the semaphore
2311 @param name String name of the semaphore
2313 Determine whether the subject identified by the credential can remove
2314 the named POSIX semaphore with label semlabel.
2316 @return Return 0 if access is granted, otherwise an appropriate value for
2317 errno should be returned.
2319 typedef int mpo_posixsem_check_unlink_t(
2321 struct pseminfo
*ps
,
2322 struct label
*semlabel
,
2326 @brief Access control check for POSIX semaphore wait
2327 @param cred Subject credential
2328 @param ps Pointer to semaphore information structure
2329 @param semlabel Label associated with the semaphore
2331 Determine whether the subject identified by the credential can lock
2332 the named POSIX semaphore with label semlabel.
2334 @return Return 0 if access is granted, otherwise an appropriate value for
2335 errno should be returned.
2337 typedef int mpo_posixsem_check_wait_t(
2339 struct pseminfo
*ps
,
2340 struct label
*semlabel
2343 @brief Create a POSIX semaphore label
2344 @param cred Subject credential
2345 @param ps Pointer to semaphore information structure
2346 @param semlabel Label to associate with the new semaphore
2347 @param name String name of the semaphore
2349 Label a new POSIX semaphore. The label was previously
2350 initialized and associated with the semaphore. At this time, an
2351 appropriate initial label value should be assigned to the object and
2352 stored in semalabel.
2354 typedef void mpo_posixsem_label_associate_t(
2356 struct pseminfo
*ps
,
2357 struct label
*semlabel
,
2361 @brief Destroy POSIX semaphore label
2362 @param label The label to be destroyed
2364 Destroy a POSIX semaphore label. Since the object is
2365 going out of scope, policy modules should free any internal storage
2366 associated with the label so that it may be destroyed.
2368 typedef void mpo_posixsem_label_destroy_t(
2372 @brief Initialize POSIX semaphore label
2373 @param label New label to initialize
2375 Initialize the label for a newly instantiated POSIX semaphore. Sleeping
2378 typedef void mpo_posixsem_label_init_t(
2382 @brief Access control check for POSIX shared memory region create
2383 @param cred Subject credential
2384 @param name String name of the shared memory region
2386 Determine whether the subject identified by the credential can create
2387 the POSIX shared memory region referenced by name.
2389 @return Return 0 if access is granted, otherwise an appropriate value for
2390 errno should be returned.
2392 typedef int mpo_posixshm_check_create_t(
2397 @brief Access control check for mapping POSIX shared memory
2398 @param cred Subject credential
2399 @param ps Pointer to shared memory information structure
2400 @param shmlabel Label associated with the shared memory region
2401 @param prot mmap protections; see mmap(2)
2402 @param flags shmat flags; see shmat(2)
2404 Determine whether the subject identified by the credential can map
2405 the POSIX shared memory segment associated with shmlabel.
2407 @return Return 0 if access is granted, otherwise an appropriate value for
2408 errno should be returned.
2410 typedef int mpo_posixshm_check_mmap_t(
2412 struct pshminfo
*ps
,
2413 struct label
*shmlabel
,
2418 @brief Access control check for POSIX shared memory region open
2419 @param cred Subject credential
2420 @param ps Pointer to shared memory information structure
2421 @param shmlabel Label associated with the shared memory region
2422 @param fflags shm_open(2) open flags ('fflags' encoded)
2424 Determine whether the subject identified by the credential can open
2425 the POSIX shared memory region.
2427 @return Return 0 if access is granted, otherwise an appropriate value for
2428 errno should be returned.
2430 typedef int mpo_posixshm_check_open_t(
2432 struct pshminfo
*ps
,
2433 struct label
*shmlabel
,
2437 @brief Access control check for POSIX shared memory stat
2438 @param cred Subject credential
2439 @param ps Pointer to shared memory information structure
2440 @param shmlabel Label associated with the shared memory region
2442 Determine whether the subject identified by the credential can obtain
2443 status for the POSIX shared memory segment associated with shmlabel.
2445 @return Return 0 if access is granted, otherwise an appropriate value for
2446 errno should be returned.
2448 typedef int mpo_posixshm_check_stat_t(
2450 struct pshminfo
*ps
,
2451 struct label
*shmlabel
2454 @brief Access control check for POSIX shared memory truncate
2455 @param cred Subject credential
2456 @param ps Pointer to shared memory information structure
2457 @param shmlabel Label associated with the shared memory region
2458 @param len Length to truncate or extend shared memory segment
2460 Determine whether the subject identified by the credential can truncate
2461 or extend (to len) the POSIX shared memory segment associated with shmlabel.
2463 @return Return 0 if access is granted, otherwise an appropriate value for
2464 errno should be returned.
2466 typedef int mpo_posixshm_check_truncate_t(
2468 struct pshminfo
*ps
,
2469 struct label
*shmlabel
,
2473 @brief Access control check for POSIX shared memory unlink
2474 @param cred Subject credential
2475 @param ps Pointer to shared memory information structure
2476 @param shmlabel Label associated with the shared memory region
2477 @param name String name of the shared memory region
2479 Determine whether the subject identified by the credential can delete
2480 the POSIX shared memory segment associated with shmlabel.
2482 @return Return 0 if access is granted, otherwise an appropriate value for
2483 errno should be returned.
2485 typedef int mpo_posixshm_check_unlink_t(
2487 struct pshminfo
*ps
,
2488 struct label
*shmlabel
,
2492 @brief Create a POSIX shared memory region label
2493 @param cred Subject credential
2494 @param ps Pointer to shared memory information structure
2495 @param shmlabel Label to associate with the new shared memory region
2496 @param name String name of the shared memory region
2498 Label a new POSIX shared memory region. The label was previously
2499 initialized and associated with the shared memory region. At this
2500 time, an appropriate initial label value should be assigned to the
2501 object and stored in shmlabel.
2503 typedef void mpo_posixshm_label_associate_t(
2505 struct pshminfo
*ps
,
2506 struct label
*shmlabel
,
2510 @brief Destroy POSIX shared memory label
2511 @param label The label to be destroyed
2513 Destroy a POSIX shared memory region label. Since the
2514 object is going out of scope, policy modules should free any
2515 internal storage associated with the label so that it may be
2518 typedef void mpo_posixshm_label_destroy_t(
2522 @brief Initialize POSIX Shared Memory region label
2523 @param label New label to initialize
2525 Initialize the label for newly a instantiated POSIX Shared Memory
2526 region. Sleeping is permitted.
2528 typedef void mpo_posixshm_label_init_t(
2532 @brief Access control check for privileged operations
2533 @param cred Subject credential
2534 @param priv Requested privilege (see sys/priv.h)
2536 Determine whether the subject identified by the credential can perform
2537 a privileged operation. Privileged operations are allowed if the cred
2538 is the superuser or any policy returns zero for mpo_priv_grant, unless
2539 any policy returns nonzero for mpo_priv_check.
2541 @return Return 0 if access is granted, otherwise EPERM should be returned.
2543 typedef int mpo_priv_check_t(
2548 @brief Grant regular users the ability to perform privileged operations
2549 @param cred Subject credential
2550 @param priv Requested privilege (see sys/priv.h)
2552 Determine whether the subject identified by the credential should be
2553 allowed to perform a privileged operation that in the absense of any
2554 MAC policy it would not be able to perform. Privileged operations are
2555 allowed if the cred is the superuser or any policy returns zero for
2556 mpo_priv_grant, unless any policy returns nonzero for mpo_priv_check.
2558 Unlike other MAC hooks which can only reduce the privilege of a
2559 credential, this hook raises the privilege of a credential when it
2560 returns 0. Extreme care must be taken when implementing this hook to
2561 avoid undermining the security of the system.
2563 @return Return 0 if additional privilege is granted, otherwise EPERM
2566 typedef int mpo_priv_grant_t(
2571 @brief Access control check for debugging process
2572 @param cred Subject credential
2573 @param proc Object process
2575 Determine whether the subject identified by the credential can debug
2576 the passed process. This call may be made in a number of situations,
2577 including use of the ptrace(2) and ktrace(2) APIs, as well as for some
2578 types of procfs operations.
2580 @return Return 0 if access is granted, otherwise an appropriate value for
2581 errno should be returned. Suggested failure: EACCES for label mismatch,
2582 EPERM for lack of privilege, or ESRCH to hide visibility of the target.
2584 typedef int mpo_proc_check_debug_t(
2589 @brief Access control over fork
2590 @param cred Subject credential
2591 @param proc Subject process trying to fork
2593 Determine whether the subject identified is allowed to fork.
2595 @return Return 0 if access is granted, otherwise an appropriate value for
2596 errno should be returned.
2598 typedef int mpo_proc_check_fork_t(
2603 @brief Access control check for setting host special ports.
2604 @param cred Subject credential
2605 @param id The host special port to set
2606 @param port The new value to set for the special port
2608 @return Return 0 if access is granted, otherwise an appropriate value for
2609 errno should be returned.
2611 typedef int mpo_proc_check_set_host_special_port_t(
2614 struct ipc_port
*port
2617 @brief Access control check for setting host exception ports.
2618 @param cred Subject credential
2619 @param exceptions Exception port to set
2621 @return Return 0 if access is granted, otherwise an appropriate value for
2622 errno should be returned.
2624 typedef int mpo_proc_check_set_host_exception_port_t(
2626 unsigned int exception
2629 @brief Access control over pid_suspend and pid_resume
2630 @param cred Subject credential
2631 @param proc Subject process trying to run pid_suspend or pid_resume
2632 @param sr Call is suspend (0) or resume (1)
2634 Determine whether the subject identified is allowed to suspend or resume
2637 @return Return 0 if access is granted, otherwise an appropriate value for
2638 errno should be returned.
2640 typedef int mpo_proc_check_suspend_resume_t(
2646 @brief Access control check for retrieving audit information
2647 @param cred Subject credential
2649 Determine whether the subject identified by the credential can get
2650 audit information such as the audit user ID, the preselection mask,
2651 the terminal ID and the audit session ID, using the getaudit() system call.
2653 @return Return 0 if access is granted, otherwise an appropriate value for
2654 errno should be returned.
2656 typedef int mpo_proc_check_getaudit_t(
2660 @brief Access control check for retrieving audit user ID
2661 @param cred Subject credential
2663 Determine whether the subject identified by the credential can get
2664 the user identity being used by the auditing system, using the getauid()
2667 @return Return 0 if access is granted, otherwise an appropriate value for
2668 errno should be returned.
2670 typedef int mpo_proc_check_getauid_t(
2674 @brief Access control check for retrieving Login Context ID
2675 @param p0 Calling process
2676 @param p Effected process
2677 @param pid syscall PID argument
2679 Determine if getlcid(2) system call is permitted.
2681 Information returned by this system call is similar to that returned via
2682 process listings etc.
2684 @return Return 0 if access is granted, otherwise an appropriate value for
2685 errno should be returned.
2687 typedef int mpo_proc_check_getlcid_t(
2693 @brief Access control check for retrieving ledger information
2694 @param cred Subject credential
2695 @param target Object process
2696 @param op ledger operation
2698 Determine if ledger(2) system call is permitted.
2700 Information returned by this system call is similar to that returned via
2701 process listings etc.
2703 @return Return 0 if access is granted, otherwise an appropriate value for
2704 errno should be returned.
2706 typedef int mpo_proc_check_ledger_t(
2708 struct proc
*target
,
2712 @brief Access control check for escaping default CPU usage monitor parameters.
2713 @param cred Subject credential
2715 Determine if a credential has permission to program CPU usage monitor parameters
2716 that are less restrictive than the global system-wide defaults.
2718 @return Return 0 if access is granted, otherwise an appropriate value for
2719 errno should be returned.
2721 typedef int mpo_proc_check_cpumon_t(
2725 @brief Access control check for retrieving process information.
2726 @param cred Subject credential
2727 @param target Target process (may be null, may be zombie)
2729 Determine if a credential has permission to access process information as defined
2730 by call number and flavor on target process
2732 @return Return 0 if access is granted, otherwise an appropriate value for
2733 errno should be returned.
2735 typedef int mpo_proc_check_proc_info_t(
2737 struct proc
*target
,
2742 @brief Access control check for retrieving code signing information.
2743 @param cred Subject credential
2744 @param target Target process
2745 @param op Code signing operation being performed
2747 Determine whether the subject identified by the credential should be
2748 allowed to get code signing information about the target process.
2750 @return Return 0 if access is granted, otherwise an appropriate value for
2751 errno should be returned.
2753 typedef int mpo_proc_check_get_cs_info_t(
2755 struct proc
*target
,
2759 @brief Access control check for setting code signing information.
2760 @param cred Subject credential
2761 @param target Target process
2762 @param op Code signing operation being performed.
2764 Determine whether the subject identified by the credential should be
2765 allowed to set code signing information about the target process.
2767 @return Return 0 if permission is granted, otherwise an appropriate
2768 value of errno should be returned.
2770 typedef int mpo_proc_check_set_cs_info_t(
2772 struct proc
*target
,
2776 @brief Access control check for mmap MAP_ANON
2777 @param proc User process requesting the memory
2778 @param cred Subject credential
2779 @param u_addr Start address of the memory range
2780 @param u_size Length address of the memory range
2781 @param prot mmap protections; see mmap(2)
2782 @param flags Type of mapped object; see mmap(2)
2783 @param maxprot Maximum rights
2785 Determine whether the subject identified by the credential should be
2786 allowed to obtain anonymous memory using the specified flags and
2787 protections on the new mapping. MAP_ANON will always be present in the
2788 flags. Certain combinations of flags with a non-NULL addr may
2789 cause a mapping to be rejected before this hook is called. The maxprot field
2790 holds the maximum permissions on the new mapping, a combination of
2791 VM_PROT_READ, VM_PROT_WRITE and VM_PROT_EXECUTE. To avoid overriding prior
2792 access control checks, a policy should only remove flags from maxprot.
2794 @return Return 0 if access is granted, otherwise an appropriate value for
2795 errno should be returned. Suggested failure: EPERM for lack of privilege.
2797 typedef int mpo_proc_check_map_anon_t(
2807 @brief Access control check for setting memory protections
2808 @param cred Subject credential
2809 @param proc User process requesting the change
2810 @param addr Start address of the memory range
2811 @param size Length address of the memory range
2812 @param prot Memory protections, see mmap(2)
2814 Determine whether the subject identified by the credential should
2815 be allowed to set the specified memory protections on memory mapped
2816 in the process proc.
2818 @return Return 0 if access is granted, otherwise an appropriate value for
2819 errno should be returned.
2821 typedef int mpo_proc_check_mprotect_t(
2829 @brief Access control check for changing scheduling parameters
2830 @param cred Subject credential
2831 @param proc Object process
2833 Determine whether the subject identified by the credential can change
2834 the scheduling parameters of the passed process.
2836 @return Return 0 if access is granted, otherwise an appropriate value for
2837 errno should be returned. Suggested failure: EACCES for label mismatch,
2838 EPERM for lack of privilege, or ESRCH to limit visibility.
2840 typedef int mpo_proc_check_sched_t(
2845 @brief Access control check for setting audit information
2846 @param cred Subject credential
2847 @param ai Audit information
2849 Determine whether the subject identified by the credential can set
2850 audit information such as the the preselection mask, the terminal ID
2851 and the audit session ID, using the setaudit() system call.
2853 @return Return 0 if access is granted, otherwise an appropriate value for
2854 errno should be returned.
2856 typedef int mpo_proc_check_setaudit_t(
2858 struct auditinfo_addr
*ai
2861 @brief Access control check for setting audit user ID
2862 @param cred Subject credential
2863 @param auid Audit user ID
2865 Determine whether the subject identified by the credential can set
2866 the user identity used by the auditing system, using the setauid()
2869 @return Return 0 if access is granted, otherwise an appropriate value for
2870 errno should be returned.
2872 typedef int mpo_proc_check_setauid_t(
2877 @brief Access control check for setting the Login Context
2878 @param p0 Calling process
2879 @param p Effected process
2880 @param pid syscall PID argument
2881 @param lcid syscall LCID argument
2883 Determine if setlcid(2) system call is permitted.
2885 See xnu/bsd/kern/kern_prot.c:setlcid() implementation for example of
2886 decoding syscall arguments to determine action desired by caller.
2888 Five distinct actions are possible: CREATE JOIN LEAVE ADOPT ORPHAN
2890 @return Return 0 if access is granted, otherwise an appropriate value for
2891 errno should be returned.
2893 typedef int mpo_proc_check_setlcid_t(
2900 @brief Access control check for delivering signal
2901 @param cred Subject credential
2902 @param proc Object process
2903 @param signum Signal number; see kill(2)
2905 Determine whether the subject identified by the credential can deliver
2906 the passed signal to the passed process.
2908 @warning Programs typically expect to be able to send and receive
2909 signals as part or their normal process lifecycle; caution should be
2910 exercised when implementing access controls over signal events.
2912 @return Return 0 if access is granted, otherwise an appropriate value for
2913 errno should be returned. Suggested failure: EACCES for label mismatch,
2914 EPERM for lack of privilege, or ESRCH to limit visibility.
2916 typedef int mpo_proc_check_signal_t(
2922 @brief Access control check for wait
2923 @param cred Subject credential
2924 @param proc Object process
2926 Determine whether the subject identified by the credential can wait
2927 for process termination.
2929 @warning Caution should be exercised when implementing access
2930 controls for wait, since programs often wait for child processes to
2931 exit. Failure to be notified of a child process terminating may
2932 cause the parent process to hang, or may produce zombie processes.
2934 @return Return 0 if access is granted, otherwise an appropriate value for
2935 errno should be returned.
2937 typedef int mpo_proc_check_wait_t(
2942 @brief Destroy process label
2943 @param label The label to be destroyed
2945 Destroy a process label. Since the object is going
2946 out of scope, policy modules should free any internal storage
2947 associated with the label so that it may be destroyed.
2949 typedef void mpo_proc_label_destroy_t(
2953 @brief Initialize process label
2954 @param label New label to initialize
2955 @see mpo_cred_label_init_t
2957 Initialize the label for a newly instantiated BSD process structure.
2958 Normally, security policies will store the process label in the user
2959 credential rather than here in the process structure. However,
2960 there are some floating label policies that may need to temporarily
2961 store a label in the process structure until it is safe to update
2962 the user credential label. Sleeping is permitted.
2964 typedef void mpo_proc_label_init_t(
2968 @brief Access control check for socket accept
2969 @param cred Subject credential
2970 @param socket Object socket
2971 @param socklabel Policy label for socket
2973 Determine whether the subject identified by the credential can accept()
2974 a new connection on the socket from the host specified by addr.
2976 @return Return 0 if access if granted, otherwise an appropriate
2977 value for errno should be returned.
2979 typedef int mpo_socket_check_accept_t(
2982 struct label
*socklabel
2985 @brief Access control check for a pending socket accept
2986 @param cred Subject credential
2987 @param so Object socket
2988 @param socklabel Policy label for socket
2989 @param addr Address of the listening socket (coming soon)
2991 Determine whether the subject identified by the credential can accept()
2992 a pending connection on the socket from the host specified by addr.
2994 @return Return 0 if access if granted, otherwise an appropriate
2995 value for errno should be returned.
2997 typedef int mpo_socket_check_accepted_t(
3000 struct label
*socklabel
,
3001 struct sockaddr
*addr
3004 @brief Access control check for socket bind
3005 @param cred Subject credential
3006 @param so Object socket
3007 @param socklabel Policy label for socket
3008 @param addr Name to assign to the socket
3010 Determine whether the subject identified by the credential can bind()
3011 the name (addr) to the socket.
3013 @return Return 0 if access if granted, otherwise an appropriate
3014 value for errno should be returned.
3016 typedef int mpo_socket_check_bind_t(
3019 struct label
*socklabel
,
3020 struct sockaddr
*addr
3023 @brief Access control check for socket connect
3024 @param cred Subject credential
3025 @param so Object socket
3026 @param socklabel Policy label for socket
3027 @param addr Name to assign to the socket
3029 Determine whether the subject identified by the credential can
3030 connect() the passed socket to the remote host specified by addr.
3032 @return Return 0 if access if granted, otherwise an appropriate
3033 value for errno should be returned.
3035 typedef int mpo_socket_check_connect_t(
3038 struct label
*socklabel
,
3039 struct sockaddr
*addr
3042 @brief Access control check for socket() system call.
3043 @param cred Subject credential
3044 @param domain communication domain
3045 @param type socket type
3046 @param protocol socket protocol
3048 Determine whether the subject identified by the credential can
3049 make the socket() call.
3051 @return Return 0 if access if granted, otherwise an appropriate
3052 value for errno should be returned.
3054 typedef int mpo_socket_check_create_t(
3061 @brief Access control check for delivering data to a user's receieve queue
3062 @param so The socket data is being delivered to
3063 @param so_label The label of so
3064 @param m The mbuf whose data will be deposited into the receive queue
3065 @param m_label The label of the sender of the data.
3067 A socket has a queue for receiving incoming data. When a packet arrives
3068 on the wire, it eventually gets deposited into this queue, which the
3069 owner of the socket drains when they read from the socket's file descriptor.
3071 This function determines whether the socket can receive data from
3072 the sender specified by m_label.
3074 @warning There is an outstanding design issue surrounding the placement
3075 of this function. The check must be placed either before or after the
3076 TCP sequence and ACK counters are updated. Placing the check before
3077 the counters are updated causes the incoming packet to be resent by
3078 the remote if the check rejects it. Placing the check after the counters
3079 are updated results in a completely silent drop. As far as each TCP stack
3080 is concerned the packet was received, however, the data will not be in the
3081 socket's receive queue. Another consideration is that the current design
3082 requires using the "failed label" occasionally. In that case, on rejection,
3083 we want the remote TCP to resend the data. Because of this, we chose to
3084 place this check before the counters are updated, so rejected packets will be
3085 resent by the remote host.
3087 If a policy keeps rejecting the same packet, eventually the connection will
3088 be dropped. Policies have several options if this design causes problems.
3089 For example, one options is to sanitize the mbuf such that it is acceptable,
3090 then accept it. That may require negotiation between policies as the
3091 Framework will not know to re-check the packet.
3093 The policy must handle NULL MBUF labels. This will likely be the case
3094 for non-local TCP sockets for example.
3096 @return Return 0 if access if granted, otherwise an appropriate
3097 value for errno should be returned.
3099 typedef int mpo_socket_check_deliver_t(
3101 struct label
*so_label
,
3103 struct label
*m_label
3106 @brief Access control check for socket kqfilter
3107 @param cred Subject credential
3108 @param kn Object knote
3109 @param so Object socket
3110 @param socklabel Policy label for socket
3112 Determine whether the subject identified by the credential can
3113 receive the knote on the passed socket.
3115 @return Return 0 if access if granted, otherwise an appropriate
3116 value for errno should be returned.
3118 typedef int mpo_socket_check_kqfilter_t(
3122 struct label
*socklabel
3125 @brief Access control check for socket relabel
3126 @param cred Subject credential
3127 @param so Object socket
3128 @param so_label The current label of so
3129 @param newlabel The label to be assigned to so
3131 Determine whether the subject identified by the credential can
3132 change the label on the socket.
3134 @return Return 0 if access if granted, otherwise an appropriate
3135 value for errno should be returned.
3137 typedef int mpo_socket_check_label_update_t(
3140 struct label
*so_label
,
3141 struct label
*newlabel
3144 @brief Access control check for socket listen
3145 @param cred Subject credential
3146 @param so Object socket
3147 @param socklabel Policy label for socket
3149 Determine whether the subject identified by the credential can
3150 listen() on the passed socket.
3152 @return Return 0 if access if granted, otherwise an appropriate
3153 value for errno should be returned.
3155 typedef int mpo_socket_check_listen_t(
3158 struct label
*socklabel
3161 @brief Access control check for socket receive
3162 @param cred Subject credential
3163 @param so Object socket
3164 @param socklabel Policy label for socket
3166 Determine whether the subject identified by the credential can
3167 receive data from the socket.
3169 @return Return 0 if access if granted, otherwise an appropriate
3170 value for errno should be returned.
3172 typedef int mpo_socket_check_receive_t(
3175 struct label
*socklabel
3179 @brief Access control check for socket receive
3180 @param cred Subject credential
3181 @param socket Object socket
3182 @param socklabel Policy label for socket
3183 @param addr Name of the remote socket
3185 Determine whether the subject identified by the credential can
3186 receive data from the remote host specified by addr.
3188 @return Return 0 if access if granted, otherwise an appropriate
3189 value for errno should be returned.
3191 typedef int mpo_socket_check_received_t(
3193 struct socket
*sock
,
3194 struct label
*socklabel
,
3195 struct sockaddr
*saddr
3200 @brief Access control check for socket select
3201 @param cred Subject credential
3202 @param so Object socket
3203 @param socklabel Policy label for socket
3204 @param which The operation selected on: FREAD or FWRITE
3206 Determine whether the subject identified by the credential can use the
3207 socket in a call to select().
3209 @return Return 0 if access if granted, otherwise an appropriate
3210 value for errno should be returned.
3212 typedef int mpo_socket_check_select_t(
3215 struct label
*socklabel
,
3219 @brief Access control check for socket send
3220 @param cred Subject credential
3221 @param so Object socket
3222 @param socklabel Policy label for socket
3223 @param addr Address being sent to
3225 Determine whether the subject identified by the credential can send
3228 @return Return 0 if access if granted, otherwise an appropriate
3229 value for errno should be returned.
3231 typedef int mpo_socket_check_send_t(
3234 struct label
*socklabel
,
3235 struct sockaddr
*addr
3238 @brief Access control check for retrieving socket status
3239 @param cred Subject credential
3240 @param so Object socket
3241 @param socklabel Policy label for so
3243 Determine whether the subject identified by the credential can
3244 execute the stat() system call on the given socket.
3246 @return Return 0 if access if granted, otherwise an appropriate
3247 value for errno should be returned.
3249 typedef int mpo_socket_check_stat_t(
3252 struct label
*socklabel
3255 @brief Access control check for setting socket options
3256 @param cred Subject credential
3257 @param so Object socket
3258 @param socklabel Policy label for so
3259 @param sopt The options being set
3261 Determine whether the subject identified by the credential can
3262 execute the setsockopt system call on the given socket.
3264 @return Return 0 if access if granted, otherwise an appropriate
3265 value for errno should be returned.
3267 typedef int mpo_socket_check_setsockopt_t(
3270 struct label
*socklabel
,
3271 struct sockopt
*sopt
3274 @brief Access control check for getting socket options
3275 @param cred Subject credential
3276 @param so Object socket
3277 @param socklabel Policy label for so
3278 @param sopt The options to get
3280 Determine whether the subject identified by the credential can
3281 execute the getsockopt system call on the given socket.
3283 @return Return 0 if access if granted, otherwise an appropriate
3284 value for errno should be returned.
3286 typedef int mpo_socket_check_getsockopt_t(
3289 struct label
*socklabel
,
3290 struct sockopt
*sopt
3293 @brief Label a socket
3294 @param oldsock Listening socket
3295 @param oldlabel Policy label associated with oldsock
3296 @param newsock New socket
3297 @param newlabel Policy label associated with newsock
3299 A new socket is created when a connection is accept(2)ed. This
3300 function labels the new socket based on the existing listen(2)ing
3303 typedef void mpo_socket_label_associate_accept_t(
3305 struct label
*oldlabel
,
3307 struct label
*newlabel
3310 @brief Assign a label to a new socket
3311 @param cred Credential of the owning process
3312 @param so The socket being labeled
3313 @param solabel The label
3314 @warning cred can be NULL
3316 Set the label on a newly created socket from the passed subject
3317 credential. This call is made when a socket is created. The
3318 credentials may be null if the socket is being created by the
3321 typedef void mpo_socket_label_associate_t(
3324 struct label
*solabel
3327 @brief Copy a socket label
3328 @param src Source label
3329 @param dest Destination label
3331 Copy the socket label information in src into dest.
3333 typedef void mpo_socket_label_copy_t(
3338 @brief Destroy socket label
3339 @param label The label to be destroyed
3341 Destroy a socket label. Since the object is going out of
3342 scope, policy modules should free any internal storage associated
3343 with the label so that it may be destroyed.
3345 typedef void mpo_socket_label_destroy_t(
3349 @brief Externalize a socket label
3350 @param label Label to be externalized
3351 @param element_name Name of the label namespace for which labels should be
3353 @param sb String buffer to be filled with a text representation of label
3355 Produce an externalized socket label based on the label structure passed.
3356 An externalized label consists of a text representation of the label
3357 contents that can be used with userland applications and read by the
3358 user. If element_name does not match a namespace managed by the policy,
3359 simply return 0. Only return nonzero if an error occurs while externalizing
3362 @return In the event of an error, an appropriate value for errno
3363 should be returned, otherwise return 0 upon success.
3365 typedef int mpo_socket_label_externalize_t(
3366 struct label
*label
,
3371 @brief Initialize socket label
3372 @param label New label to initialize
3373 @param waitok Malloc flags
3375 Initialize the label of a newly instantiated socket. The waitok
3376 field may be one of M_WAITOK and M_NOWAIT, and should be employed to
3377 avoid performing a sleeping malloc(9) during this initialization
3378 call. It it not always safe to sleep during this entry point.
3380 @warning Since it is possible for the waitok flags to be set to
3381 M_NOWAIT, the malloc operation may fail.
3383 @return In the event of an error, an appropriate value for errno
3384 should be returned, otherwise return 0 upon success.
3386 typedef int mpo_socket_label_init_t(
3387 struct label
*label
,
3391 @brief Internalize a socket label
3392 @param label Label to be filled in
3393 @param element_name Name of the label namespace for which the label should
3395 @param element_data Text data to be internalized
3397 Produce an internal socket label structure based on externalized label
3398 data in text format.
3400 The policy's internalize entry points will be called only if the
3401 policy has registered interest in the label namespace.
3403 @return In the event of an error, an appropriate value for errno
3404 should be returned, otherwise return 0 upon success.
3406 typedef int mpo_socket_label_internalize_t(
3407 struct label
*label
,
3412 @brief Relabel socket
3413 @param cred Subject credential
3414 @param so Object; socket
3415 @param so_label Current label of the socket
3416 @param newlabel The label to be assigned to so
3418 The subject identified by the credential has previously requested
3419 and was authorized to relabel the socket; this entry point allows
3420 policies to perform the actual label update operation.
3422 @warning XXX This entry point will likely change in future versions.
3424 typedef void mpo_socket_label_update_t(
3427 struct label
*so_label
,
3428 struct label
*newlabel
3431 @brief Set the peer label on a socket from mbuf
3432 @param m Mbuf chain received on socket so
3433 @param m_label Label for m
3434 @param so Current label for the socket
3435 @param so_label Policy label to be filled out for the socket
3437 Set the peer label of a socket based on the label of the sender of the
3440 This is called for every TCP/IP packet received. The first call for a given
3441 socket operates on a newly initialized label, and subsequent calls operate
3442 on existing label data.
3444 @warning Because this can affect performance significantly, it has
3445 different sematics than other 'set' operations. Typically, 'set' operations
3446 operate on newly initialzed labels and policies do not need to worry about
3447 clobbering existing values. In this case, it is too inefficient to
3448 initialize and destroy a label every time data is received for the socket.
3449 Instead, it is up to the policies to determine how to replace the label data.
3450 Most policies should be able to replace the data inline.
3452 typedef void mpo_socketpeer_label_associate_mbuf_t(
3454 struct label
*m_label
,
3456 struct label
*so_label
3459 @brief Set the peer label on a socket from socket
3460 @param source Local socket
3461 @param sourcelabel Policy label for source
3462 @param target Peer socket
3463 @param targetlabel Policy label to fill in for target
3465 Set the peer label on a stream UNIX domain socket from the passed
3466 remote socket endpoint. This call will be made when the socket pair
3467 is connected, and will be made for both endpoints.
3469 Note that this call is only made on connection; it is currently not updated
3470 during communication.
3472 typedef void mpo_socketpeer_label_associate_socket_t(
3474 struct label
*sourcelabel
,
3476 struct label
*targetlabel
3479 @brief Destroy socket peer label
3480 @param label The peer label to be destroyed
3482 Destroy a socket peer label. Since the object is going out of
3483 scope, policy modules should free any internal storage associated
3484 with the label so that it may be destroyed.
3486 typedef void mpo_socketpeer_label_destroy_t(
3490 @brief Externalize a socket peer label
3491 @param label Label to be externalized
3492 @param element_name Name of the label namespace for which labels should be
3494 @param sb String buffer to be filled with a text representation of label
3496 Produce an externalized socket peer label based on the label structure
3497 passed. An externalized label consists of a text representation of the
3498 label contents that can be used with userland applications and read by the
3499 user. If element_name does not match a namespace managed by the policy,
3500 simply return 0. Only return nonzero if an error occurs while externalizing
3503 @return In the event of an error, an appropriate value for errno
3504 should be returned, otherwise return 0 upon success.
3506 typedef int mpo_socketpeer_label_externalize_t(
3507 struct label
*label
,
3512 @brief Initialize socket peer label
3513 @param label New label to initialize
3514 @param waitok Malloc flags
3516 Initialize the peer label of a newly instantiated socket. The
3517 waitok field may be one of M_WAITOK and M_NOWAIT, and should be
3518 employed to avoid performing a sleeping malloc(9) during this
3519 initialization call. It it not always safe to sleep during this
3522 @warning Since it is possible for the waitok flags to be set to
3523 M_NOWAIT, the malloc operation may fail.
3525 @return In the event of an error, an appropriate value for errno
3526 should be returned, otherwise return 0 upon success.
3528 typedef int mpo_socketpeer_label_init_t(
3529 struct label
*label
,
3533 @brief Access control check for enabling accounting
3534 @param cred Subject credential
3535 @param vp Accounting file
3536 @param vlabel Label associated with vp
3538 Determine whether the subject should be allowed to enable accounting,
3539 based on its label and the label of the accounting log file. See
3540 acct(5) for more information.
3542 As accounting is disabled by passing NULL to the acct(2) system call,
3543 the policy should be prepared for both 'vp' and 'vlabel' to be NULL.
3545 @return Return 0 if access is granted, otherwise an appropriate value for
3546 errno should be returned.
3548 typedef int mpo_system_check_acct_t(
3551 struct label
*vlabel
3554 @brief Access control check for audit
3555 @param cred Subject credential
3556 @param record Audit record
3557 @param length Audit record length
3559 Determine whether the subject identified by the credential can submit
3560 an audit record for inclusion in the audit log via the audit() system call.
3562 @return Return 0 if access is granted, otherwise an appropriate value for
3563 errno should be returned.
3565 typedef int mpo_system_check_audit_t(
3571 @brief Access control check for controlling audit
3572 @param cred Subject credential
3573 @param vp Audit file
3574 @param vl Label associated with vp
3576 Determine whether the subject should be allowed to enable auditing using
3577 the auditctl() system call, based on its label and the label of the proposed
3580 @return Return 0 if access is granted, otherwise an appropriate value for
3581 errno should be returned.
3583 typedef int mpo_system_check_auditctl_t(
3589 @brief Access control check for manipulating auditing
3590 @param cred Subject credential
3591 @param cmd Audit control command
3593 Determine whether the subject identified by the credential can perform
3594 the audit subsystem control operation cmd via the auditon() system call.
3596 @return Return 0 if access is granted, otherwise an appropriate value for
3597 errno should be returned.
3599 typedef int mpo_system_check_auditon_t(
3604 @brief Access control check for using CHUD facilities
3605 @param cred Subject credential
3607 Determine whether the subject identified by the credential can perform
3608 performance-related tasks using the CHUD system call.
3610 @return Return 0 if access is granted, otherwise an appropriate value for
3611 errno should be returned.
3613 typedef int mpo_system_check_chud_t(
3617 @brief Access control check for obtaining the host control port
3618 @param cred Subject credential
3620 Determine whether the subject identified by the credential can
3621 obtain the host control port.
3623 @return Return 0 if access is granted, or non-zero otherwise.
3625 typedef int mpo_system_check_host_priv_t(
3629 @brief Access control check for obtaining system information
3630 @param cred Subject credential
3631 @param info_type A description of the information requested
3633 Determine whether the subject identified by the credential should be
3634 allowed to obtain information about the system.
3636 This is a generic hook that can be used in a variety of situations where
3637 information is being returned that might be considered sensitive.
3638 Rather than adding a new MAC hook for every such interface, this hook can
3639 be called with a string identifying the type of information requested.
3641 @return Return 0 if access is granted, otherwise an appropriate value for
3642 errno should be returned.
3644 typedef int mpo_system_check_info_t(
3646 const char *info_type
3649 @brief Access control check for calling NFS services
3650 @param cred Subject credential
3652 Determine whether the subject identified by the credential should be
3653 allowed to call nfssrv(2).
3655 @return Return 0 if access is granted, otherwise an appropriate value for
3656 errno should be returned.
3658 typedef int mpo_system_check_nfsd_t(
3662 @brief Access control check for reboot
3663 @param cred Subject credential
3664 @param howto howto parameter from reboot(2)
3666 Determine whether the subject identified by the credential should be
3667 allowed to reboot the system in the specified manner.
3669 @return Return 0 if access is granted, otherwise an appropriate value for
3670 errno should be returned.
3672 typedef int mpo_system_check_reboot_t(
3677 @brief Access control check for setting system clock
3678 @param cred Subject credential
3680 Determine whether the subject identified by the credential should be
3681 allowed to set the system clock.
3683 @return Return 0 if access is granted, otherwise an appropriate value for
3684 errno should be returned.
3686 typedef int mpo_system_check_settime_t(
3690 @brief Access control check for removing swap devices
3691 @param cred Subject credential
3692 @param vp Swap device
3693 @param label Label associated with vp
3695 Determine whether the subject identified by the credential should be
3696 allowed to remove vp as a swap device.
3698 @return Return 0 if access is granted, otherwise an appropriate value for
3699 errno should be returned.
3701 typedef int mpo_system_check_swapoff_t(
3707 @brief Access control check for adding swap devices
3708 @param cred Subject credential
3709 @param vp Swap device
3710 @param label Label associated with vp
3712 Determine whether the subject identified by the credential should be
3713 allowed to add vp as a swap device.
3715 @return Return 0 if access is granted, otherwise an appropriate value for
3716 errno should be returned.
3718 typedef int mpo_system_check_swapon_t(
3724 @brief Access control check for sysctl
3725 @param cred Subject credential
3726 @param namestring String representation of sysctl name.
3727 @param name Integer name; see sysctl(3)
3728 @param namelen Length of name array of integers; see sysctl(3)
3729 @param old 0 or address where to store old value; see sysctl(3)
3730 @param oldlen Length of old buffer; see sysctl(3)
3731 @param newvalue 0 or address of new value; see sysctl(3)
3732 @param newlen Length of new buffer; see sysctl(3)
3734 Determine whether the subject identified by the credential should be
3735 allowed to make the specified sysctl(3) transaction.
3737 The sysctl(3) call specifies that if the old value is not desired,
3738 oldp and oldlenp should be set to NULL. Likewise, if a new value is
3739 not to be set, newp should be set to NULL and newlen set to 0.
3741 @return Return 0 if access is granted, otherwise an appropriate value for
3742 errno should be returned.
3744 typedef int mpo_system_check_sysctlbyname_t(
3746 const char *namestring
,
3749 user_addr_t old
, /* NULLOK */
3751 user_addr_t newvalue
, /* NULLOK */
3755 @brief Access control check for kas_info
3756 @param cred Subject credential
3757 @param selector Category of information to return. See kas_info.h
3759 Determine whether the subject identified by the credential can perform
3760 introspection of the kernel address space layout for
3761 debugging/performance analysis.
3763 @return Return 0 if access is granted, otherwise an appropriate value for
3764 errno should be returned.
3766 typedef int mpo_system_check_kas_info_t(
3771 @brief Create a System V message label
3772 @param cred Subject credential
3773 @param msqkptr The message queue the message will be placed in
3774 @param msqlabel The label of the message queue
3775 @param msgptr The message
3776 @param msglabel The label of the message
3778 Label the message as its placed in the message queue.
3780 typedef void mpo_sysvmsg_label_associate_t(
3782 struct msqid_kernel
*msqptr
,
3783 struct label
*msqlabel
,
3785 struct label
*msglabel
3788 @brief Destroy System V message label
3789 @param label The label to be destroyed
3791 Destroy a System V message label. Since the object is
3792 going out of scope, policy modules should free any internal storage
3793 associated with the label so that it may be destroyed.
3795 typedef void mpo_sysvmsg_label_destroy_t(
3799 @brief Initialize System V message label
3800 @param label New label to initialize
3802 Initialize the label for a newly instantiated System V message.
3804 typedef void mpo_sysvmsg_label_init_t(
3808 @brief Clean up a System V message label
3809 @param label The label to be destroyed
3811 Clean up a System V message label. Darwin pre-allocates
3812 messages at system boot time and re-uses them rather than
3813 allocating new ones. Before messages are returned to the "free
3814 pool", policies can cleanup or overwrite any information present in
3817 typedef void mpo_sysvmsg_label_recycle_t(
3821 @brief Access control check for System V message enqueuing
3822 @param cred Subject credential
3823 @param msgptr The message
3824 @param msglabel The message's label
3825 @param msqkptr The message queue
3826 @param msqlabel The message queue's label
3828 Determine whether the subject identified by the credential can add the
3829 given message to the given message queue.
3831 @return Return 0 if access is granted, otherwise an appropriate value for
3832 errno should be returned.
3834 typedef int mpo_sysvmsq_check_enqueue_t(
3837 struct label
*msglabel
,
3838 struct msqid_kernel
*msqptr
,
3839 struct label
*msqlabel
3842 @brief Access control check for System V message reception
3843 @param cred The credential of the intended recipient
3844 @param msgptr The message
3845 @param msglabel The message's label
3847 Determine whether the subject identified by the credential can receive
3850 @return Return 0 if access is granted, otherwise an appropriate value for
3851 errno should be returned.
3853 typedef int mpo_sysvmsq_check_msgrcv_t(
3856 struct label
*msglabel
3859 @brief Access control check for System V message queue removal
3860 @param cred The credential of the caller
3861 @param msgptr The message
3862 @param msglabel The message's label
3864 System V message queues are removed using the msgctl() system call.
3865 The system will iterate over each messsage in the queue, calling this
3866 function for each, to determine whether the caller has the appropriate
3869 @return Return 0 if access is granted, otherwise an appropriate value for
3870 errno should be returned.
3872 typedef int mpo_sysvmsq_check_msgrmid_t(
3875 struct label
*msglabel
3878 @brief Access control check for msgctl()
3879 @param cred The credential of the caller
3880 @param msqptr The message queue
3881 @param msqlabel The message queue's label
3883 This access check is performed to validate calls to msgctl().
3885 @return Return 0 if access is granted, otherwise an appropriate value for
3886 errno should be returned.
3888 typedef int mpo_sysvmsq_check_msqctl_t(
3890 struct msqid_kernel
*msqptr
,
3891 struct label
*msqlabel
,
3895 @brief Access control check to get a System V message queue
3896 @param cred The credential of the caller
3897 @param msqptr The message queue requested
3898 @param msqlabel The message queue's label
3900 On a call to msgget(), if the queue requested already exists,
3901 and it is a public queue, this check will be performed before the
3902 queue's ID is returned to the user.
3904 @return Return 0 if access is granted, otherwise an appropriate value for
3905 errno should be returned.
3907 typedef int mpo_sysvmsq_check_msqget_t(
3909 struct msqid_kernel
*msqptr
,
3910 struct label
*msqlabel
3913 @brief Access control check to receive a System V message from the given queue
3914 @param cred The credential of the caller
3915 @param msqptr The message queue to receive from
3916 @param msqlabel The message queue's label
3918 On a call to msgrcv(), this check is performed to determine whether the
3919 caller has receive rights on the given queue.
3921 @return Return 0 if access is granted, otherwise an appropriate value for
3922 errno should be returned.
3924 typedef int mpo_sysvmsq_check_msqrcv_t(
3926 struct msqid_kernel
*msqptr
,
3927 struct label
*msqlabel
3930 @brief Access control check to send a System V message to the given queue
3931 @param cred The credential of the caller
3932 @param msqptr The message queue to send to
3933 @param msqlabel The message queue's label
3935 On a call to msgsnd(), this check is performed to determine whether the
3936 caller has send rights on the given queue.
3938 @return Return 0 if access is granted, otherwise an appropriate value for
3939 errno should be returned.
3941 typedef int mpo_sysvmsq_check_msqsnd_t(
3943 struct msqid_kernel
*msqptr
,
3944 struct label
*msqlabel
3947 @brief Create a System V message queue label
3948 @param cred Subject credential
3949 @param msqkptr The message queue
3950 @param msqlabel The label of the message queue
3953 typedef void mpo_sysvmsq_label_associate_t(
3955 struct msqid_kernel
*msqptr
,
3956 struct label
*msqlabel
3959 @brief Destroy System V message queue label
3960 @param label The label to be destroyed
3962 Destroy a System V message queue label. Since the object is
3963 going out of scope, policy modules should free any internal storage
3964 associated with the label so that it may be destroyed.
3966 typedef void mpo_sysvmsq_label_destroy_t(
3970 @brief Initialize System V message queue label
3971 @param label New label to initialize
3973 Initialize the label for a newly instantiated System V message queue.
3975 typedef void mpo_sysvmsq_label_init_t(
3979 @brief Clean up a System V message queue label
3980 @param label The label to be destroyed
3982 Clean up a System V message queue label. Darwin pre-allocates
3983 message queues at system boot time and re-uses them rather than
3984 allocating new ones. Before message queues are returned to the "free
3985 pool", policies can cleanup or overwrite any information present in
3988 typedef void mpo_sysvmsq_label_recycle_t(
3992 @brief Access control check for System V semaphore control operation
3993 @param cred Subject credential
3994 @param semakptr Pointer to semaphore identifier
3995 @param semaklabel Label associated with semaphore
3996 @param cmd Control operation to be performed; see semctl(2)
3998 Determine whether the subject identified by the credential can perform
3999 the operation indicated by cmd on the System V semaphore semakptr.
4001 @return Return 0 if access is granted, otherwise an appropriate value for
4002 errno should be returned.
4004 typedef int mpo_sysvsem_check_semctl_t(
4006 struct semid_kernel
*semakptr
,
4007 struct label
*semaklabel
,
4011 @brief Access control check for obtaining a System V semaphore
4012 @param cred Subject credential
4013 @param semakptr Pointer to semaphore identifier
4014 @param semaklabel Label to associate with the semaphore
4016 Determine whether the subject identified by the credential can
4017 obtain a System V semaphore.
4019 @return Return 0 if access is granted, otherwise an appropriate value for
4020 errno should be returned.
4022 typedef int mpo_sysvsem_check_semget_t(
4024 struct semid_kernel
*semakptr
,
4025 struct label
*semaklabel
4028 @brief Access control check for System V semaphore operations
4029 @param cred Subject credential
4030 @param semakptr Pointer to semaphore identifier
4031 @param semaklabel Label associated with the semaphore
4032 @param accesstype Flags to indicate access (read and/or write)
4034 Determine whether the subject identified by the credential can
4035 perform the operations on the System V semaphore indicated by
4036 semakptr. The accesstype flags hold the maximum set of permissions
4037 from the sem_op array passed to the semop system call. It may
4038 contain SEM_R for read-only operations or SEM_A for read/write
4041 @return Return 0 if access is granted, otherwise an appropriate value for
4042 errno should be returned.
4044 typedef int mpo_sysvsem_check_semop_t(
4046 struct semid_kernel
*semakptr
,
4047 struct label
*semaklabel
,
4051 @brief Create a System V semaphore label
4052 @param cred Subject credential
4053 @param semakptr The semaphore being created
4054 @param semalabel Label to associate with the new semaphore
4056 Label a new System V semaphore. The label was previously
4057 initialized and associated with the semaphore. At this time, an
4058 appropriate initial label value should be assigned to the object and
4059 stored in semalabel.
4061 typedef void mpo_sysvsem_label_associate_t(
4063 struct semid_kernel
*semakptr
,
4064 struct label
*semalabel
4067 @brief Destroy System V semaphore label
4068 @param label The label to be destroyed
4070 Destroy a System V semaphore label. Since the object is
4071 going out of scope, policy modules should free any internal storage
4072 associated with the label so that it may be destroyed.
4074 typedef void mpo_sysvsem_label_destroy_t(
4078 @brief Initialize System V semaphore label
4079 @param label New label to initialize
4081 Initialize the label for a newly instantiated System V semaphore. Sleeping
4084 typedef void mpo_sysvsem_label_init_t(
4088 @brief Clean up a System V semaphore label
4089 @param label The label to be cleaned
4091 Clean up a System V semaphore label. Darwin pre-allocates
4092 semaphores at system boot time and re-uses them rather than
4093 allocating new ones. Before semaphores are returned to the "free
4094 pool", policies can cleanup or overwrite any information present in
4097 typedef void mpo_sysvsem_label_recycle_t(
4101 @brief Access control check for mapping System V shared memory
4102 @param cred Subject credential
4103 @param shmsegptr Pointer to shared memory segment identifier
4104 @param shmseglabel Label associated with the shared memory segment
4105 @param shmflg shmat flags; see shmat(2)
4107 Determine whether the subject identified by the credential can map
4108 the System V shared memory segment associated with shmsegptr.
4110 @return Return 0 if access is granted, otherwise an appropriate value for
4111 errno should be returned.
4113 typedef int mpo_sysvshm_check_shmat_t(
4115 struct shmid_kernel
*shmsegptr
,
4116 struct label
*shmseglabel
,
4120 @brief Access control check for System V shared memory control operation
4121 @param cred Subject credential
4122 @param shmsegptr Pointer to shared memory segment identifier
4123 @param shmseglabel Label associated with the shared memory segment
4124 @param cmd Control operation to be performed; see shmctl(2)
4126 Determine whether the subject identified by the credential can perform
4127 the operation indicated by cmd on the System V shared memory segment
4130 @return Return 0 if access is granted, otherwise an appropriate value for
4131 errno should be returned.
4133 typedef int mpo_sysvshm_check_shmctl_t(
4135 struct shmid_kernel
*shmsegptr
,
4136 struct label
*shmseglabel
,
4140 @brief Access control check for unmapping System V shared memory
4141 @param cred Subject credential
4142 @param shmsegptr Pointer to shared memory segment identifier
4143 @param shmseglabel Label associated with the shared memory segment
4145 Determine whether the subject identified by the credential can unmap
4146 the System V shared memory segment associated with shmsegptr.
4148 @return Return 0 if access is granted, otherwise an appropriate value for
4149 errno should be returned.
4151 typedef int mpo_sysvshm_check_shmdt_t(
4153 struct shmid_kernel
*shmsegptr
,
4154 struct label
*shmseglabel
4157 @brief Access control check obtaining System V shared memory identifier
4158 @param cred Subject credential
4159 @param shmsegptr Pointer to shared memory segment identifier
4160 @param shmseglabel Label associated with the shared memory segment
4161 @param shmflg shmget flags; see shmget(2)
4163 Determine whether the subject identified by the credential can get
4164 the System V shared memory segment address.
4166 @return Return 0 if access is granted, otherwise an appropriate value for
4167 errno should be returned.
4169 typedef int mpo_sysvshm_check_shmget_t(
4171 struct shmid_kernel
*shmsegptr
,
4172 struct label
*shmseglabel
,
4176 @brief Create a System V shared memory region label
4177 @param cred Subject credential
4178 @param shmsegptr The shared memory region being created
4179 @param shmlabel Label to associate with the new shared memory region
4181 Label a new System V shared memory region. The label was previously
4182 initialized and associated with the shared memory region. At this
4183 time, an appropriate initial label value should be assigned to the
4184 object and stored in shmlabel.
4186 typedef void mpo_sysvshm_label_associate_t(
4188 struct shmid_kernel
*shmsegptr
,
4189 struct label
*shmlabel
4192 @brief Destroy System V shared memory label
4193 @param label The label to be destroyed
4195 Destroy a System V shared memory region label. Since the
4196 object is going out of scope, policy modules should free any
4197 internal storage associated with the label so that it may be
4200 typedef void mpo_sysvshm_label_destroy_t(
4204 @brief Initialize System V Shared Memory region label
4205 @param label New label to initialize
4207 Initialize the label for a newly instantiated System V Shared Memory
4208 region. Sleeping is permitted.
4210 typedef void mpo_sysvshm_label_init_t(
4214 @brief Clean up a System V Share Memory Region label
4215 @param shmlabel The label to be cleaned
4217 Clean up a System V Shared Memory Region label. Darwin
4218 pre-allocates these objects at system boot time and re-uses them
4219 rather than allocating new ones. Before the memory regions are
4220 returned to the "free pool", policies can cleanup or overwrite any
4221 information present in the label.
4223 typedef void mpo_sysvshm_label_recycle_t(
4224 struct label
*shmlabel
4227 @brief Access control check for getting a process's task name
4228 @param cred Subject credential
4229 @param proc Object process
4231 Determine whether the subject identified by the credential can get
4232 the passed process's task name port.
4233 This call is used by the task_name_for_pid(2) API.
4235 @return Return 0 if access is granted, otherwise an appropriate value for
4236 errno should be returned. Suggested failure: EACCES for label mismatch,
4237 EPERM for lack of privilege, or ESRCH to hide visibility of the target.
4239 typedef int mpo_proc_check_get_task_name_t(
4244 @brief Access control check for getting a process's task port
4245 @param cred Subject credential
4246 @param proc Object process
4248 Determine whether the subject identified by the credential can get
4249 the passed process's task control port.
4250 This call is used by the task_for_pid(2) API.
4252 @return Return 0 if access is granted, otherwise an appropriate value for
4253 errno should be returned. Suggested failure: EACCES for label mismatch,
4254 EPERM for lack of privilege, or ESRCH to hide visibility of the target.
4256 typedef int mpo_proc_check_get_task_t(
4262 @brief Access control check for exposing a process's task port
4263 @param cred Subject credential
4264 @param proc Object process
4266 Determine whether the subject identified by the credential can expose
4267 the passed process's task control port.
4268 This call is used by the accessor APIs like processor_set_tasks() and
4269 processor_set_threads().
4271 @return Return 0 if access is granted, otherwise an appropriate value for
4272 errno should be returned. Suggested failure: EACCES for label mismatch,
4273 EPERM for lack of privilege, or ESRCH to hide visibility of the target.
4275 typedef int mpo_proc_check_expose_task_t(
4281 @brief Check whether task's IPC may inherit across process exec
4282 @param proc current process instance
4283 @param cur_vp vnode pointer to current instance
4284 @param cur_offset offset of binary of currently executing image
4285 @param img_vp vnode pointer to to be exec'ed image
4286 @param img_offset offset into file which is selected for execution
4287 @param scriptvp vnode pointer of script file if any.
4288 @return Return 0 if access is granted.
4289 EPERM if parent does not have any entitlements.
4290 EACCESS if mismatch in entitlements
4292 typedef int mpo_proc_check_inherit_ipc_ports_t(
4294 struct vnode
*cur_vp
,
4296 struct vnode
*img_vp
,
4298 struct vnode
*scriptvp
4302 @brief Privilege check for a process to run invalid
4303 @param proc Object process
4305 Determine whether the process may execute even though the system determined
4306 that it is untrusted (eg unidentified / modified code).
4308 @return Return 0 if access is granted, otherwise an appropriate value for
4309 errno should be returned.
4311 typedef int mpo_proc_check_run_cs_invalid_t(
4316 @brief Perform MAC-related events when a thread returns to user space
4317 @param thread Mach (not BSD) thread that is returning
4319 This entry point permits policy modules to perform MAC-related
4320 events when a thread returns to user space, via a system call
4321 return or trap return.
4323 typedef void mpo_thread_userret_t(
4324 struct thread
*thread
4328 @brief Check vnode access
4329 @param cred Subject credential
4330 @param vp Object vnode
4331 @param label Label for vp
4332 @param acc_mode access(2) flags
4334 Determine how invocations of access(2) and related calls by the
4335 subject identified by the credential should return when performed
4336 on the passed vnode using the passed access flags. This should
4337 generally be implemented using the same semantics used in
4338 mpo_vnode_check_open.
4340 @return Return 0 if access is granted, otherwise an appropriate value for
4341 errno should be returned. Suggested failure: EACCES for label mismatch or
4342 EPERM for lack of privilege.
4344 typedef int mpo_vnode_check_access_t(
4347 struct label
*label
,
4351 @brief Access control check for changing working directory
4352 @param cred Subject credential
4353 @param dvp Object; vnode to chdir(2) into
4354 @param dlabel Policy label for dvp
4356 Determine whether the subject identified by the credential can change
4357 the process working directory to the passed vnode.
4359 @return Return 0 if access is granted, otherwise an appropriate value for
4360 errno should be returned. Suggested failure: EACCES for label mismatch or
4361 EPERM for lack of privilege.
4363 typedef int mpo_vnode_check_chdir_t(
4366 struct label
*dlabel
4369 @brief Access control check for changing root directory
4370 @param cred Subject credential
4371 @param dvp Directory vnode
4372 @param dlabel Policy label associated with dvp
4373 @param cnp Component name for dvp
4375 Determine whether the subject identified by the credential should be
4376 allowed to chroot(2) into the specified directory (dvp).
4378 @return In the event of an error, an appropriate value for errno
4379 should be returned, otherwise return 0 upon success.
4381 typedef int mpo_vnode_check_chroot_t(
4384 struct label
*dlabel
,
4385 struct componentname
*cnp
4388 @brief Access control check for creating vnode
4389 @param cred Subject credential
4390 @param dvp Directory vnode
4391 @param dlabel Policy label for dvp
4392 @param cnp Component name for dvp
4393 @param vap vnode attributes for vap
4395 Determine whether the subject identified by the credential can create
4396 a vnode with the passed parent directory, passed name information,
4397 and passed attribute information. This call may be made in a number of
4398 situations, including as a result of calls to open(2) with O_CREAT,
4399 mknod(2), mkfifo(2), and others.
4401 @return Return 0 if access is granted, otherwise an appropriate value for
4402 errno should be returned. Suggested failure: EACCES for label mismatch or
4403 EPERM for lack of privilege.
4405 typedef int mpo_vnode_check_create_t(
4408 struct label
*dlabel
,
4409 struct componentname
*cnp
,
4410 struct vnode_attr
*vap
4413 @brief Access control check for deleting extended attribute
4414 @param cred Subject credential
4415 @param vp Object vnode
4416 @param vlabel Label associated with vp
4417 @param name Extended attribute name
4419 Determine whether the subject identified by the credential can delete
4420 the extended attribute from the passed vnode.
4422 @return Return 0 if access is granted, otherwise an appropriate value for
4423 errno should be returned. Suggested failure: EACCES for label mismatch or
4424 EPERM for lack of privilege.
4426 typedef int mpo_vnode_check_deleteextattr_t(
4429 struct label
*vlabel
,
4433 @brief Access control check for exchanging file data
4434 @param cred Subject credential
4435 @param v1 vnode 1 to swap
4436 @param vl1 Policy label for v1
4437 @param v2 vnode 2 to swap
4438 @param vl2 Policy label for v2
4440 Determine whether the subject identified by the credential can swap the data
4441 in the two supplied vnodes.
4443 @return Return 0 if access is granted, otherwise an appropriate value for
4444 errno should be returned. Suggested failure: EACCES for label mismatch or
4445 EPERM for lack of privilege.
4447 typedef int mpo_vnode_check_exchangedata_t(
4455 @brief Access control check for executing the vnode
4456 @param cred Subject credential
4457 @param vp Object vnode to execute
4458 @param scriptvp Script being executed by interpreter, if any.
4459 @param vnodelabel Label corresponding to vp
4460 @param scriptvnodelabel Script vnode label
4461 @param execlabel Userspace provided execution label
4462 @param cnp Component name for file being executed
4463 @param macpolicyattr MAC policy-specific spawn attribute data.
4464 @param macpolicyattrlen Length of policy-specific spawn attribute data.
4466 Determine whether the subject identified by the credential can execute
4467 the passed vnode. Determination of execute privilege is made separately
4468 from decisions about any process label transitioning event.
4470 The final label, execlabel, corresponds to a label supplied by a
4471 user space application through the use of the mac_execve system call.
4472 This label will be NULL if the user application uses the the vendor
4473 execve(2) call instead of the MAC Framework mac_execve() call.
4475 @return Return 0 if access is granted, otherwise an appropriate value for
4476 errno should be returned. Suggested failure: EACCES for label mismatch or
4477 EPERM for lack of privilege.
4479 typedef int mpo_vnode_check_exec_t(
4482 struct vnode
*scriptvp
,
4483 struct label
*vnodelabel
,
4484 struct label
*scriptlabel
,
4485 struct label
*execlabel
, /* NULLOK */
4486 struct componentname
*cnp
,
4488 void *macpolicyattr
,
4489 size_t macpolicyattrlen
4492 @brief Access control check for fsgetpath
4493 @param cred Subject credential
4494 @param vp Vnode for which a path will be returned
4495 @param label Label associated with the vnode
4497 Determine whether the subject identified by the credential can get the path
4498 of the given vnode with fsgetpath.
4500 @return Return 0 if access is granted, otherwise an appropriate value for
4501 errno should be returned.
4503 typedef int mpo_vnode_check_fsgetpath_t(
4509 @brief Access control check after determining the code directory hash
4511 typedef int mpo_vnode_check_signature_t(struct vnode
*vp
, struct label
*label
,
4512 off_t macho_offset
, unsigned char *sha1
,
4513 const void *signature
, int size
,
4514 int flags
, int *is_platform_binary
);
4517 @brief Access control check for retrieving file attributes
4518 @param cred Subject credential
4519 @param vp Object vnode
4520 @param vlabel Policy label for vp
4521 @param alist List of attributes to retrieve
4523 Determine whether the subject identified by the credential can read
4524 various attributes of the specified vnode, or the filesystem or volume on
4525 which that vnode resides. See <sys/attr.h> for definitions of the
4528 @return Return 0 if access is granted, otherwise an appropriate value for
4529 errno should be returned. Suggested failure: EACCES for label mismatch or
4530 EPERM for lack of privilege. Access control covers all attributes requested
4531 with this call; the security policy is not permitted to change the set of
4532 attributes requested.
4534 typedef int mpo_vnode_check_getattrlist_t(
4537 struct label
*vlabel
,
4538 struct attrlist
*alist
4541 @brief Access control check for retrieving an extended attribute
4542 @param cred Subject credential
4543 @param vp Object vnode
4544 @param label Policy label for vp
4545 @param name Extended attribute name
4546 @param uio I/O structure pointer
4548 Determine whether the subject identified by the credential can retrieve
4549 the extended attribute from the passed vnode. The uio parameter
4550 will be NULL when the getxattr(2) call has been made with a NULL data
4551 value; this is done to request the size of the data only.
4553 @return Return 0 if access is granted, otherwise an appropriate value for
4554 errno should be returned. Suggested failure: EACCES for label mismatch or
4555 EPERM for lack of privilege.
4557 typedef int mpo_vnode_check_getextattr_t(
4560 struct label
*label
, /* NULLOK */
4562 struct uio
*uio
/* NULLOK */
4565 @brief Access control check for ioctl
4566 @param cred Subject credential
4567 @param vp Object vnode
4568 @param label Policy label for vp
4569 @param com Device-dependent request code; see ioctl(2)
4571 Determine whether the subject identified by the credential can perform
4572 the ioctl operation indicated by com.
4574 @warning Since ioctl data is opaque from the standpoint of the MAC
4575 framework, and since ioctls can affect many aspects of system
4576 operation, policies must exercise extreme care when implementing
4577 access control checks.
4579 @return Return 0 if access is granted, otherwise an appropriate value for
4580 errno should be returned.
4582 typedef int mpo_vnode_check_ioctl_t(
4585 struct label
*label
,
4589 @brief Access control check for vnode kqfilter
4590 @param cred Subject credential
4591 @param kn Object knote
4592 @param vp Object vnode
4593 @param label Policy label for vp
4595 Determine whether the subject identified by the credential can
4596 receive the knote on the passed vnode.
4598 @return Return 0 if access if granted, otherwise an appropriate
4599 value for errno should be returned.
4601 typedef int mpo_vnode_check_kqfilter_t(
4602 kauth_cred_t active_cred
,
4603 kauth_cred_t file_cred
, /* NULLOK */
4609 @brief Access control check for relabel
4610 @param cred Subject credential
4611 @param vp Object vnode
4612 @param vnodelabel Existing policy label for vp
4613 @param newlabel Policy label update to later be applied to vp
4614 @see mpo_relable_vnode_t
4616 Determine whether the subject identified by the credential can relabel
4617 the passed vnode to the passed label update. If all policies permit
4618 the label change, the actual relabel entry point (mpo_vnode_label_update)
4621 @return Return 0 if access is granted, otherwise an appropriate value for
4622 errno should be returned.
4624 typedef int mpo_vnode_check_label_update_t(
4627 struct label
*vnodelabel
,
4628 struct label
*newlabel
4631 @brief Access control check for creating link
4632 @param cred Subject credential
4633 @param dvp Directory vnode
4634 @param dlabel Policy label associated with dvp
4635 @param vp Link destination vnode
4636 @param label Policy label associated with vp
4637 @param cnp Component name for the link being created
4639 Determine whether the subject identified by the credential should be
4640 allowed to create a link to the vnode vp with the name specified by cnp.
4642 @return Return 0 if access is granted, otherwise an appropriate value for
4643 errno should be returned.
4645 typedef int mpo_vnode_check_link_t(
4648 struct label
*dlabel
,
4650 struct label
*label
,
4651 struct componentname
*cnp
4654 @brief Access control check for listing extended attributes
4655 @param cred Subject credential
4656 @param vp Object vnode
4657 @param vlabel Policy label associated with vp
4659 Determine whether the subject identified by the credential can retrieve
4660 a list of named extended attributes from a vnode.
4662 @return Return 0 if access is granted, otherwise an appropriate value for
4663 errno should be returned.
4665 typedef int mpo_vnode_check_listextattr_t(
4668 struct label
*vlabel
4671 @brief Access control check for lookup
4672 @param cred Subject credential
4673 @param dvp Object vnode
4674 @param dlabel Policy label for dvp
4675 @param cnp Component name being looked up
4677 Determine whether the subject identified by the credential can perform
4678 a lookup in the passed directory vnode for the passed name (cnp).
4680 @return Return 0 if access is granted, otherwise an appropriate value for
4681 errno should be returned. Suggested failure: EACCES for label mismatch or
4682 EPERM for lack of privilege.
4684 typedef int mpo_vnode_check_lookup_t(
4687 struct label
*dlabel
,
4688 struct componentname
*cnp
4691 @brief Access control check for open
4692 @param cred Subject credential
4693 @param vp Object vnode
4694 @param label Policy label associated with vp
4695 @param acc_mode open(2) access mode
4697 Determine whether the subject identified by the credential can perform
4698 an open operation on the passed vnode with the passed access mode.
4700 @return Return 0 if access is granted, otherwise an appropriate value for
4701 errno should be returned. Suggested failure: EACCES for label mismatch or
4702 EPERM for lack of privilege.
4704 typedef int mpo_vnode_check_open_t(
4707 struct label
*label
,
4711 @brief Access control check for read
4712 @param active_cred Subject credential
4713 @param file_cred Credential associated with the struct fileproc
4714 @param vp Object vnode
4715 @param label Policy label for vp
4717 Determine whether the subject identified by the credential can perform
4718 a read operation on the passed vnode. The active_cred hold the credentials
4719 of the subject performing the operation, and file_cred holds the
4720 credentials of the subject that originally opened the file.
4722 @return Return 0 if access is granted, otherwise an appropriate value for
4723 errno should be returned. Suggested failure: EACCES for label mismatch or
4724 EPERM for lack of privilege.
4726 typedef int mpo_vnode_check_read_t(
4727 kauth_cred_t active_cred
, /* SUBJECT */
4728 kauth_cred_t file_cred
, /* NULLOK */
4729 struct vnode
*vp
, /* OBJECT */
4730 struct label
*label
/* LABEL */
4733 @brief Access control check for read directory
4734 @param cred Subject credential
4735 @param dvp Object directory vnode
4736 @param dlabel Policy label for dvp
4738 Determine whether the subject identified by the credential can
4739 perform a readdir operation on the passed directory vnode.
4741 @return Return 0 if access is granted, otherwise an appropriate value for
4742 errno should be returned. Suggested failure: EACCES for label mismatch or
4743 EPERM for lack of privilege.
4745 typedef int mpo_vnode_check_readdir_t(
4746 kauth_cred_t cred
, /* SUBJECT */
4747 struct vnode
*dvp
, /* OBJECT */
4748 struct label
*dlabel
/* LABEL */
4751 @brief Access control check for read link
4752 @param cred Subject credential
4753 @param vp Object vnode
4754 @param label Policy label for vp
4756 Determine whether the subject identified by the credential can perform
4757 a readlink operation on the passed symlink vnode. This call can be made
4758 in a number of situations, including an explicit readlink call by the
4759 user process, or as a result of an implicit readlink during a name
4760 lookup by the process.
4762 @return Return 0 if access is granted, otherwise an appropriate value for
4763 errno should be returned. Suggested failure: EACCES for label mismatch or
4764 EPERM for lack of privilege.
4766 typedef int mpo_vnode_check_readlink_t(
4772 @brief Access control check for rename
4773 @param cred Subject credential
4774 @param dvp Directory vnode
4775 @param dlabel Policy label associated with dvp
4776 @param vp vnode to be renamed
4777 @param label Policy label associated with vp
4778 @param cnp Component name for vp
4779 @param tdvp Destination directory vnode
4780 @param tdlabel Policy label associated with tdvp
4781 @param tvp Overwritten vnode
4782 @param tlabel Policy label associated with tvp
4783 @param tcnp Destination component name
4785 Determine whether the subject identified by the credential should be allowed
4786 to rename the vnode vp to something else.
4788 @return Return 0 if access is granted, otherwise an appropriate value for
4789 errno should be returned.
4791 typedef int mpo_vnode_check_rename_t(
4794 struct label
*dlabel
,
4796 struct label
*label
,
4797 struct componentname
*cnp
,
4799 struct label
*tdlabel
,
4801 struct label
*tlabel
,
4802 struct componentname
*tcnp
4805 @brief Access control check for rename from
4806 @param cred Subject credential
4807 @param dvp Directory vnode
4808 @param dlabel Policy label associated with dvp
4809 @param vp vnode to be renamed
4810 @param label Policy label associated with vp
4811 @param cnp Component name for vp
4812 @see mpo_vnode_check_rename_t
4813 @see mpo_vnode_check_rename_to_t
4815 Determine whether the subject identified by the credential should be
4816 allowed to rename the vnode vp to something else.
4818 Due to VFS locking constraints (to make sure proper vnode locks are
4819 held during this entry point), the vnode relabel checks had to be
4820 split into two parts: relabel_from and relabel to.
4822 This hook is deprecated, mpo_vnode_check_rename_t should be used instead.
4824 @return Return 0 if access is granted, otherwise an appropriate value for
4825 errno should be returned.
4827 typedef int mpo_vnode_check_rename_from_t(
4830 struct label
*dlabel
,
4832 struct label
*label
,
4833 struct componentname
*cnp
4836 @brief Access control check for rename to
4837 @param cred Subject credential
4838 @param dvp Directory vnode
4839 @param dlabel Policy label associated with dvp
4840 @param vp Overwritten vnode
4841 @param label Policy label associated with vp
4842 @param samedir Boolean; 1 if the source and destination directories are the same
4843 @param cnp Destination component name
4844 @see mpo_vnode_check_rename_t
4845 @see mpo_vnode_check_rename_from_t
4847 Determine whether the subject identified by the credential should be
4848 allowed to rename to the vnode vp, into the directory dvp, or to the
4849 name represented by cnp. If there is no existing file to overwrite,
4850 vp and label will be NULL.
4852 Due to VFS locking constraints (to make sure proper vnode locks are
4853 held during this entry point), the vnode relabel checks had to be
4854 split into two parts: relabel_from and relabel to.
4856 This hook is deprecated, mpo_vnode_check_rename_t should be used instead.
4858 @return Return 0 if access is granted, otherwise an appropriate value for
4859 errno should be returned.
4861 typedef int mpo_vnode_check_rename_to_t(
4864 struct label
*dlabel
,
4865 struct vnode
*vp
, /* NULLOK */
4866 struct label
*label
, /* NULLOK */
4868 struct componentname
*cnp
4871 @brief Access control check for revoke
4872 @param cred Subject credential
4873 @param vp Object vnode
4874 @param label Policy label for vp
4876 Determine whether the subject identified by the credential can revoke
4877 access to the passed vnode.
4879 @return Return 0 if access is granted, otherwise an appropriate value for
4880 errno should be returned. Suggested failure: EACCES for label mismatch or
4881 EPERM for lack of privilege.
4883 typedef int mpo_vnode_check_revoke_t(
4889 @brief Access control check for searchfs
4890 @param cred Subject credential
4891 @param vp Object vnode
4892 @param vlabel Policy label for vp
4893 @param alist List of attributes used as search criteria
4895 Determine whether the subject identified by the credential can search the
4896 vnode using the searchfs system call.
4898 @return Return 0 if access is granted, otherwise an appropriate value for
4899 errno should be returned.
4901 typedef int mpo_vnode_check_searchfs_t(
4904 struct label
*vlabel
,
4905 struct attrlist
*alist
4908 @brief Access control check for select
4909 @param cred Subject credential
4910 @param vp Object vnode
4911 @param label Policy label for vp
4912 @param which The operation selected on: FREAD or FWRITE
4914 Determine whether the subject identified by the credential can select
4917 @return Return 0 if access is granted, otherwise an appropriate value for
4918 errno should be returned.
4920 typedef int mpo_vnode_check_select_t(
4923 struct label
*label
,
4927 @brief Access control check for setting file attributes
4928 @param cred Subject credential
4929 @param vp Object vnode
4930 @param vlabel Policy label for vp
4931 @param alist List of attributes to set
4933 Determine whether the subject identified by the credential can set
4934 various attributes of the specified vnode, or the filesystem or volume on
4935 which that vnode resides. See <sys/attr.h> for definitions of the
4938 @return Return 0 if access is granted, otherwise an appropriate value for
4939 errno should be returned. Suggested failure: EACCES for label mismatch or
4940 EPERM for lack of privilege. Access control covers all attributes requested
4943 typedef int mpo_vnode_check_setattrlist_t(
4946 struct label
*vlabel
,
4947 struct attrlist
*alist
4950 @brief Access control check for setting extended attribute
4951 @param cred Subject credential
4952 @param vp Object vnode
4953 @param label Policy label for vp
4954 @param name Extended attribute name
4955 @param uio I/O structure pointer
4957 Determine whether the subject identified by the credential can set the
4958 extended attribute of passed name and passed namespace on the passed
4959 vnode. Policies implementing security labels backed into extended
4960 attributes may want to provide additional protections for those
4961 attributes. Additionally, policies should avoid making decisions based
4962 on the data referenced from uio, as there is a potential race condition
4963 between this check and the actual operation. The uio may also be NULL
4964 if a delete operation is being performed.
4966 @return Return 0 if access is granted, otherwise an appropriate value for
4967 errno should be returned. Suggested failure: EACCES for label mismatch or
4968 EPERM for lack of privilege.
4970 typedef int mpo_vnode_check_setextattr_t(
4973 struct label
*label
,
4978 @brief Access control check for setting flags
4979 @param cred Subject credential
4980 @param vp Object vnode
4981 @param label Policy label for vp
4982 @param flags File flags; see chflags(2)
4984 Determine whether the subject identified by the credential can set
4985 the passed flags on the passed vnode.
4987 @return Return 0 if access is granted, otherwise an appropriate value for
4988 errno should be returned. Suggested failure: EACCES for label mismatch or
4989 EPERM for lack of privilege.
4991 typedef int mpo_vnode_check_setflags_t(
4994 struct label
*label
,
4998 @brief Access control check for setting mode
4999 @param cred Subject credential
5000 @param vp Object vnode
5001 @param label Policy label for vp
5002 @param mode File mode; see chmod(2)
5004 Determine whether the subject identified by the credential can set
5005 the passed mode on the passed vnode.
5007 @return Return 0 if access is granted, otherwise an appropriate value for
5008 errno should be returned. Suggested failure: EACCES for label mismatch or
5009 EPERM for lack of privilege.
5011 typedef int mpo_vnode_check_setmode_t(
5014 struct label
*label
,
5018 @brief Access control check for setting uid and gid
5019 @param cred Subject credential
5020 @param vp Object vnode
5021 @param label Policy label for vp
5025 Determine whether the subject identified by the credential can set
5026 the passed uid and passed gid as file uid and file gid on the passed
5027 vnode. The IDs may be set to (-1) to request no update.
5029 @return Return 0 if access is granted, otherwise an appropriate value for
5030 errno should be returned. Suggested failure: EACCES for label mismatch or
5031 EPERM for lack of privilege.
5033 typedef int mpo_vnode_check_setowner_t(
5036 struct label
*label
,
5041 @brief Access control check for setting timestamps
5042 @param cred Subject credential
5043 @param vp Object vnode
5044 @param label Policy label for vp
5045 @param atime Access time; see utimes(2)
5046 @param mtime Modification time; see utimes(2)
5048 Determine whether the subject identified by the credential can set
5049 the passed access timestamps on the passed vnode.
5051 @return Return 0 if access is granted, otherwise an appropriate value for
5052 errno should be returned. Suggested failure: EACCES for label mismatch or
5053 EPERM for lack of privilege.
5055 typedef int mpo_vnode_check_setutimes_t(
5058 struct label
*label
,
5059 struct timespec atime
,
5060 struct timespec mtime
5063 @brief Access control check for stat
5064 @param active_cred Subject credential
5065 @param file_cred Credential associated with the struct fileproc
5066 @param vp Object vnode
5067 @param label Policy label for vp
5069 Determine whether the subject identified by the credential can stat
5070 the passed vnode. See stat(2) for more information. The active_cred
5071 hold the credentials of the subject performing the operation, and
5072 file_cred holds the credentials of the subject that originally
5075 @return Return 0 if access is granted, otherwise an appropriate value for
5076 errno should be returned. Suggested failure: EACCES for label mismatch or
5077 EPERM for lack of privilege.
5079 typedef int mpo_vnode_check_stat_t(
5080 struct ucred
*active_cred
,
5081 struct ucred
*file_cred
, /* NULLOK */
5086 @brief Access control check for truncate/ftruncate
5087 @param active_cred Subject credential
5088 @param file_cred Credential associated with the struct fileproc
5089 @param vp Object vnode
5090 @param label Policy label for vp
5092 Determine whether the subject identified by the credential can
5093 perform a truncate operation on the passed vnode. The active_cred hold
5094 the credentials of the subject performing the operation, and
5095 file_cred holds the credentials of the subject that originally
5098 @return Return 0 if access is granted, otherwise an appropriate value for
5099 errno should be returned. Suggested failure: EACCES for label mismatch or
5100 EPERM for lack of privilege.
5102 typedef int mpo_vnode_check_truncate_t(
5103 kauth_cred_t active_cred
,
5104 kauth_cred_t file_cred
, /* NULLOK */
5109 @brief Access control check for binding UNIX domain socket
5110 @param cred Subject credential
5111 @param dvp Directory vnode
5112 @param dlabel Policy label for dvp
5113 @param cnp Component name for dvp
5114 @param vap vnode attributes for vap
5116 Determine whether the subject identified by the credential can perform a
5117 bind operation on a UNIX domain socket with the passed parent directory,
5118 passed name information, and passed attribute information.
5120 @return Return 0 if access is granted, otherwise an appropriate value for
5121 errno should be returned. Suggested failure: EACCES for label mismatch or
5122 EPERM for lack of privilege.
5124 typedef int mpo_vnode_check_uipc_bind_t(
5127 struct label
*dlabel
,
5128 struct componentname
*cnp
,
5129 struct vnode_attr
*vap
5132 @brief Access control check for connecting UNIX domain socket
5133 @param cred Subject credential
5134 @param vp Object vnode
5135 @param label Policy label associated with vp
5137 Determine whether the subject identified by the credential can perform a
5138 connect operation on the passed UNIX domain socket vnode.
5140 @return Return 0 if access is granted, otherwise an appropriate value for
5141 errno should be returned. Suggested failure: EACCES for label mismatch or
5142 EPERM for lack of privilege.
5144 typedef int mpo_vnode_check_uipc_connect_t(
5150 @brief Access control check for deleting vnode
5151 @param cred Subject credential
5152 @param dvp Parent directory vnode
5153 @param dlabel Policy label for dvp
5154 @param vp Object vnode to delete
5155 @param label Policy label for vp
5156 @param cnp Component name for vp
5157 @see mpo_check_rename_to_t
5159 Determine whether the subject identified by the credential can delete
5160 a vnode from the passed parent directory and passed name information.
5161 This call may be made in a number of situations, including as a
5162 results of calls to unlink(2) and rmdir(2). Policies implementing
5163 this entry point should also implement mpo_check_rename_to to
5164 authorize deletion of objects as a result of being the target of a rename.
5166 @return Return 0 if access is granted, otherwise an appropriate value for
5167 errno should be returned. Suggested failure: EACCES for label mismatch or
5168 EPERM for lack of privilege.
5170 typedef int mpo_vnode_check_unlink_t(
5173 struct label
*dlabel
,
5175 struct label
*label
,
5176 struct componentname
*cnp
5179 @brief Access control check for write
5180 @param active_cred Subject credential
5181 @param file_cred Credential associated with the struct fileproc
5182 @param vp Object vnode
5183 @param label Policy label for vp
5185 Determine whether the subject identified by the credential can
5186 perform a write operation on the passed vnode. The active_cred hold
5187 the credentials of the subject performing the operation, and
5188 file_cred holds the credentials of the subject that originally
5191 @return Return 0 if access is granted, otherwise an appropriate value for
5192 errno should be returned. Suggested failure: EACCES for label mismatch or
5193 EPERM for lack of privilege.
5195 typedef int mpo_vnode_check_write_t(
5196 kauth_cred_t active_cred
,
5197 kauth_cred_t file_cred
, /* NULLOK */
5202 @brief Associate a vnode with a devfs entry
5203 @param mp Devfs mount point
5204 @param mntlabel Devfs mount point label
5205 @param de Devfs directory entry
5206 @param delabel Label associated with de
5207 @param vp vnode associated with de
5208 @param vlabel Label associated with vp
5210 Fill in the label (vlabel) for a newly created devfs vnode. The
5211 label is typically derived from the label on the devfs directory
5212 entry or the label on the filesystem, supplied as parameters.
5214 typedef void mpo_vnode_label_associate_devfs_t(
5216 struct label
*mntlabel
,
5218 struct label
*delabel
,
5220 struct label
*vlabel
5223 @brief Associate a label with a vnode
5224 @param mp File system mount point
5225 @param mntlabel File system mount point label
5226 @param vp Vnode to label
5227 @param vlabel Label associated with vp
5229 Attempt to retrieve label information for the vnode, vp, from the
5230 file system extended attribute store. The label should be stored in
5231 the supplied vlabel parameter. If a policy cannot retrieve an
5232 extended attribute, sometimes it is acceptible to fallback to using
5235 If the policy requires vnodes to have a valid label elsewhere it
5236 MUST NOT return other than temporary errors, and must always provide
5237 a valid label of some sort. Returning an error will cause vnode
5238 labeling to be retried at a later access. Failure to handle policy
5239 centric errors internally (corrupt labels etc.) will result in
5242 @return In the event of an error, an appropriate value for errno
5243 should be returned, otherwise return 0 upon success.
5245 typedef int mpo_vnode_label_associate_extattr_t(
5247 struct label
*mntlabel
,
5249 struct label
*vlabel
5252 @brief Associate a file label with a vnode
5253 @param cred User credential
5254 @param mp Fdesc mount point
5255 @param mntlabel Fdesc mount point label
5256 @param fg Fileglob structure
5257 @param label Policy label for fg
5258 @param vp Vnode to label
5259 @param vlabel Label associated with vp
5261 Associate label information for the vnode, vp, with the label of
5262 the open file descriptor described by fg.
5263 The label should be stored in the supplied vlabel parameter.
5265 typedef void mpo_vnode_label_associate_file_t(
5268 struct label
*mntlabel
,
5269 struct fileglob
*fg
,
5270 struct label
*label
,
5272 struct label
*vlabel
5275 @brief Associate a pipe label with a vnode
5276 @param cred User credential for the process that opened the pipe
5277 @param cpipe Pipe structure
5278 @param pipelabel Label associated with pipe
5279 @param vp Vnode to label
5280 @param vlabel Label associated with vp
5282 Associate label information for the vnode, vp, with the label of
5283 the pipe described by the pipe structure cpipe.
5284 The label should be stored in the supplied vlabel parameter.
5286 typedef void mpo_vnode_label_associate_pipe_t(
5289 struct label
*pipelabel
,
5291 struct label
*vlabel
5294 @brief Associate a POSIX semaphore label with a vnode
5295 @param cred User credential for the process that create psem
5296 @param psem POSIX semaphore structure
5297 @param psemlabel Label associated with psem
5298 @param vp Vnode to label
5299 @param vlabel Label associated with vp
5301 Associate label information for the vnode, vp, with the label of
5302 the POSIX semaphore described by psem.
5303 The label should be stored in the supplied vlabel parameter.
5305 typedef void mpo_vnode_label_associate_posixsem_t(
5307 struct pseminfo
*psem
,
5308 struct label
*psemlabel
,
5310 struct label
*vlabel
5313 @brief Associate a POSIX shared memory label with a vnode
5314 @param cred User credential for the process that created pshm
5315 @param pshm POSIX shared memory structure
5316 @param pshmlabel Label associated with pshm
5317 @param vp Vnode to label
5318 @param vlabel Label associated with vp
5320 Associate label information for the vnode, vp, with the label of
5321 the POSIX shared memory region described by pshm.
5322 The label should be stored in the supplied vlabel parameter.
5324 typedef void mpo_vnode_label_associate_posixshm_t(
5326 struct pshminfo
*pshm
,
5327 struct label
*pshmlabel
,
5329 struct label
*vlabel
5332 @brief Associate a label with a vnode
5333 @param mp File system mount point
5334 @param mntlabel File system mount point label
5335 @param vp Vnode to label
5336 @param vlabel Label associated with vp
5338 On non-multilabel file systems, set the label for a vnode. The
5339 label will most likely be based on the file system label.
5341 typedef void mpo_vnode_label_associate_singlelabel_t(
5343 struct label
*mntlabel
,
5345 struct label
*vlabel
5348 @brief Associate a socket label with a vnode
5349 @param cred User credential for the process that opened the socket
5350 @param so Socket structure
5351 @param solabel Label associated with so
5352 @param vp Vnode to label
5353 @param vlabel Label associated with vp
5355 Associate label information for the vnode, vp, with the label of
5356 the open socket described by the socket structure so.
5357 The label should be stored in the supplied vlabel parameter.
5359 typedef void mpo_vnode_label_associate_socket_t(
5362 struct label
*solabel
,
5364 struct label
*vlabel
5367 @brief Copy a vnode label
5368 @param src Source vnode label
5369 @param dest Destination vnode label
5371 Copy the vnode label information from src to dest. On Darwin, this
5372 is currently only necessary when executing interpreted scripts, but
5373 will later be used if vnode label externalization cannot be an
5376 typedef void mpo_vnode_label_copy_t(
5381 @brief Destroy vnode label
5382 @param label The label to be destroyed
5384 Destroy a vnode label. Since the object is going out of scope,
5385 policy modules should free any internal storage associated with the
5386 label so that it may be destroyed.
5388 typedef void mpo_vnode_label_destroy_t(
5392 @brief Externalize a vnode label for auditing
5393 @param label Label to be externalized
5394 @param element_name Name of the label namespace for which labels should be
5396 @param sb String buffer to be filled with a text representation of the label
5398 Produce an external representation of the label on a vnode suitable for
5399 inclusion in an audit record. An externalized label consists of a text
5400 representation of the label contents that will be added to the audit record
5401 as part of a text token. Policy-agnostic user space tools will display
5402 this externalized version.
5404 @return 0 on success, return non-zero if an error occurs while
5405 externalizing the label data.
5408 typedef int mpo_vnode_label_externalize_audit_t(
5409 struct label
*label
,
5414 @brief Externalize a vnode label
5415 @param label Label to be externalized
5416 @param element_name Name of the label namespace for which labels should be
5418 @param sb String buffer to be filled with a text representation of the label
5420 Produce an external representation of the label on a vnode. An
5421 externalized label consists of a text representation of the label
5422 contents that can be used with user applications. Policy-agnostic
5423 user space tools will display this externalized version.
5425 @return 0 on success, return non-zero if an error occurs while
5426 externalizing the label data.
5429 typedef int mpo_vnode_label_externalize_t(
5430 struct label
*label
,
5435 @brief Initialize vnode label
5436 @param label New label to initialize
5438 Initialize label storage for use with a newly instantiated vnode, or
5439 for temporary storage associated with the copying in or out of a
5440 vnode label. While it is necessary to allocate space for a
5441 kernel-resident vnode label, it is not yet necessary to link this vnode
5442 with persistent label storage facilities, such as extended attributes.
5443 Sleeping is permitted.
5445 typedef void mpo_vnode_label_init_t(
5449 @brief Internalize a vnode label
5450 @param label Label to be internalized
5451 @param element_name Name of the label namespace for which the label should
5453 @param element_data Text data to be internalized
5455 Produce a vnode label from an external representation. An
5456 externalized label consists of a text representation of the label
5457 contents that can be used with user applications. Policy-agnostic
5458 user space tools will forward text version to the kernel for
5459 processing by individual policy modules.
5461 The policy's internalize entry points will be called only if the
5462 policy has registered interest in the label namespace.
5464 @return 0 on success, Otherwise, return non-zero if an error occurs
5465 while internalizing the label data.
5467 typedef int mpo_vnode_label_internalize_t(
5468 struct label
*label
,
5473 @brief Clean up a vnode label
5474 @param label The label to be cleaned for re-use
5476 Clean up a vnode label. Darwin (Tiger, 8.x) allocates vnodes on demand, but
5477 typically never frees them. Before vnodes are placed back on free lists for
5478 re-use, policies can cleanup or overwrite any information present in the label.
5480 typedef void mpo_vnode_label_recycle_t(
5484 @brief Write a label to a extended attribute
5485 @param cred Subject credential
5486 @param vp The vnode for which the label is being stored
5487 @param vlabel Label associated with vp
5488 @param intlabel The new label to store
5490 Store a new label in the extended attribute corresponding to the
5491 supplied vnode. The policy has already authorized the operation;
5492 this call must be implemented in order to perform the actual
5495 @return In the event of an error, an appropriate value for errno
5496 should be returned, otherwise return 0 upon success.
5498 @warning XXX After examining the extended attribute implementation on
5499 Apple's future release, this entry point may be changed.
5501 typedef int mpo_vnode_label_store_t(
5504 struct label
*vlabel
,
5505 struct label
*intlabel
5508 @brief Update vnode label from extended attributes
5509 @param mp File system mount point
5510 @param mntlabel Mount point label
5511 @param vp Vnode to label
5512 @param vlabel Label associated with vp
5513 @param name Name of the xattr
5514 @see mpo_vnode_check_setextattr_t
5516 When an extended attribute is updated via the Vendor attribute management
5517 functions, the MAC vnode label might also require an update.
5518 Policies should first determine if 'name' matches their xattr label
5519 name. If it does, the kernel is has either replaced or removed the
5520 named extended attribute that was previously associated with the
5521 vnode. Normally labels should only be modified via MAC Framework label
5522 management calls, but sometimes the user space components will directly
5523 modify extended attributes. For example, 'cp', 'tar', etc. manage
5524 extended attributes in userspace, not the kernel.
5526 This entry point is called after the label update has occurred, so
5527 it cannot return a failure. However, the operation is preceded by
5528 the mpo_vnode_check_setextattr() access control check.
5530 If the vnode label needs to be updated the policy should return
5531 a non-zero value. The vnode label will be marked for re-association
5534 typedef int mpo_vnode_label_update_extattr_t(
5536 struct label
*mntlabel
,
5538 struct label
*vlabel
,
5542 @brief Update a vnode label
5543 @param cred Subject credential
5544 @param vp The vnode to relabel
5545 @param vnodelabel Existing vnode label
5546 @param label New label to replace existing label
5547 @see mpo_vnode_check_label_update_t
5549 The subject identified by the credential has previously requested
5550 and was authorized to relabel the vnode; this entry point allows
5551 policies to perform the actual relabel operation. Policies should
5552 update vnodelabel using the label stored in the label parameter.
5554 typedef void mpo_vnode_label_update_t(
5557 struct label
*vnodelabel
,
5561 @brief Find deatched signatures for a shared library
5562 @param p file trying to find the signature
5563 @param vp The vnode to relabel
5564 @param offset offset in the macho that the signature is requested for (for fat binaries)
5565 @param label Existing vnode label
5568 typedef int mpo_vnode_find_sigs_t(
5575 @brief Create a new vnode, backed by extended attributes
5576 @param cred User credential for the creating process
5577 @param mp File system mount point
5578 @param mntlabel File system mount point label
5579 @param dvp Parent directory vnode
5580 @param dlabel Parent directory vnode label
5581 @param vp Newly created vnode
5582 @param vlabel Label to associate with the new vnode
5583 @param cnp Component name for vp
5585 Write out the label for the newly created vnode, most likely storing
5586 the results in a file system extended attribute. Most policies will
5587 derive the new vnode label using information from a combination
5588 of the subject (user) credential, the file system label, the parent
5589 directory label, and potentially the path name component.
5591 @return If the operation succeeds, store the new label in vlabel and
5592 return 0. Otherwise, return an appropriate errno value.
5594 typedef int mpo_vnode_notify_create_t(
5597 struct label
*mntlabel
,
5599 struct label
*dlabel
,
5601 struct label
*vlabel
,
5602 struct componentname
*cnp
5606 @brief Inform MAC policies that a vnode has been opened
5607 @param cred User credential for the creating process
5608 @param vp vnode opened
5609 @param label Policy label for the vp
5610 @param acc_mode open(2) access mode used
5612 Inform Mac policies that a vnode have been successfully opened
5613 (passing all MAC polices and DAC).
5615 typedef void mpo_vnode_notify_open_t(
5618 struct label
*label
,
5623 @brief Inform MAC policies that a vnode has been renamed
5624 @param cred User credential for the renaming process
5625 @param vp Vnode that's being renamed
5626 @param label Policy label for vp
5627 @param dvp Parent directory for the destination
5628 @param dlabel Policy label for dvp
5629 @param cnp Component name for the destination
5631 Inform MAC policies that a vnode has been renamed.
5633 typedef void mpo_vnode_notify_rename_t(
5636 struct label
*label
,
5638 struct label
*dlabel
,
5639 struct componentname
*cnp
5643 @brief Inform MAC policies that a vnode has been linked
5644 @param cred User credential for the renaming process
5645 @param dvp Parent directory for the destination
5646 @param dlabel Policy label for dvp
5647 @param vp Vnode that's being linked
5648 @param vlabel Policy label for vp
5649 @param cnp Component name for the destination
5651 Inform MAC policies that a vnode has been linked.
5653 typedef void mpo_vnode_notify_link_t(
5656 struct label
*dlabel
,
5658 struct label
*vlabel
,
5659 struct componentname
*cnp
5663 @brief Inform MAC policies that a pty slave has been granted
5664 @param p Responsible process
5665 @param tp tty data structure
5666 @param dev Major and minor numbers of device
5667 @param label Policy label for tp
5669 Inform MAC policies that a pty slave has been granted.
5671 typedef void mpo_pty_notify_grant_t(
5679 @brief Inform MAC policies that a pty master has been closed
5680 @param p Responsible process
5681 @param tp tty data structure
5682 @param dev Major and minor numbers of device
5683 @param label Policy label for tp
5685 Inform MAC policies that a pty master has been closed.
5687 typedef void mpo_pty_notify_close_t(
5695 @brief Access control check for kext loading
5696 @param cred Subject credential
5697 @param identifier Kext identifier
5699 Determine whether the subject identified by the credential can load the
5702 @return Return 0 if access is granted, otherwise an appropriate value for
5703 errno should be returned. Suggested failure: EPERM for lack of privilege.
5705 typedef int mpo_kext_check_load_t(
5707 const char *identifier
5711 @brief Access control check for kext unloading
5712 @param cred Subject credential
5713 @param identifier Kext identifier
5715 Determine whether the subject identified by the credential can unload the
5718 @return Return 0 if access is granted, otherwise an appropriate value for
5719 errno should be returned. Suggested failure: EPERM for lack of privilege.
5721 typedef int mpo_kext_check_unload_t(
5723 const char *identifier
5727 @brief Access control check for querying information about loaded kexts
5728 @param cred Subject credential
5730 Determine whether the subject identified by the credential can query
5731 information about loaded kexts.
5733 @return Return 0 if access is granted, otherwise an appropriate value for
5734 errno should be returned. Suggested failure: EPERM for lack of privilege.
5736 typedef int mpo_kext_check_query_t(
5741 @brief Access control check for getting NVRAM variables.
5742 @param cred Subject credential
5743 @param name NVRAM variable to get
5745 Determine whether the subject identifier by the credential can get the
5746 value of the named NVRAM variable.
5748 @return Return 0 if access is granted, otherwise an appropriate value for
5749 errno should be returned. Suggested failure: EPERM for lack of privilege.
5751 typedef int mpo_iokit_check_nvram_get_t(
5757 @brief Access control check for setting NVRAM variables.
5758 @param cred Subject credential
5759 @param name NVRAM variable to set
5760 @param value The new value for the NVRAM variable
5762 Determine whether the subject identifier by the credential can set the
5763 value of the named NVRAM variable.
5765 @return Return 0 if access is granted, otherwise an appropriate value for
5766 errno should be returned. Suggested failure: EPERM for lack of privilege.
5768 typedef int mpo_iokit_check_nvram_set_t(
5775 @brief Access control check for deleting NVRAM variables.
5776 @param cred Subject credential
5777 @param name NVRAM variable to delete
5779 Determine whether the subject identifier by the credential can delete the
5780 named NVRAM variable.
5782 @return Return 0 if access is granted, otherwise an appropriate value for
5783 errno should be returned. Suggested failure: EPERM for lack of privilege.
5785 typedef int mpo_iokit_check_nvram_delete_t(
5791 * Placeholder for future events that may need mac hooks.
5793 typedef void mpo_reserved_hook_t(void);
5796 * Policy module operations.
5798 * Please note that this should be kept in sync with the check assumptions
5799 * policy in bsd/kern/policy_check.c (policy_ops struct).
5801 #define MAC_POLICY_OPS_VERSION 39 /* inc when new reserved slots are taken */
5802 struct mac_policy_ops
{
5803 mpo_audit_check_postselect_t
*mpo_audit_check_postselect
;
5804 mpo_audit_check_preselect_t
*mpo_audit_check_preselect
;
5806 mpo_bpfdesc_label_associate_t
*mpo_bpfdesc_label_associate
;
5807 mpo_bpfdesc_label_destroy_t
*mpo_bpfdesc_label_destroy
;
5808 mpo_bpfdesc_label_init_t
*mpo_bpfdesc_label_init
;
5809 mpo_bpfdesc_check_receive_t
*mpo_bpfdesc_check_receive
;
5811 mpo_cred_check_label_update_execve_t
*mpo_cred_check_label_update_execve
;
5812 mpo_cred_check_label_update_t
*mpo_cred_check_label_update
;
5813 mpo_cred_check_visible_t
*mpo_cred_check_visible
;
5814 mpo_cred_label_associate_fork_t
*mpo_cred_label_associate_fork
;
5815 mpo_cred_label_associate_kernel_t
*mpo_cred_label_associate_kernel
;
5816 mpo_cred_label_associate_t
*mpo_cred_label_associate
;
5817 mpo_cred_label_associate_user_t
*mpo_cred_label_associate_user
;
5818 mpo_cred_label_destroy_t
*mpo_cred_label_destroy
;
5819 mpo_cred_label_externalize_audit_t
*mpo_cred_label_externalize_audit
;
5820 mpo_cred_label_externalize_t
*mpo_cred_label_externalize
;
5821 mpo_cred_label_init_t
*mpo_cred_label_init
;
5822 mpo_cred_label_internalize_t
*mpo_cred_label_internalize
;
5823 mpo_cred_label_update_execve_t
*mpo_cred_label_update_execve
;
5824 mpo_cred_label_update_t
*mpo_cred_label_update
;
5826 mpo_devfs_label_associate_device_t
*mpo_devfs_label_associate_device
;
5827 mpo_devfs_label_associate_directory_t
*mpo_devfs_label_associate_directory
;
5828 mpo_devfs_label_copy_t
*mpo_devfs_label_copy
;
5829 mpo_devfs_label_destroy_t
*mpo_devfs_label_destroy
;
5830 mpo_devfs_label_init_t
*mpo_devfs_label_init
;
5831 mpo_devfs_label_update_t
*mpo_devfs_label_update
;
5833 mpo_file_check_change_offset_t
*mpo_file_check_change_offset
;
5834 mpo_file_check_create_t
*mpo_file_check_create
;
5835 mpo_file_check_dup_t
*mpo_file_check_dup
;
5836 mpo_file_check_fcntl_t
*mpo_file_check_fcntl
;
5837 mpo_file_check_get_offset_t
*mpo_file_check_get_offset
;
5838 mpo_file_check_get_t
*mpo_file_check_get
;
5839 mpo_file_check_inherit_t
*mpo_file_check_inherit
;
5840 mpo_file_check_ioctl_t
*mpo_file_check_ioctl
;
5841 mpo_file_check_lock_t
*mpo_file_check_lock
;
5842 mpo_file_check_mmap_downgrade_t
*mpo_file_check_mmap_downgrade
;
5843 mpo_file_check_mmap_t
*mpo_file_check_mmap
;
5844 mpo_file_check_receive_t
*mpo_file_check_receive
;
5845 mpo_file_check_set_t
*mpo_file_check_set
;
5846 mpo_file_label_init_t
*mpo_file_label_init
;
5847 mpo_file_label_destroy_t
*mpo_file_label_destroy
;
5848 mpo_file_label_associate_t
*mpo_file_label_associate
;
5850 mpo_ifnet_check_label_update_t
*mpo_ifnet_check_label_update
;
5851 mpo_ifnet_check_transmit_t
*mpo_ifnet_check_transmit
;
5852 mpo_ifnet_label_associate_t
*mpo_ifnet_label_associate
;
5853 mpo_ifnet_label_copy_t
*mpo_ifnet_label_copy
;
5854 mpo_ifnet_label_destroy_t
*mpo_ifnet_label_destroy
;
5855 mpo_ifnet_label_externalize_t
*mpo_ifnet_label_externalize
;
5856 mpo_ifnet_label_init_t
*mpo_ifnet_label_init
;
5857 mpo_ifnet_label_internalize_t
*mpo_ifnet_label_internalize
;
5858 mpo_ifnet_label_update_t
*mpo_ifnet_label_update
;
5859 mpo_ifnet_label_recycle_t
*mpo_ifnet_label_recycle
;
5861 mpo_inpcb_check_deliver_t
*mpo_inpcb_check_deliver
;
5862 mpo_inpcb_label_associate_t
*mpo_inpcb_label_associate
;
5863 mpo_inpcb_label_destroy_t
*mpo_inpcb_label_destroy
;
5864 mpo_inpcb_label_init_t
*mpo_inpcb_label_init
;
5865 mpo_inpcb_label_recycle_t
*mpo_inpcb_label_recycle
;
5866 mpo_inpcb_label_update_t
*mpo_inpcb_label_update
;
5868 mpo_iokit_check_device_t
*mpo_iokit_check_device
;
5870 mpo_ipq_label_associate_t
*mpo_ipq_label_associate
;
5871 mpo_ipq_label_compare_t
*mpo_ipq_label_compare
;
5872 mpo_ipq_label_destroy_t
*mpo_ipq_label_destroy
;
5873 mpo_ipq_label_init_t
*mpo_ipq_label_init
;
5874 mpo_ipq_label_update_t
*mpo_ipq_label_update
;
5876 mpo_reserved_hook_t
*mpo_reserved1
;
5877 mpo_reserved_hook_t
*mpo_reserved2
;
5878 mpo_reserved_hook_t
*mpo_reserved3
;
5879 mpo_reserved_hook_t
*mpo_reserved4
;
5880 mpo_reserved_hook_t
*mpo_reserved5
;
5881 mpo_reserved_hook_t
*mpo_reserved6
;
5882 mpo_reserved_hook_t
*mpo_reserved7
;
5883 mpo_reserved_hook_t
*mpo_reserved8
;
5884 mpo_reserved_hook_t
*mpo_reserved9
;
5886 mpo_mbuf_label_associate_bpfdesc_t
*mpo_mbuf_label_associate_bpfdesc
;
5887 mpo_mbuf_label_associate_ifnet_t
*mpo_mbuf_label_associate_ifnet
;
5888 mpo_mbuf_label_associate_inpcb_t
*mpo_mbuf_label_associate_inpcb
;
5889 mpo_mbuf_label_associate_ipq_t
*mpo_mbuf_label_associate_ipq
;
5890 mpo_mbuf_label_associate_linklayer_t
*mpo_mbuf_label_associate_linklayer
;
5891 mpo_mbuf_label_associate_multicast_encap_t
*mpo_mbuf_label_associate_multicast_encap
;
5892 mpo_mbuf_label_associate_netlayer_t
*mpo_mbuf_label_associate_netlayer
;
5893 mpo_mbuf_label_associate_socket_t
*mpo_mbuf_label_associate_socket
;
5894 mpo_mbuf_label_copy_t
*mpo_mbuf_label_copy
;
5895 mpo_mbuf_label_destroy_t
*mpo_mbuf_label_destroy
;
5896 mpo_mbuf_label_init_t
*mpo_mbuf_label_init
;
5898 mpo_mount_check_fsctl_t
*mpo_mount_check_fsctl
;
5899 mpo_mount_check_getattr_t
*mpo_mount_check_getattr
;
5900 mpo_mount_check_label_update_t
*mpo_mount_check_label_update
;
5901 mpo_mount_check_mount_t
*mpo_mount_check_mount
;
5902 mpo_mount_check_remount_t
*mpo_mount_check_remount
;
5903 mpo_mount_check_setattr_t
*mpo_mount_check_setattr
;
5904 mpo_mount_check_stat_t
*mpo_mount_check_stat
;
5905 mpo_mount_check_umount_t
*mpo_mount_check_umount
;
5906 mpo_mount_label_associate_t
*mpo_mount_label_associate
;
5907 mpo_mount_label_destroy_t
*mpo_mount_label_destroy
;
5908 mpo_mount_label_externalize_t
*mpo_mount_label_externalize
;
5909 mpo_mount_label_init_t
*mpo_mount_label_init
;
5910 mpo_mount_label_internalize_t
*mpo_mount_label_internalize
;
5912 mpo_netinet_fragment_t
*mpo_netinet_fragment
;
5913 mpo_netinet_icmp_reply_t
*mpo_netinet_icmp_reply
;
5914 mpo_netinet_tcp_reply_t
*mpo_netinet_tcp_reply
;
5916 mpo_pipe_check_ioctl_t
*mpo_pipe_check_ioctl
;
5917 mpo_pipe_check_kqfilter_t
*mpo_pipe_check_kqfilter
;
5918 mpo_pipe_check_label_update_t
*mpo_pipe_check_label_update
;
5919 mpo_pipe_check_read_t
*mpo_pipe_check_read
;
5920 mpo_pipe_check_select_t
*mpo_pipe_check_select
;
5921 mpo_pipe_check_stat_t
*mpo_pipe_check_stat
;
5922 mpo_pipe_check_write_t
*mpo_pipe_check_write
;
5923 mpo_pipe_label_associate_t
*mpo_pipe_label_associate
;
5924 mpo_pipe_label_copy_t
*mpo_pipe_label_copy
;
5925 mpo_pipe_label_destroy_t
*mpo_pipe_label_destroy
;
5926 mpo_pipe_label_externalize_t
*mpo_pipe_label_externalize
;
5927 mpo_pipe_label_init_t
*mpo_pipe_label_init
;
5928 mpo_pipe_label_internalize_t
*mpo_pipe_label_internalize
;
5929 mpo_pipe_label_update_t
*mpo_pipe_label_update
;
5931 mpo_policy_destroy_t
*mpo_policy_destroy
;
5932 mpo_policy_init_t
*mpo_policy_init
;
5933 mpo_policy_initbsd_t
*mpo_policy_initbsd
;
5934 mpo_policy_syscall_t
*mpo_policy_syscall
;
5936 mpo_system_check_sysctlbyname_t
*mpo_system_check_sysctlbyname
;
5937 mpo_proc_check_inherit_ipc_ports_t
*mpo_proc_check_inherit_ipc_ports
;
5938 mpo_vnode_check_rename_t
*mpo_vnode_check_rename
;
5939 mpo_kext_check_query_t
*mpo_kext_check_query
;
5940 mpo_iokit_check_nvram_get_t
*mpo_iokit_check_nvram_get
;
5941 mpo_iokit_check_nvram_set_t
*mpo_iokit_check_nvram_set
;
5942 mpo_iokit_check_nvram_delete_t
*mpo_iokit_check_nvram_delete
;
5943 mpo_proc_check_expose_task_t
*mpo_proc_check_expose_task
;
5944 mpo_proc_check_set_host_special_port_t
*mpo_proc_check_set_host_special_port
;
5945 mpo_proc_check_set_host_exception_port_t
*mpo_proc_check_set_host_exception_port
;
5946 mpo_reserved_hook_t
*mpo_reserved11
;
5947 mpo_reserved_hook_t
*mpo_reserved12
;
5948 mpo_reserved_hook_t
*mpo_reserved13
;
5949 mpo_reserved_hook_t
*mpo_reserved14
;
5950 mpo_reserved_hook_t
*mpo_reserved15
;
5951 mpo_reserved_hook_t
*mpo_reserved16
;
5952 mpo_reserved_hook_t
*mpo_reserved17
;
5953 mpo_reserved_hook_t
*mpo_reserved18
;
5954 mpo_reserved_hook_t
*mpo_reserved19
;
5955 mpo_reserved_hook_t
*mpo_reserved20
;
5956 mpo_reserved_hook_t
*mpo_reserved21
;
5957 mpo_reserved_hook_t
*mpo_reserved22
;
5959 mpo_posixsem_check_create_t
*mpo_posixsem_check_create
;
5960 mpo_posixsem_check_open_t
*mpo_posixsem_check_open
;
5961 mpo_posixsem_check_post_t
*mpo_posixsem_check_post
;
5962 mpo_posixsem_check_unlink_t
*mpo_posixsem_check_unlink
;
5963 mpo_posixsem_check_wait_t
*mpo_posixsem_check_wait
;
5964 mpo_posixsem_label_associate_t
*mpo_posixsem_label_associate
;
5965 mpo_posixsem_label_destroy_t
*mpo_posixsem_label_destroy
;
5966 mpo_posixsem_label_init_t
*mpo_posixsem_label_init
;
5967 mpo_posixshm_check_create_t
*mpo_posixshm_check_create
;
5968 mpo_posixshm_check_mmap_t
*mpo_posixshm_check_mmap
;
5969 mpo_posixshm_check_open_t
*mpo_posixshm_check_open
;
5970 mpo_posixshm_check_stat_t
*mpo_posixshm_check_stat
;
5971 mpo_posixshm_check_truncate_t
*mpo_posixshm_check_truncate
;
5972 mpo_posixshm_check_unlink_t
*mpo_posixshm_check_unlink
;
5973 mpo_posixshm_label_associate_t
*mpo_posixshm_label_associate
;
5974 mpo_posixshm_label_destroy_t
*mpo_posixshm_label_destroy
;
5975 mpo_posixshm_label_init_t
*mpo_posixshm_label_init
;
5977 mpo_proc_check_debug_t
*mpo_proc_check_debug
;
5978 mpo_proc_check_fork_t
*mpo_proc_check_fork
;
5979 mpo_proc_check_get_task_name_t
*mpo_proc_check_get_task_name
;
5980 mpo_proc_check_get_task_t
*mpo_proc_check_get_task
;
5981 mpo_proc_check_getaudit_t
*mpo_proc_check_getaudit
;
5982 mpo_proc_check_getauid_t
*mpo_proc_check_getauid
;
5983 mpo_proc_check_getlcid_t
*mpo_proc_check_getlcid
;
5984 mpo_proc_check_mprotect_t
*mpo_proc_check_mprotect
;
5985 mpo_proc_check_sched_t
*mpo_proc_check_sched
;
5986 mpo_proc_check_setaudit_t
*mpo_proc_check_setaudit
;
5987 mpo_proc_check_setauid_t
*mpo_proc_check_setauid
;
5988 mpo_proc_check_setlcid_t
*mpo_proc_check_setlcid
;
5989 mpo_proc_check_signal_t
*mpo_proc_check_signal
;
5990 mpo_proc_check_wait_t
*mpo_proc_check_wait
;
5991 mpo_proc_label_destroy_t
*mpo_proc_label_destroy
;
5992 mpo_proc_label_init_t
*mpo_proc_label_init
;
5994 mpo_socket_check_accept_t
*mpo_socket_check_accept
;
5995 mpo_socket_check_accepted_t
*mpo_socket_check_accepted
;
5996 mpo_socket_check_bind_t
*mpo_socket_check_bind
;
5997 mpo_socket_check_connect_t
*mpo_socket_check_connect
;
5998 mpo_socket_check_create_t
*mpo_socket_check_create
;
5999 mpo_socket_check_deliver_t
*mpo_socket_check_deliver
;
6000 mpo_socket_check_kqfilter_t
*mpo_socket_check_kqfilter
;
6001 mpo_socket_check_label_update_t
*mpo_socket_check_label_update
;
6002 mpo_socket_check_listen_t
*mpo_socket_check_listen
;
6003 mpo_socket_check_receive_t
*mpo_socket_check_receive
;
6004 mpo_socket_check_received_t
*mpo_socket_check_received
;
6005 mpo_socket_check_select_t
*mpo_socket_check_select
;
6006 mpo_socket_check_send_t
*mpo_socket_check_send
;
6007 mpo_socket_check_stat_t
*mpo_socket_check_stat
;
6008 mpo_socket_check_setsockopt_t
*mpo_socket_check_setsockopt
;
6009 mpo_socket_check_getsockopt_t
*mpo_socket_check_getsockopt
;
6010 mpo_socket_label_associate_accept_t
*mpo_socket_label_associate_accept
;
6011 mpo_socket_label_associate_t
*mpo_socket_label_associate
;
6012 mpo_socket_label_copy_t
*mpo_socket_label_copy
;
6013 mpo_socket_label_destroy_t
*mpo_socket_label_destroy
;
6014 mpo_socket_label_externalize_t
*mpo_socket_label_externalize
;
6015 mpo_socket_label_init_t
*mpo_socket_label_init
;
6016 mpo_socket_label_internalize_t
*mpo_socket_label_internalize
;
6017 mpo_socket_label_update_t
*mpo_socket_label_update
;
6019 mpo_socketpeer_label_associate_mbuf_t
*mpo_socketpeer_label_associate_mbuf
;
6020 mpo_socketpeer_label_associate_socket_t
*mpo_socketpeer_label_associate_socket
;
6021 mpo_socketpeer_label_destroy_t
*mpo_socketpeer_label_destroy
;
6022 mpo_socketpeer_label_externalize_t
*mpo_socketpeer_label_externalize
;
6023 mpo_socketpeer_label_init_t
*mpo_socketpeer_label_init
;
6025 mpo_system_check_acct_t
*mpo_system_check_acct
;
6026 mpo_system_check_audit_t
*mpo_system_check_audit
;
6027 mpo_system_check_auditctl_t
*mpo_system_check_auditctl
;
6028 mpo_system_check_auditon_t
*mpo_system_check_auditon
;
6029 mpo_system_check_host_priv_t
*mpo_system_check_host_priv
;
6030 mpo_system_check_nfsd_t
*mpo_system_check_nfsd
;
6031 mpo_system_check_reboot_t
*mpo_system_check_reboot
;
6032 mpo_system_check_settime_t
*mpo_system_check_settime
;
6033 mpo_system_check_swapoff_t
*mpo_system_check_swapoff
;
6034 mpo_system_check_swapon_t
*mpo_system_check_swapon
;
6035 mpo_reserved_hook_t
*mpo_reserved31
;
6037 mpo_sysvmsg_label_associate_t
*mpo_sysvmsg_label_associate
;
6038 mpo_sysvmsg_label_destroy_t
*mpo_sysvmsg_label_destroy
;
6039 mpo_sysvmsg_label_init_t
*mpo_sysvmsg_label_init
;
6040 mpo_sysvmsg_label_recycle_t
*mpo_sysvmsg_label_recycle
;
6041 mpo_sysvmsq_check_enqueue_t
*mpo_sysvmsq_check_enqueue
;
6042 mpo_sysvmsq_check_msgrcv_t
*mpo_sysvmsq_check_msgrcv
;
6043 mpo_sysvmsq_check_msgrmid_t
*mpo_sysvmsq_check_msgrmid
;
6044 mpo_sysvmsq_check_msqctl_t
*mpo_sysvmsq_check_msqctl
;
6045 mpo_sysvmsq_check_msqget_t
*mpo_sysvmsq_check_msqget
;
6046 mpo_sysvmsq_check_msqrcv_t
*mpo_sysvmsq_check_msqrcv
;
6047 mpo_sysvmsq_check_msqsnd_t
*mpo_sysvmsq_check_msqsnd
;
6048 mpo_sysvmsq_label_associate_t
*mpo_sysvmsq_label_associate
;
6049 mpo_sysvmsq_label_destroy_t
*mpo_sysvmsq_label_destroy
;
6050 mpo_sysvmsq_label_init_t
*mpo_sysvmsq_label_init
;
6051 mpo_sysvmsq_label_recycle_t
*mpo_sysvmsq_label_recycle
;
6052 mpo_sysvsem_check_semctl_t
*mpo_sysvsem_check_semctl
;
6053 mpo_sysvsem_check_semget_t
*mpo_sysvsem_check_semget
;
6054 mpo_sysvsem_check_semop_t
*mpo_sysvsem_check_semop
;
6055 mpo_sysvsem_label_associate_t
*mpo_sysvsem_label_associate
;
6056 mpo_sysvsem_label_destroy_t
*mpo_sysvsem_label_destroy
;
6057 mpo_sysvsem_label_init_t
*mpo_sysvsem_label_init
;
6058 mpo_sysvsem_label_recycle_t
*mpo_sysvsem_label_recycle
;
6059 mpo_sysvshm_check_shmat_t
*mpo_sysvshm_check_shmat
;
6060 mpo_sysvshm_check_shmctl_t
*mpo_sysvshm_check_shmctl
;
6061 mpo_sysvshm_check_shmdt_t
*mpo_sysvshm_check_shmdt
;
6062 mpo_sysvshm_check_shmget_t
*mpo_sysvshm_check_shmget
;
6063 mpo_sysvshm_label_associate_t
*mpo_sysvshm_label_associate
;
6064 mpo_sysvshm_label_destroy_t
*mpo_sysvshm_label_destroy
;
6065 mpo_sysvshm_label_init_t
*mpo_sysvshm_label_init
;
6066 mpo_sysvshm_label_recycle_t
*mpo_sysvshm_label_recycle
;
6068 mpo_reserved_hook_t
*mpo_reserved23
;
6069 mpo_reserved_hook_t
*mpo_reserved24
;
6070 mpo_reserved_hook_t
*mpo_reserved25
;
6071 mpo_reserved_hook_t
*mpo_reserved26
;
6072 mpo_reserved_hook_t
*mpo_reserved27
;
6073 mpo_reserved_hook_t
*mpo_reserved28
;
6074 mpo_proc_check_get_cs_info_t
*mpo_proc_check_get_cs_info
;
6075 mpo_proc_check_set_cs_info_t
*mpo_proc_check_set_cs_info
;
6077 mpo_iokit_check_hid_control_t
*mpo_iokit_check_hid_control
;
6079 mpo_vnode_check_access_t
*mpo_vnode_check_access
;
6080 mpo_vnode_check_chdir_t
*mpo_vnode_check_chdir
;
6081 mpo_vnode_check_chroot_t
*mpo_vnode_check_chroot
;
6082 mpo_vnode_check_create_t
*mpo_vnode_check_create
;
6083 mpo_vnode_check_deleteextattr_t
*mpo_vnode_check_deleteextattr
;
6084 mpo_vnode_check_exchangedata_t
*mpo_vnode_check_exchangedata
;
6085 mpo_vnode_check_exec_t
*mpo_vnode_check_exec
;
6086 mpo_vnode_check_getattrlist_t
*mpo_vnode_check_getattrlist
;
6087 mpo_vnode_check_getextattr_t
*mpo_vnode_check_getextattr
;
6088 mpo_vnode_check_ioctl_t
*mpo_vnode_check_ioctl
;
6089 mpo_vnode_check_kqfilter_t
*mpo_vnode_check_kqfilter
;
6090 mpo_vnode_check_label_update_t
*mpo_vnode_check_label_update
;
6091 mpo_vnode_check_link_t
*mpo_vnode_check_link
;
6092 mpo_vnode_check_listextattr_t
*mpo_vnode_check_listextattr
;
6093 mpo_vnode_check_lookup_t
*mpo_vnode_check_lookup
;
6094 mpo_vnode_check_open_t
*mpo_vnode_check_open
;
6095 mpo_vnode_check_read_t
*mpo_vnode_check_read
;
6096 mpo_vnode_check_readdir_t
*mpo_vnode_check_readdir
;
6097 mpo_vnode_check_readlink_t
*mpo_vnode_check_readlink
;
6098 mpo_vnode_check_rename_from_t
*mpo_vnode_check_rename_from
;
6099 mpo_vnode_check_rename_to_t
*mpo_vnode_check_rename_to
;
6100 mpo_vnode_check_revoke_t
*mpo_vnode_check_revoke
;
6101 mpo_vnode_check_select_t
*mpo_vnode_check_select
;
6102 mpo_vnode_check_setattrlist_t
*mpo_vnode_check_setattrlist
;
6103 mpo_vnode_check_setextattr_t
*mpo_vnode_check_setextattr
;
6104 mpo_vnode_check_setflags_t
*mpo_vnode_check_setflags
;
6105 mpo_vnode_check_setmode_t
*mpo_vnode_check_setmode
;
6106 mpo_vnode_check_setowner_t
*mpo_vnode_check_setowner
;
6107 mpo_vnode_check_setutimes_t
*mpo_vnode_check_setutimes
;
6108 mpo_vnode_check_stat_t
*mpo_vnode_check_stat
;
6109 mpo_vnode_check_truncate_t
*mpo_vnode_check_truncate
;
6110 mpo_vnode_check_unlink_t
*mpo_vnode_check_unlink
;
6111 mpo_vnode_check_write_t
*mpo_vnode_check_write
;
6112 mpo_vnode_label_associate_devfs_t
*mpo_vnode_label_associate_devfs
;
6113 mpo_vnode_label_associate_extattr_t
*mpo_vnode_label_associate_extattr
;
6114 mpo_vnode_label_associate_file_t
*mpo_vnode_label_associate_file
;
6115 mpo_vnode_label_associate_pipe_t
*mpo_vnode_label_associate_pipe
;
6116 mpo_vnode_label_associate_posixsem_t
*mpo_vnode_label_associate_posixsem
;
6117 mpo_vnode_label_associate_posixshm_t
*mpo_vnode_label_associate_posixshm
;
6118 mpo_vnode_label_associate_singlelabel_t
*mpo_vnode_label_associate_singlelabel
;
6119 mpo_vnode_label_associate_socket_t
*mpo_vnode_label_associate_socket
;
6120 mpo_vnode_label_copy_t
*mpo_vnode_label_copy
;
6121 mpo_vnode_label_destroy_t
*mpo_vnode_label_destroy
;
6122 mpo_vnode_label_externalize_audit_t
*mpo_vnode_label_externalize_audit
;
6123 mpo_vnode_label_externalize_t
*mpo_vnode_label_externalize
;
6124 mpo_vnode_label_init_t
*mpo_vnode_label_init
;
6125 mpo_vnode_label_internalize_t
*mpo_vnode_label_internalize
;
6126 mpo_vnode_label_recycle_t
*mpo_vnode_label_recycle
;
6127 mpo_vnode_label_store_t
*mpo_vnode_label_store
;
6128 mpo_vnode_label_update_extattr_t
*mpo_vnode_label_update_extattr
;
6129 mpo_vnode_label_update_t
*mpo_vnode_label_update
;
6130 mpo_vnode_notify_create_t
*mpo_vnode_notify_create
;
6131 mpo_vnode_check_signature_t
*mpo_vnode_check_signature
;
6132 mpo_vnode_check_uipc_bind_t
*mpo_vnode_check_uipc_bind
;
6133 mpo_vnode_check_uipc_connect_t
*mpo_vnode_check_uipc_connect
;
6135 mpo_proc_check_run_cs_invalid_t
*mpo_proc_check_run_cs_invalid
;
6136 mpo_proc_check_suspend_resume_t
*mpo_proc_check_suspend_resume
;
6138 mpo_thread_userret_t
*mpo_thread_userret
;
6140 mpo_iokit_check_set_properties_t
*mpo_iokit_check_set_properties
;
6142 mpo_system_check_chud_t
*mpo_system_check_chud
;
6144 mpo_vnode_check_searchfs_t
*mpo_vnode_check_searchfs
;
6146 mpo_priv_check_t
*mpo_priv_check
;
6147 mpo_priv_grant_t
*mpo_priv_grant
;
6149 mpo_proc_check_map_anon_t
*mpo_proc_check_map_anon
;
6151 mpo_vnode_check_fsgetpath_t
*mpo_vnode_check_fsgetpath
;
6153 mpo_iokit_check_open_t
*mpo_iokit_check_open
;
6155 mpo_proc_check_ledger_t
*mpo_proc_check_ledger
;
6157 mpo_vnode_notify_rename_t
*mpo_vnode_notify_rename
;
6159 mpo_reserved_hook_t
*mpo_reserved32
;
6160 mpo_reserved_hook_t
*mpo_reserved33
;
6162 mpo_system_check_kas_info_t
*mpo_system_check_kas_info
;
6164 mpo_proc_check_cpumon_t
*mpo_proc_check_cpumon
;
6166 mpo_vnode_notify_open_t
*mpo_vnode_notify_open
;
6168 mpo_system_check_info_t
*mpo_system_check_info
;
6170 mpo_pty_notify_grant_t
*mpo_pty_notify_grant
;
6171 mpo_pty_notify_close_t
*mpo_pty_notify_close
;
6173 mpo_vnode_find_sigs_t
*mpo_vnode_find_sigs
;
6175 mpo_kext_check_load_t
*mpo_kext_check_load
;
6176 mpo_kext_check_unload_t
*mpo_kext_check_unload
;
6178 mpo_proc_check_proc_info_t
*mpo_proc_check_proc_info
;
6179 mpo_vnode_notify_link_t
*mpo_vnode_notify_link
;
6180 mpo_iokit_check_filter_properties_t
*mpo_iokit_check_filter_properties
;
6181 mpo_iokit_check_get_property_t
*mpo_iokit_check_get_property
;
6185 @brief MAC policy handle type
6187 The MAC handle is used to uniquely identify a loaded policy within
6190 A variable of this type is set by mac_policy_register().
6192 typedef unsigned int mac_policy_handle_t
;
6194 #define mpc_t struct mac_policy_conf *
6197 @brief Mac policy configuration
6199 This structure specifies the configuration information for a
6200 MAC policy module. A policy module developer must supply
6201 a short unique policy name, a more descriptive full name, a list of label
6202 namespaces and count, a pointer to the registered enty point operations,
6203 any load time flags, and optionally, a pointer to a label slot identifier.
6205 The Framework will update the runtime flags (mpc_runtime_flags) to
6206 indicate that the module has been registered.
6208 If the label slot identifier (mpc_field_off) is NULL, the Framework
6209 will not provide label storage for the policy. Otherwise, the
6210 Framework will store the label location (slot) in this field.
6212 The mpc_list field is used by the Framework and should not be
6213 modified by policies.
6215 /* XXX - reorder these for better aligment on 64bit platforms */
6216 struct mac_policy_conf
{
6217 const char *mpc_name
; /** policy name */
6218 const char *mpc_fullname
; /** full name */
6219 const char **mpc_labelnames
; /** managed label namespaces */
6220 unsigned int mpc_labelname_count
; /** number of managed label namespaces */
6221 struct mac_policy_ops
*mpc_ops
; /** operation vector */
6222 int mpc_loadtime_flags
; /** load time flags */
6223 int *mpc_field_off
; /** label slot */
6224 int mpc_runtime_flags
; /** run time flags */
6225 mpc_t mpc_list
; /** List reference */
6226 void *mpc_data
; /** module data */
6230 @brief MAC policy module registration routine
6232 This function is called to register a policy with the
6233 MAC framework. A policy module will typically call this from the
6234 Darwin KEXT registration routine.
6236 int mac_policy_register(struct mac_policy_conf
*mpc
,
6237 mac_policy_handle_t
*handlep
, void *xd
);
6240 @brief MAC policy module de-registration routine
6242 This function is called to de-register a policy with theD
6243 MAC framework. A policy module will typically call this from the
6244 Darwin KEXT de-registration routine.
6246 int mac_policy_unregister(mac_policy_handle_t handle
);
6249 * Framework entry points for the policies to add audit data.
6251 int mac_audit_text(char *text
, mac_policy_handle_t handle
);
6254 * Calls to assist with use of Apple XATTRs within policy modules.
6256 int mac_vnop_setxattr(struct vnode
*, const char *, char *, size_t);
6257 int mac_vnop_getxattr(struct vnode
*, const char *, char *, size_t,
6259 int mac_vnop_removexattr(struct vnode
*, const char *);
6262 * Arbitrary limit on how much data will be logged by the audit
6263 * entry points above.
6265 #define MAC_AUDIT_DATA_LIMIT 1024
6268 * Values returned by mac_audit_{pre,post}select. To combine the responses
6269 * of the security policies into a single decision,
6270 * mac_audit_{pre,post}select() choose the greatest value returned.
6272 #define MAC_AUDIT_DEFAULT 0 /* use system behavior */
6273 #define MAC_AUDIT_NO 1 /* force not auditing this event */
6274 #define MAC_AUDIT_YES 2 /* force auditing this event */
6276 // \defgroup mpc_loadtime_flags Flags for the mpc_loadtime_flags field
6279 @name Flags for the mpc_loadtime_flags field
6280 @see mac_policy_conf
6282 This is the complete list of flags that are supported by the
6283 mpc_loadtime_flags field of the mac_policy_conf structure. These
6284 flags specify the load time behavior of MAC Framework policy
6291 @brief Flag to indicate registration preference
6293 This flag indicates that the policy module must be loaded and
6294 initialized early in the boot process. If the flag is specified,
6295 attempts to register the module following boot will be rejected. The
6296 flag may be used by policies that require pervasive labeling of all
6297 system objects, and cannot handle objects that have not been
6298 properly initialized by the policy.
6300 #define MPC_LOADTIME_FLAG_NOTLATE 0x00000001
6303 @brief Flag to indicate unload preference
6305 This flag indicates that the policy module may be unloaded. If this
6306 flag is not set, then the policy framework will reject requests to
6307 unload the module. This flag might be used by modules that allocate
6308 label state and are unable to free that state at runtime, or for
6309 modules that simply do not want to permit unload operations.
6311 #define MPC_LOADTIME_FLAG_UNLOADOK 0x00000002
6316 XXX This flag is not yet supported.
6318 #define MPC_LOADTIME_FLAG_LABELMBUFS 0x00000004
6321 @brief Flag to indicate a base policy
6323 This flag indicates that the policy module is a base policy. Only
6324 one module can declare itself as base, otherwise the boot process
6327 #define MPC_LOADTIME_BASE_POLICY 0x00000008
6332 @brief Policy registration flag
6333 @see mac_policy_conf
6335 This flag indicates that the policy module has been successfully
6336 registered with the TrustedBSD MAC Framework. The Framework will
6337 set this flag in the mpc_runtime_flags field of the policy's
6338 mac_policy_conf structure after registering the policy.
6340 #define MPC_RUNTIME_FLAG_REGISTERED 0x00000001
6343 * Depends on POLICY_VER
6347 #define POLICY_VER 1.0
6350 #define MAC_POLICY_SET(handle, mpops, mpname, mpfullname, lnames, lcount, slot, lflags, rflags) \
6351 static struct mac_policy_conf mpname##_mac_policy_conf = { \
6352 .mpc_name = #mpname, \
6353 .mpc_fullname = mpfullname, \
6354 .mpc_labelnames = lnames, \
6355 .mpc_labelname_count = lcount, \
6357 .mpc_loadtime_flags = lflags, \
6358 .mpc_field_off = slot, \
6359 .mpc_runtime_flags = rflags \
6362 static kern_return_t \
6363 kmod_start(kmod_info_t *ki, void *xd) \
6365 return mac_policy_register(&mpname##_mac_policy_conf, \
6369 static kern_return_t \
6370 kmod_stop(kmod_info_t *ki, void *xd) \
6372 return mac_policy_unregister(handle); \
6375 extern kern_return_t _start(kmod_info_t *ki, void *data); \
6376 extern kern_return_t _stop(kmod_info_t *ki, void *data); \
6378 KMOD_EXPLICIT_DECL(security.mpname, POLICY_VER, _start, _stop) \
6379 kmod_start_func_t *_realmain = kmod_start; \
6380 kmod_stop_func_t *_antimain = kmod_stop; \
6381 int _kext_apple_cc = __APPLE_CC__
6384 #define LABEL_TO_SLOT(l, s) (l)->l_perpolicy[s]
6387 * Policy interface to map a struct label pointer to per-policy data.
6388 * Typically, policies wrap this in their own accessor macro that casts an
6389 * intptr_t to a policy-specific data type.
6391 intptr_t mac_label_get(struct label
*l
, int slot
);
6392 void mac_label_set(struct label
*l
, int slot
, intptr_t v
);
6394 #define mac_get_mpc(h) (mac_policy_list.entries[h].mpc)
6397 @name Flags for MAC allocator interfaces
6399 These flags are passed to the Darwin kernel allocator routines to
6400 indicate whether the allocation is permitted to block or not.
6401 Caution should be taken; some operations are not permitted to sleep,
6402 and some types of locks cannot be held when sleeping.
6408 @brief Allocation operations may block
6410 If memory is not immediately available, the allocation routine
6411 will block (typically sleeping) until memory is available.
6413 @warning Inappropriate use of this flag may cause kernel panics.
6415 #define MAC_WAITOK 0
6418 @brief Allocation operations may not block
6420 Rather than blocking, the allocator may return an error if memory
6421 is not immediately available. This type of allocation will not
6422 sleep, preserving locking semantics.
6424 #define MAC_NOWAIT 1
6428 #endif /* !_SECURITY_MAC_POLICY_H_ */