2 * Copyright (c) 2007-2016 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>
94 struct exception_action
;
100 struct mac_module_data
;
101 struct mac_policy_conf
;
124 #ifndef _KAUTH_CRED_T
125 #define _KAUTH_CRED_T
126 typedef struct ucred
*kauth_cred_t
;
127 #endif /* !_KAUTH_CRED_T */
129 #ifndef __IOKIT_PORTS_DEFINED__
130 #define __IOKIT_PORTS_DEFINED__
133 typedef OSObject
*io_object_t
;
136 typedef struct OSObject
*io_object_t
;
138 #endif /* __IOKIT_PORTS_DEFINED__ */
141 * MAC entry points are generally named using the following template:
143 * mpo_<object>_<operation>()
147 * mpo_<object>_check_<operation>()
149 * Entry points are sorted by object type.
151 * It may be desirable also to consider some subsystems as "objects", such
152 * as system, iokit, etc.
156 @name Entry Points for Label Management
158 These are the entry points corresponding to the life cycle events for
159 kernel objects, such as initialization, creation, and destruction.
161 Most policies (that use labels) will initialize labels by allocating
162 space for policy-specific data. In most cases, it is permitted to
163 sleep during label initialization operations; it will be noted when
166 Initialization usually will not require doing more than allocating a
167 generic label for the given object. What follows initialization is
168 creation, where a label is made specific to the object it is associated
169 with. Destruction occurs when the label is no longer needed, such as
170 when the corresponding object is destroyed. All necessary cleanup should
171 be performed in label destroy operations.
173 Where possible, the label entry points have identical parameters. If
174 the policy module does not require structure-specific label
175 information, the same function may be registered in the policy
176 operation vector. Many policies will implement two such generic
177 allocation calls: one to handle sleepable requests, and one to handle
178 potentially non-sleepable requests.
183 @brief Audit event postselection
184 @param cred Subject credential
185 @param syscode Syscall number
186 @param args Syscall arguments
187 @param error Syscall errno
188 @param retval Syscall return value
190 This is the MAC Framework audit postselect, which is called before
191 exiting a syscall to determine if an audit event should be committed.
192 A return value of MAC_AUDIT_NO forces the audit record to be suppressed.
193 Any other return value results in the audit record being committed.
195 @warning The suppression behavior will probably go away in Apple's
196 future version of the audit implementation.
198 @return Return MAC_AUDIT_NO to force suppression of the audit record.
199 Any other value results in the audit record being committed.
202 typedef int mpo_audit_check_postselect_t(
204 unsigned short syscode
,
210 @brief Audit event preselection
211 @param cred Subject credential
212 @param syscode Syscall number
213 @param args Syscall arguments
215 This is the MAC Framework audit preselect, which is called before a
216 syscall is entered to determine if an audit event should be created.
217 If the MAC policy forces the syscall to be audited, MAC_AUDIT_YES should be
218 returned. A return value of MAC_AUDIT_NO causes the audit record to
219 be suppressed. Returning MAC_POLICY_DEFAULT indicates that the policy wants
220 to defer to the system's existing preselection mechanism.
222 When policies return different preferences, the Framework decides what action
223 to take based on the following policy. If any policy returns MAC_AUDIT_YES,
224 then create an audit record, else if any policy returns MAC_AUDIT_NO, then
225 suppress the creations of an audit record, else defer to the system's
226 existing preselection mechanism.
228 @warning The audit implementation in Apple's current version is
229 incomplete, so the MAC policies have priority over the system's existing
230 mechanisms. This will probably change in the future version where
231 the audit implementation is more complete.
233 @return Return MAC_AUDIT_YES to force auditing of the syscall,
234 MAC_AUDIT_NO to force no auditing of the syscall, MAC_AUDIT_DEFAULT
235 to allow auditing mechanisms to determine if the syscall is audited.
238 typedef int mpo_audit_check_preselect_t(
240 unsigned short syscode
,
244 @brief Initialize BPF descriptor label
245 @param label New label to initialize
247 Initialize the label for a newly instantiated BPF descriptor.
248 Sleeping is permitted.
250 typedef void mpo_bpfdesc_label_init_t(
254 @brief Destroy BPF descriptor label
255 @param label The label to be destroyed
257 Destroy a BPF descriptor label. Since the BPF descriptor
258 is going out of scope, policy modules should free any internal
259 storage associated with the label so that it may be destroyed.
261 typedef void mpo_bpfdesc_label_destroy_t(
265 @brief Associate a BPF descriptor with a label
266 @param cred User credential creating the BPF descriptor
267 @param bpf_d The BPF descriptor
268 @param bpflabel The new label
270 Set the label on a newly created BPF descriptor from the passed
271 subject credential. This call will be made when a BPF device node
272 is opened by a process with the passed subject credential.
274 typedef void mpo_bpfdesc_label_associate_t(
277 struct label
*bpflabel
280 @brief Check whether BPF can read from a network interface
281 @param bpf_d Subject; the BPF descriptor
282 @param bpflabel Policy label for bpf_d
283 @param ifp Object; the network interface
284 @param ifnetlabel Policy label for ifp
286 Determine whether the MAC framework should permit datagrams from
287 the passed network interface to be delivered to the buffers of
288 the passed BPF descriptor. Return (0) for success, or an errno
289 value for failure. Suggested failure: EACCES for label mismatches,
290 EPERM for lack of privilege.
292 typedef int mpo_bpfdesc_check_receive_t(
294 struct label
*bpflabel
,
296 struct label
*ifnetlabel
299 @brief Indicate desire to change the process label at exec time
300 @param old Existing subject credential
301 @param vp File being executed
302 @param offset Offset of binary within file being executed
303 @param scriptvp Script being executed by interpreter, if any.
304 @param vnodelabel Label corresponding to vp
305 @param scriptvnodelabel Script vnode label
306 @param execlabel Userspace provided execution label
307 @param p Object process
308 @param macpolicyattr MAC policy-specific spawn attribute data
309 @param macpolicyattrlen Length of policy-specific spawn attribute data
311 @see mpo_cred_label_update_execve_t
312 @see mpo_vnode_check_exec_t
314 Indicate whether this policy intends to update the label of a newly
315 created credential from the existing subject credential (old). This
316 call occurs when a process executes the passed vnode. If a policy
317 returns success from this entry point, the mpo_cred_label_update_execve
318 entry point will later be called with the same parameters. Access
319 has already been checked via the mpo_vnode_check_exec entry point,
320 this entry point is necessary to preserve kernel locking constraints
321 during program execution.
323 The supplied vnode and vnodelabel correspond with the file actually
324 being executed; in the case that the file is interpreted (for
325 example, a script), the label of the original exec-time vnode has
326 been preserved in scriptvnodelabel.
328 The final label, execlabel, corresponds to a label supplied by a
329 user space application through the use of the mac_execve system call.
331 The vnode lock is held during this operation. No changes should be
332 made to the old credential structure.
334 @warning Even if a policy returns 0, it should behave correctly in
335 the presence of an invocation of mpo_cred_label_update_execve, as that
336 call may happen as a result of another policy requesting a transition.
338 @return Non-zero if a transition is required, 0 otherwise.
340 typedef int mpo_cred_check_label_update_execve_t(
344 struct vnode
*scriptvp
,
345 struct label
*vnodelabel
,
346 struct label
*scriptvnodelabel
,
347 struct label
*execlabel
,
350 size_t macpolicyattrlen
353 @brief Access control check for relabelling processes
354 @param cred Subject credential
355 @param newlabel New label to apply to the user credential
356 @see mpo_cred_label_update_t
359 Determine whether the subject identified by the credential can relabel
360 itself to the supplied new label (newlabel). This access control check
361 is called when the mac_set_proc system call is invoked. A user space
362 application will supply a new value, the value will be internalized
363 and provided in newlabel.
365 @return Return 0 if access is granted, otherwise an appropriate value for
366 errno should be returned.
368 typedef int mpo_cred_check_label_update_t(
370 struct label
*newlabel
373 @brief Access control check for visibility of other subjects
374 @param u1 Subject credential
375 @param u2 Object credential
377 Determine whether the subject identified by the credential u1 can
378 "see" other subjects with the passed subject credential u2. This call
379 may be made in a number of situations, including inter-process status
380 sysctls used by ps, and in procfs lookups.
382 @return Return 0 if access is granted, otherwise an appropriate value for
383 errno should be returned. Suggested failure: EACCES for label mismatch,
384 EPERM for lack of privilege, or ESRCH to hide visibility.
386 typedef int mpo_cred_check_visible_t(
391 @brief Associate a credential with a new process at fork
392 @param cred credential to inherited by new process
393 @param proc the new process
395 Allow a process to associate the credential with a new
396 process for reference countng purposes.
397 NOTE: the credential can be dis-associated in ways other
398 than exit - so this strategy is flawed - should just
399 catch label destroy callback.
401 typedef void mpo_cred_label_associate_fork_t(
406 @brief Create the first process
407 @param cred Subject credential to be labeled
409 Create the subject credential of process 0, the parent of all BSD
410 kernel processes. Policies should update the label in the
411 previously initialized credential structure.
413 typedef void mpo_cred_label_associate_kernel_t(
417 @brief Create a credential label
418 @param parent_cred Parent credential
419 @param child_cred Child credential
421 Set the label of a newly created credential, most likely using the
422 information in the supplied parent credential.
424 @warning This call is made when crcopy or crdup is invoked on a
425 newly created struct ucred, and should not be confused with a
426 process fork or creation event.
428 typedef void mpo_cred_label_associate_t(
429 kauth_cred_t parent_cred
,
430 kauth_cred_t child_cred
433 @brief Create the first process
434 @param cred Subject credential to be labeled
436 Create the subject credential of process 1, the parent of all BSD
437 user processes. Policies should update the label in the previously
438 initialized credential structure. This is the 'init' process.
440 typedef void mpo_cred_label_associate_user_t(
444 @brief Destroy credential label
445 @param label The label to be destroyed
447 Destroy a user credential label. Since the user credential
448 is going out of scope, policy modules should free any internal
449 storage associated with the label so that it may be destroyed.
451 typedef void mpo_cred_label_destroy_t(
455 @brief Externalize a user credential label for auditing
456 @param label Label to be externalized
457 @param element_name Name of the label namespace for which labels should be
459 @param sb String buffer to be filled with a text representation of the label
461 Produce an external representation of the label on a user credential for
462 inclusion in an audit record. An externalized label consists of a text
463 representation of the label contents that will be added to the audit record
464 as part of a text token. Policy-agnostic user space tools will display
465 this externalized version.
467 @return 0 on success, return non-zero if an error occurs while
468 externalizing the label data.
471 typedef int mpo_cred_label_externalize_audit_t(
477 @brief Externalize a user credential label
478 @param label Label to be externalized
479 @param element_name Name of the label namespace for which labels should be
481 @param sb String buffer to be filled with a text representation of the label
483 Produce an external representation of the label on a user
484 credential. An externalized label consists of a text representation
485 of the label contents that can be used with user applications.
486 Policy-agnostic user space tools will display this externalized
489 @return 0 on success, return non-zero if an error occurs while
490 externalizing the label data.
493 typedef int mpo_cred_label_externalize_t(
499 @brief Initialize user credential label
500 @param label New label to initialize
502 Initialize the label for a newly instantiated user credential.
503 Sleeping is permitted.
505 typedef void mpo_cred_label_init_t(
509 @brief Internalize a user credential label
510 @param label Label to be internalized
511 @param element_name Name of the label namespace for which the label should
513 @param element_data Text data to be internalized
515 Produce a user credential label from an external representation. An
516 externalized label consists of a text representation of the label
517 contents that can be used with user applications. Policy-agnostic
518 user space tools will forward text version to the kernel for
519 processing by individual policy modules.
521 The policy's internalize entry points will be called only if the
522 policy has registered interest in the label namespace.
524 @return 0 on success, Otherwise, return non-zero if an error occurs
525 while internalizing the label data.
528 typedef int mpo_cred_label_internalize_t(
534 @brief Update credential at exec time
535 @param old_cred Existing subject credential
536 @param new_cred New subject credential to be labeled
537 @param p Object process.
538 @param vp File being executed
539 @param offset Offset of binary within file being executed
540 @param scriptvp Script being executed by interpreter, if any.
541 @param vnodelabel Label corresponding to vp
542 @param scriptvnodelabel Script vnode label
543 @param execlabel Userspace provided execution label
544 @param csflags Code signing flags to be set after exec
545 @param macpolicyattr MAC policy-specific spawn attribute data.
546 @param macpolicyattrlen Length of policy-specific spawn attribute data.
548 @see mpo_cred_check_label_update_execve_t
549 @see mpo_vnode_check_exec_t
551 Update the label of a newly created credential (new) from the
552 existing subject credential (old). This call occurs when a process
553 executes the passed vnode and one of the loaded policy modules has
554 returned success from the mpo_cred_check_label_update_execve entry point.
555 Access has already been checked via the mpo_vnode_check_exec entry
556 point, this entry point is only used to update any policy state.
558 The supplied vnode and vnodelabel correspond with the file actually
559 being executed; in the case that the file is interpreted (for
560 example, a script), the label of the original exec-time vnode has
561 been preserved in scriptvnodelabel.
563 The final label, execlabel, corresponds to a label supplied by a
564 user space application through the use of the mac_execve system call.
566 If non-NULL, the value pointed to by disjointp will be set to 0 to
567 indicate that the old and new credentials are not disjoint, or 1 to
568 indicate that they are.
570 The vnode lock is held during this operation. No changes should be
571 made to the old credential structure.
572 @return 0 on success, Otherwise, return non-zero if update results in
573 termination of child.
575 typedef int mpo_cred_label_update_execve_t(
576 kauth_cred_t old_cred
,
577 kauth_cred_t new_cred
,
581 struct vnode
*scriptvp
,
582 struct label
*vnodelabel
,
583 struct label
*scriptvnodelabel
,
584 struct label
*execlabel
,
587 size_t macpolicyattrlen
,
591 @brief Update a credential label
592 @param cred The existing credential
593 @param newlabel A new label to apply to the credential
594 @see mpo_cred_check_label_update_t
597 Update the label on a user credential, using the supplied new label.
598 This is called as a result of a process relabel operation. Access
599 control was already confirmed by mpo_cred_check_label_update.
601 typedef void mpo_cred_label_update_t(
603 struct label
*newlabel
606 @brief Create a new devfs device
607 @param dev Major and minor numbers of special file
608 @param de "inode" of new device file
609 @param label Destination label
610 @param fullpath Path relative to mount (e.g. /dev) of new device file
612 This entry point labels a new devfs device. The label will likely be based
613 on the path to the device, or the major and minor numbers.
614 The policy should store an appropriate label into 'label'.
616 typedef void mpo_devfs_label_associate_device_t(
623 @brief Create a new devfs directory
624 @param dirname Name of new directory
625 @param dirnamelen Length of 'dirname'
626 @param de "inode" of new directory
627 @param label Destination label
628 @param fullpath Path relative to mount (e.g. /dev) of new directory
630 This entry point labels a new devfs directory. The label will likely be
631 based on the path of the new directory. The policy should store an appropriate
632 label into 'label'. The devfs root directory is labelled in this way.
634 typedef void mpo_devfs_label_associate_directory_t(
642 @brief Copy a devfs label
643 @param src Source devfs label
644 @param dest Destination devfs label
646 Copy the label information from src to dest. The devfs file system
647 often duplicates (splits) existing device nodes rather than creating
650 typedef void mpo_devfs_label_copy_t(
655 @brief Destroy devfs label
656 @param label The label to be destroyed
658 Destroy a devfs entry label. Since the object is going out
659 of scope, policy modules should free any internal storage associated
660 with the label so that it may be destroyed.
662 typedef void mpo_devfs_label_destroy_t(
666 @brief Initialize devfs label
667 @param label New label to initialize
669 Initialize the label for a newly instantiated devfs entry. Sleeping
672 typedef void mpo_devfs_label_init_t(
676 @brief Update a devfs label after relabelling its vnode
677 @param mp Devfs mount point
678 @param de Affected devfs directory entry
679 @param delabel Label of devfs directory entry
680 @param vp Vnode associated with de
681 @param vnodelabel New label of vnode
683 Update a devfs label when its vnode is manually relabelled,
684 for example with setfmac(1). Typically, this will simply copy
685 the vnode label into the devfs label.
687 typedef void mpo_devfs_label_update_t(
690 struct label
*delabel
,
692 struct label
*vnodelabel
695 @brief Access control for sending an exception to an exception action
696 @param crashlabel The crashing process's label
697 @param action Exception action
698 @param exclabel Policy label for exception action
700 Determine whether the the exception message caused by the victim
701 process can be sent to the exception action.
703 @return Return 0 if the message can be sent, otherwise an
704 appropriate value for errno should be returned.
706 typedef int mpo_exc_action_check_exception_send_t(
707 struct label
*crashlabel
,
708 struct exception_action
*action
,
709 struct label
*exclabel
712 @brief Create an exception action label
713 @param action Exception action to label
714 @param exclabel Policy label to be filled in for exception action
716 Set the label on an exception action.
718 typedef void mpo_exc_action_label_associate_t(
719 struct exception_action
*action
,
720 struct label
*exclabel
723 @brief Copy an exception action label
724 @param src Source exception action label
725 @param dest Destination exception action label
727 Copy the label information from src to dest.
728 Exception actions are often inherited, e.g. from parent to child.
729 In that case, the labels are copied instead of created fresh.
731 typedef void mpo_exc_action_label_copy_t(
736 @brief Destroy exception action label
737 @param label The label to be destroyed
739 Destroy the label on an exception action. In this entry point, a
740 policy module should free any internal storage associated with
741 label so that it may be destroyed.
743 typedef void mpo_exc_action_label_destroy_t(
747 @brief Initialize exception action label
748 @param label New label to initialize
750 Initialize a label for an exception action.
752 typedef int mpo_exc_action_label_init_t(
756 @brief Update the label on an exception action
757 @param p Process to update the label from
758 @param exclabel Policy label to be updated for exception action
760 Update the credentials of an exception action with the given task.
762 typedef void mpo_exc_action_label_update_t(
764 struct label
*exclabel
767 @brief Access control for changing the offset of a file descriptor
768 @param cred Subject credential
769 @param fg Fileglob structure
770 @param label Policy label for fg
772 Determine whether the subject identified by the credential can
773 change the offset of the file represented by fg.
775 @return Return 0 if access if granted, otherwise an appropriate
776 value for errno should be returned.
778 typedef int mpo_file_check_change_offset_t(
784 @brief Access control for creating a file descriptor
785 @param cred Subject credential
787 Determine whether the subject identified by the credential can
788 allocate a new file descriptor.
790 @return Return 0 if access if granted, otherwise an appropriate
791 value for errno should be returned.
793 typedef int mpo_file_check_create_t(
797 @brief Access control for duplicating a file descriptor
798 @param cred Subject credential
799 @param fg Fileglob structure
800 @param label Policy label for fg
801 @param newfd New file descriptor number
803 Determine whether the subject identified by the credential can
804 duplicate the fileglob structure represented by fg and as file
805 descriptor number newfd.
807 @return Return 0 if access if granted, otherwise an appropriate
808 value for errno should be returned.
810 typedef int mpo_file_check_dup_t(
817 @brief Access control check for fcntl
818 @param cred Subject credential
819 @param fg Fileglob structure
820 @param label Policy label for fg
821 @param cmd Control operation to be performed; see fcntl(2)
822 @param arg fcnt arguments; see fcntl(2)
824 Determine whether the subject identified by the credential can perform
825 the file control operation indicated by cmd.
827 @return Return 0 if access is granted, otherwise an appropriate value for
828 errno should be returned.
830 typedef int mpo_file_check_fcntl_t(
838 @brief Access control check for mac_get_fd
839 @param cred Subject credential
840 @param fg Fileglob structure
841 @param elements Element buffer
842 @param len Length of buffer
844 Determine whether the subject identified by the credential should be allowed
845 to get an externalized version of the label on the object indicated by fd.
847 @return Return 0 if access is granted, otherwise an appropriate value for
848 errno should be returned.
850 typedef int mpo_file_check_get_t(
857 @brief Access control for getting the offset of a file descriptor
858 @param cred Subject credential
859 @param fg Fileglob structure
860 @param label Policy label for fg
862 Determine whether the subject identified by the credential can
863 get the offset of the file represented by fg.
865 @return Return 0 if access if granted, otherwise an appropriate
866 value for errno should be returned.
868 typedef int mpo_file_check_get_offset_t(
874 @brief Access control for inheriting a file descriptor
875 @param cred Subject credential
876 @param fg Fileglob structure
877 @param label Policy label for fg
879 Determine whether the subject identified by the credential can
880 inherit the fileglob structure represented by fg.
882 @return Return 0 if access if granted, otherwise an appropriate
883 value for errno should be returned.
885 typedef int mpo_file_check_inherit_t(
891 @brief Access control check for file ioctl
892 @param cred Subject credential
893 @param fg Fileglob structure
894 @param label Policy label for fg
895 @param cmd The ioctl command; see ioctl(2)
897 Determine whether the subject identified by the credential can perform
898 the ioctl operation indicated by cmd.
900 @warning Since ioctl data is opaque from the standpoint of the MAC
901 framework, policies must exercise extreme care when implementing
902 access control checks.
904 @return Return 0 if access is granted, otherwise an appropriate value for
905 errno should be returned.
908 typedef int mpo_file_check_ioctl_t(
915 @brief Access control check for file locking
916 @param cred Subject credential
917 @param fg Fileglob structure
918 @param label Policy label for fg
919 @param op The lock operation (F_GETLK, F_SETLK, F_UNLK)
920 @param fl The flock structure
922 Determine whether the subject identified by the credential can perform
923 the lock operation indicated by op and fl on the file represented by fg.
925 @return Return 0 if access is granted, otherwise an appropriate value for
926 errno should be returned.
929 typedef int mpo_file_check_lock_t(
937 @brief Check with library validation if a macho slice is allowed to be combined into a proc.
938 @param p Subject process
939 @param fg Fileglob structure
940 @param slice_offset offset of the code slice
941 @param error_message error message returned to user-space in case of error (userspace pointer)
942 @param error_message_size error message size
944 Its a little odd that the MAC/kext writes into userspace since this
945 implies there is only one MAC module that implements this, however
946 the alterantive is to allocate memory in xnu, on the hope that
947 the MAC module will use it, or allocated in the MAC module and then
948 free it in xnu. Either of these are very appeling, so lets go with
949 the slightly more hacky way.
951 @return Return 0 if access is granted, otherwise an appropriate value for
952 errno should be returned.
954 typedef int mpo_file_check_library_validation_t(
958 user_long_t error_message
,
959 size_t error_message_size
962 @brief Access control check for mapping a file
963 @param cred Subject credential
964 @param fg fileglob representing file to map
965 @param label Policy label associated with vp
966 @param prot mmap protections; see mmap(2)
967 @param flags Type of mapped object; see mmap(2)
968 @param maxprot Maximum rights
970 Determine whether the subject identified by the credential should be
971 allowed to map the file represented by fg with the protections specified
972 in prot. The maxprot field holds the maximum permissions on the new
973 mapping, a combination of VM_PROT_READ, VM_PROT_WRITE, and VM_PROT_EXECUTE.
974 To avoid overriding prior access control checks, a policy should only
975 remove flags from maxprot.
977 @return Return 0 if access is granted, otherwise an appropriate value for
978 errno should be returned. Suggested failure: EACCES for label mismatch or
979 EPERM for lack of privilege.
981 typedef int mpo_file_check_mmap_t(
991 @brief Downgrade the mmap protections
992 @param cred Subject credential
993 @param fg file to map
994 @param label Policy label associated with vp
995 @param prot mmap protections to be downgraded
997 Downgrade the mmap protections based on the subject and object labels.
999 typedef void mpo_file_check_mmap_downgrade_t(
1001 struct fileglob
*fg
,
1002 struct label
*label
,
1006 @brief Access control for receiving a file descriptor
1007 @param cred Subject credential
1008 @param fg Fileglob structure
1009 @param label Policy label for fg
1011 Determine whether the subject identified by the credential can
1012 receive the fileglob structure represented by fg.
1014 @return Return 0 if access if granted, otherwise an appropriate
1015 value for errno should be returned.
1017 typedef int mpo_file_check_receive_t(
1019 struct fileglob
*fg
,
1023 @brief Access control check for mac_set_fd
1024 @param cred Subject credential
1025 @param fg Fileglob structure
1026 @param elements Elements buffer
1027 @param len Length of elements buffer
1029 Determine whether the subject identified by the credential can
1030 perform the mac_set_fd operation. The mac_set_fd operation is used
1031 to associate a MAC label with a file.
1033 @return Return 0 if access is granted, otherwise an appropriate value for
1034 errno should be returned.
1036 typedef int mpo_file_check_set_t(
1038 struct fileglob
*fg
,
1043 @brief Create file label
1044 @param cred Subject credential
1045 @param fg Fileglob structure
1046 @param label Policy label for fg
1048 typedef void mpo_file_label_associate_t(
1050 struct fileglob
*fg
,
1054 @brief Destroy file label
1055 @param label The label to be destroyed
1057 Destroy the label on a file descriptor. In this entry point, a
1058 policy module should free any internal storage associated with
1059 label so that it may be destroyed.
1061 typedef void mpo_file_label_destroy_t(
1065 @brief Initialize file label
1066 @param label New label to initialize
1068 typedef void mpo_file_label_init_t(
1072 @brief Access control check for relabeling network interfaces
1073 @param cred Subject credential
1074 @param ifp network interface being relabeled
1075 @param ifnetlabel Current label of the network interfaces
1076 @param newlabel New label to apply to the network interfaces
1077 @see mpo_ifnet_label_update_t
1079 Determine whether the subject identified by the credential can
1080 relabel the network interface represented by ifp to the supplied
1081 new label (newlabel).
1083 @return Return 0 if access is granted, otherwise an appropriate value for
1084 errno should be returned.
1086 typedef int mpo_ifnet_check_label_update_t(
1089 struct label
*ifnetlabel
,
1090 struct label
*newlabel
1093 @brief Access control check for relabeling network interfaces
1094 @param ifp Network interface mbuf will be transmitted through
1095 @param ifnetlabel Label of the network interfaces
1096 @param m The mbuf to be transmitted
1097 @param mbuflabel Label of the mbuf to be transmitted
1098 @param family Address Family, AF_*
1099 @param type Type of socket, SOCK_{STREAM,DGRAM,RAW}
1101 Determine whether the mbuf with label mbuflabel may be transmitted
1102 through the network interface represented by ifp that has the
1105 @return Return 0 if access is granted, otherwise an appropriate value for
1106 errno should be returned.
1108 typedef int mpo_ifnet_check_transmit_t(
1110 struct label
*ifnetlabel
,
1112 struct label
*mbuflabel
,
1117 @brief Create a network interface label
1118 @param ifp Network interface labeled
1119 @param ifnetlabel Label for the network interface
1121 Set the label of a newly created network interface, most likely
1122 using the information in the supplied network interface struct.
1124 typedef void mpo_ifnet_label_associate_t(
1126 struct label
*ifnetlabel
1129 @brief Copy an ifnet label
1130 @param src Source ifnet label
1131 @param dest Destination ifnet label
1133 Copy the label information from src to dest.
1135 typedef void mpo_ifnet_label_copy_t(
1140 @brief Destroy ifnet label
1141 @param label The label to be destroyed
1143 Destroy the label on an ifnet label. In this entry point, a
1144 policy module should free any internal storage associated with
1145 label so that it may be destroyed.
1147 typedef void mpo_ifnet_label_destroy_t(
1151 @brief Externalize an ifnet label
1152 @param label Label to be externalized
1153 @param element_name Name of the label namespace for which labels should be
1155 @param sb String buffer to be filled with a text representation of the label
1157 Produce an external representation of the label on an interface.
1158 An externalized label consists of a text representation of the
1159 label contents that can be used with user applications.
1160 Policy-agnostic user space tools will display this externalized
1163 @return 0 on success, return non-zero if an error occurs while
1164 externalizing the label data.
1167 typedef int mpo_ifnet_label_externalize_t(
1168 struct label
*label
,
1173 @brief Initialize ifnet label
1174 @param label New label to initialize
1176 typedef void mpo_ifnet_label_init_t(
1180 @brief Internalize an interface label
1181 @param label Label to be internalized
1182 @param element_name Name of the label namespace for which the label should
1184 @param element_data Text data to be internalized
1186 Produce an interface label from an external representation. An
1187 externalized label consists of a text representation of the label
1188 contents that can be used with user applications. Policy-agnostic
1189 user space tools will forward text version to the kernel for
1190 processing by individual policy modules.
1192 The policy's internalize entry points will be called only if the
1193 policy has registered interest in the label namespace.
1195 @return 0 on success, Otherwise, return non-zero if an error occurs
1196 while internalizing the label data.
1199 typedef int mpo_ifnet_label_internalize_t(
1200 struct label
*label
,
1205 @brief Recycle up a network interface label
1206 @param label The label to be recycled
1208 Recycle a network interface label. Darwin caches the struct ifnet
1209 of detached ifnets in a "free pool". Before ifnets are returned
1210 to the "free pool", policies can cleanup or overwrite any information
1211 present in the label.
1213 typedef void mpo_ifnet_label_recycle_t(
1217 @brief Update a network interface label
1218 @param cred Subject credential
1219 @param ifp The network interface to be relabeled
1220 @param ifnetlabel The current label of the network interface
1221 @param newlabel A new label to apply to the network interface
1222 @see mpo_ifnet_check_label_update_t
1224 Update the label on a network interface, using the supplied new label.
1226 typedef void mpo_ifnet_label_update_t(
1229 struct label
*ifnetlabel
,
1230 struct label
*newlabel
1233 @brief Access control check for delivering a packet to a socket
1234 @param inp inpcb the socket is associated with
1235 @param inplabel Label of the inpcb
1236 @param m The mbuf being received
1237 @param mbuflabel Label of the mbuf being received
1238 @param family Address family, AF_*
1239 @param type Type of socket, SOCK_{STREAM,DGRAM,RAW}
1241 Determine whether the mbuf with label mbuflabel may be received
1242 by the socket associated with inpcb that has the label inplabel.
1244 @return Return 0 if access is granted, otherwise an appropriate value for
1245 errno should be returned.
1247 typedef int mpo_inpcb_check_deliver_t(
1249 struct label
*inplabel
,
1251 struct label
*mbuflabel
,
1256 @brief Create an inpcb label
1257 @param so Socket containing the inpcb to be labeled
1258 @param solabel Label of the socket
1259 @param inp inpcb to be labeled
1260 @param inplabel Label for the inpcb
1262 Set the label of a newly created inpcb, most likely
1263 using the information in the socket and/or socket label.
1265 typedef void mpo_inpcb_label_associate_t(
1267 struct label
*solabel
,
1269 struct label
*inplabel
1272 @brief Destroy inpcb label
1273 @param label The label to be destroyed
1275 Destroy the label on an inpcb label. In this entry point, a
1276 policy module should free any internal storage associated with
1277 label so that it may be destroyed.
1279 typedef void mpo_inpcb_label_destroy_t(
1283 @brief Initialize inpcb label
1284 @param label New label to initialize
1285 @param flag M_WAITOK or M_NOWAIT
1287 typedef int mpo_inpcb_label_init_t(
1288 struct label
*label
,
1292 @brief Recycle up an inpcb label
1293 @param label The label to be recycled
1295 Recycle an inpcb label. Darwin allocates the inpcb as part of
1296 the socket structure in some cases. For this case we must recycle
1297 rather than destroy the inpcb as it will be reused later.
1299 typedef void mpo_inpcb_label_recycle_t(
1303 @brief Update an inpcb label from a socket label
1304 @param so Socket containing the inpcb to be relabeled
1305 @param solabel New label of the socket
1306 @param inp inpcb to be labeled
1307 @param inplabel Label for the inpcb
1309 Set the label of a newly created inpcb due to a change in the
1310 underlying socket label.
1312 typedef void mpo_inpcb_label_update_t(
1314 struct label
*solabel
,
1316 struct label
*inplabel
1319 @brief Device hardware access control
1320 @param devtype Type of device connected
1322 This is the MAC Framework device access control, which is called by the I/O
1323 Kit when a new device is connected to the system to determine whether that
1324 device should be trusted. A list of properties associated with the device
1325 is passed as an XML-formatted string. The routine should examine these
1326 properties to determine the trustworthiness of the device. A return value
1327 of EPERM forces the device to be claimed by a special device driver that
1328 will prevent its operation.
1330 @warning This is an experimental interface and may change in the future.
1332 @return Return EPERM to indicate that the device is untrusted and should
1333 not be allowed to operate. Return zero to indicate that the device is
1334 trusted and should be allowed to operate normally.
1337 typedef int mpo_iokit_check_device_t(
1339 struct mac_module_data
*mdata
1342 @brief Access control check for opening an I/O Kit device
1343 @param cred Subject credential
1344 @param user_client User client instance
1345 @param user_client_type User client type
1347 Determine whether the subject identified by the credential can open an
1348 I/O Kit device at the passed path of the passed user client class and
1351 @return Return 0 if access is granted, or an appropriate value for
1352 errno should be returned.
1354 typedef int mpo_iokit_check_open_t(
1356 io_object_t user_client
,
1357 unsigned int user_client_type
1360 @brief Access control check for setting I/O Kit device properties
1361 @param cred Subject credential
1362 @param entry Target device
1363 @param properties Property list
1365 Determine whether the subject identified by the credential can set
1366 properties on an I/O Kit device.
1368 @return Return 0 if access is granted, or an appropriate value for
1369 errno should be returned.
1371 typedef int mpo_iokit_check_set_properties_t(
1374 io_object_t properties
1377 @brief Indicate desire to filter I/O Kit devices properties
1378 @param cred Subject credential
1379 @param entry Target device
1380 @see mpo_iokit_check_get_property_t
1382 Indicate whether this policy may restrict the subject credential
1383 from reading properties of the target device.
1384 If a policy returns success from this entry point, the
1385 mpo_iokit_check_get_property entry point will later be called
1386 for each property that the subject credential tries to read from
1389 This entry point is primarilly to optimize bulk property reads
1390 by skipping calls to the mpo_iokit_check_get_property entry point
1391 for credentials / devices no MAC policy is interested in.
1393 @warning Even if a policy returns 0, it should behave correctly in
1394 the presence of an invocation of mpo_iokit_check_get_property, as that
1395 call may happen as a result of another policy requesting a transition.
1397 @return Non-zero if a transition is required, 0 otherwise.
1399 typedef int mpo_iokit_check_filter_properties_t(
1404 @brief Access control check for getting I/O Kit device properties
1405 @param cred Subject credential
1406 @param entry Target device
1407 @param name Property name
1409 Determine whether the subject identified by the credential can get
1410 properties on an I/O Kit device.
1412 @return Return 0 if access is granted, or an appropriate value for
1415 typedef int mpo_iokit_check_get_property_t(
1421 @brief Access control check for software HID control
1422 @param cred Subject credential
1424 Determine whether the subject identified by the credential can
1425 control the HID (Human Interface Device) subsystem, such as to
1426 post synthetic keypresses, pointer movement and clicks.
1428 @return Return 0 if access is granted, or an appropriate value for
1431 typedef int mpo_iokit_check_hid_control_t(
1435 @brief Create an IP reassembly queue label
1436 @param fragment First received IP fragment
1437 @param fragmentlabel Policy label for fragment
1438 @param ipq IP reassembly queue to be labeled
1439 @param ipqlabel Policy label to be filled in for ipq
1441 Set the label on a newly created IP reassembly queue from
1442 the mbuf header of the first received fragment.
1444 typedef void mpo_ipq_label_associate_t(
1445 struct mbuf
*fragment
,
1446 struct label
*fragmentlabel
,
1448 struct label
*ipqlabel
1451 @brief Compare an mbuf header label to an ipq label
1452 @param fragment IP datagram fragment
1453 @param fragmentlabel Policy label for fragment
1454 @param ipq IP fragment reassembly queue
1455 @param ipqlabel Policy label for ipq
1457 Compare the label of the mbuf header containing an IP datagram
1458 (fragment) fragment with the label of the passed IP fragment
1459 reassembly queue (ipq). Return (1) for a successful match, or (0)
1460 for no match. This call is made when the IP stack attempts to
1461 find an existing fragment reassembly queue for a newly received
1462 fragment; if this fails, a new fragment reassembly queue may be
1463 instantiated for the fragment. Policies may use this entry point
1464 to prevent the reassembly of otherwise matching IP fragments if
1465 policy does not permit them to be reassembled based on the label
1466 or other information.
1468 typedef int mpo_ipq_label_compare_t(
1469 struct mbuf
*fragment
,
1470 struct label
*fragmentlabel
,
1472 struct label
*ipqlabel
1475 @brief Destroy IP reassembly queue label
1476 @param label The label to be destroyed
1478 Destroy the label on an IP fragment queue. In this entry point, a
1479 policy module should free any internal storage associated with
1480 label so that it may be destroyed.
1482 typedef void mpo_ipq_label_destroy_t(
1486 @brief Initialize IP reassembly queue label
1487 @param label New label to initialize
1488 @param flag M_WAITOK or M_NOWAIT
1490 Initialize the label on a newly instantiated IP fragment reassembly
1491 queue. The flag field may be one of M_WAITOK and M_NOWAIT, and
1492 should be employed to avoid performing a sleeping malloc(9) during
1493 this initialization call. IP fragment reassembly queue allocation
1494 frequently occurs in performance sensitive environments, and the
1495 implementation should be careful to avoid sleeping or long-lived
1496 operations. This entry point is permitted to fail resulting in
1497 the failure to allocate the IP fragment reassembly queue.
1499 typedef int mpo_ipq_label_init_t(
1500 struct label
*label
,
1504 @brief Update the label on an IP fragment reassembly queue
1505 @param fragment IP fragment
1506 @param fragmentlabel Policy label for fragment
1507 @param ipq IP fragment reassembly queue
1508 @param ipqlabel Policy label to be updated for ipq
1510 Update the label on an IP fragment reassembly queue (ipq) based
1511 on the acceptance of the passed IP fragment mbuf header (fragment).
1513 typedef void mpo_ipq_label_update_t(
1514 struct mbuf
*fragment
,
1515 struct label
*fragmentlabel
,
1517 struct label
*ipqlabel
1520 @brief Assign a label to a new mbuf
1521 @param bpf_d BPF descriptor
1522 @param b_label Policy label for bpf_d
1523 @param m Object; mbuf
1524 @param m_label Policy label to fill in for m
1526 Set the label on the mbuf header of a newly created datagram
1527 generated using the passed BPF descriptor. This call is made when
1528 a write is performed to the BPF device associated with the passed
1531 typedef void mpo_mbuf_label_associate_bpfdesc_t(
1532 struct bpf_d
*bpf_d
,
1533 struct label
*b_label
,
1535 struct label
*m_label
1538 @brief Assign a label to a new mbuf
1539 @param ifp Interface descriptor
1540 @param i_label Existing label of ifp
1541 @param m Object; mbuf
1542 @param m_label Policy label to fill in for m
1544 Label an mbuf based on the interface from which it was received.
1546 typedef void mpo_mbuf_label_associate_ifnet_t(
1548 struct label
*i_label
,
1550 struct label
*m_label
1553 @brief Assign a label to a new mbuf
1554 @param inp inpcb structure
1555 @param i_label Existing label of inp
1556 @param m Object; mbuf
1557 @param m_label Policy label to fill in for m
1559 Label an mbuf based on the inpcb from which it was derived.
1561 typedef void mpo_mbuf_label_associate_inpcb_t(
1563 struct label
*i_label
,
1565 struct label
*m_label
1568 @brief Set the label on a newly reassembled IP datagram
1569 @param ipq IP fragment reassembly queue
1570 @param ipqlabel Policy label for ipq
1571 @param mbuf IP datagram to be labeled
1572 @param mbuflabel Policy label to be filled in for mbuf
1574 Set the label on a newly reassembled IP datagram (mbuf) from the IP
1575 fragment reassembly queue (ipq) from which it was generated.
1577 typedef void mpo_mbuf_label_associate_ipq_t(
1579 struct label
*ipqlabel
,
1581 struct label
*mbuflabel
1584 @brief Assign a label to a new mbuf
1585 @param ifp Subject; network interface
1586 @param i_label Existing label of ifp
1587 @param m Object; mbuf
1588 @param m_label Policy label to fill in for m
1590 Set the label on the mbuf header of a newly created datagram
1591 generated for the purposes of a link layer response for the passed
1592 interface. This call may be made in a number of situations, including
1593 for ARP or ND6 responses in the IPv4 and IPv6 stacks.
1595 typedef void mpo_mbuf_label_associate_linklayer_t(
1597 struct label
*i_label
,
1599 struct label
*m_label
1602 @brief Assign a label to a new mbuf
1603 @param oldmbuf mbuf headerder for existing datagram for existing datagram
1604 @param oldmbuflabel Policy label for oldmbuf
1605 @param ifp Network interface
1606 @param ifplabel Policy label for ifp
1607 @param newmbuf mbuf header to be labeled for new datagram
1608 @param newmbuflabel Policy label for newmbuf
1610 Set the label on the mbuf header of a newly created datagram
1611 generated from the existing passed datagram when it is processed
1612 by the passed multicast encapsulation interface. This call is made
1613 when an mbuf is to be delivered using the virtual interface.
1615 typedef void mpo_mbuf_label_associate_multicast_encap_t(
1616 struct mbuf
*oldmbuf
,
1617 struct label
*oldmbuflabel
,
1619 struct label
*ifplabel
,
1620 struct mbuf
*newmbuf
,
1621 struct label
*newmbuflabel
1624 @brief Assign a label to a new mbuf
1625 @param oldmbuf Received datagram
1626 @param oldmbuflabel Policy label for oldmbuf
1627 @param newmbuf Newly created datagram
1628 @param newmbuflabel Policy label for newmbuf
1630 Set the label on the mbuf header of a newly created datagram generated
1631 by the IP stack in response to an existing received datagram (oldmbuf).
1632 This call may be made in a number of situations, including when responding
1633 to ICMP request datagrams.
1635 typedef void mpo_mbuf_label_associate_netlayer_t(
1636 struct mbuf
*oldmbuf
,
1637 struct label
*oldmbuflabel
,
1638 struct mbuf
*newmbuf
,
1639 struct label
*newmbuflabel
1642 @brief Assign a label to a new mbuf
1643 @param so Socket to label
1644 @param so_label Policy label for socket
1645 @param m Object; mbuf
1646 @param m_label Policy label to fill in for m
1648 An mbuf structure is used to store network traffic in transit.
1649 When an application sends data to a socket or a pipe, it is wrapped
1650 in an mbuf first. This function sets the label on a newly created mbuf header
1651 based on the socket sending the data. The contents of the label should be
1652 suitable for performing an access check on the receiving side of the
1655 Only labeled MBUFs will be presented to the policy via this entrypoint.
1657 typedef void mpo_mbuf_label_associate_socket_t(
1659 struct label
*so_label
,
1661 struct label
*m_label
1664 @brief Copy a mbuf label
1665 @param src Source label
1666 @param dest Destination label
1668 Copy the mbuf label information in src into dest.
1670 Only called when both source and destination mbufs have labels.
1672 typedef void mpo_mbuf_label_copy_t(
1677 @brief Destroy mbuf label
1678 @param label The label to be destroyed
1680 Destroy a mbuf label. Since the
1681 object is going out of scope, policy modules should free any
1682 internal storage associated with the label so that it may be
1685 typedef void mpo_mbuf_label_destroy_t(
1689 @brief Initialize mbuf label
1690 @param label New label to initialize
1691 @param flag Malloc flags
1693 Initialize the label for a newly instantiated mbuf.
1695 @warning Since it is possible for the flags to be set to
1696 M_NOWAIT, the malloc operation may fail.
1698 @return On success, 0, otherwise, an appropriate errno return value.
1700 typedef int mpo_mbuf_label_init_t(
1701 struct label
*label
,
1705 @brief Access control check for fsctl
1706 @param cred Subject credential
1707 @param mp The mount point
1708 @param label Label associated with the mount point
1709 @param cmd Filesystem-dependent request code; see fsctl(2)
1711 Determine whether the subject identified by the credential can perform
1712 the volume operation indicated by com.
1714 @warning The fsctl() system call is directly analogous to ioctl(); since
1715 the associated data is opaque from the standpoint of the MAC framework
1716 and since these operations can affect many aspects of system operation,
1717 policies must exercise extreme care when implementing access control checks.
1719 @return Return 0 if access is granted, otherwise an appropriate value for
1720 errno should be returned.
1722 typedef int mpo_mount_check_fsctl_t(
1725 struct label
*label
,
1729 @brief Access control check for the retrieval of file system attributes
1730 @param cred Subject credential
1731 @param mp The mount structure of the file system
1732 @param vfa The attributes requested
1734 This entry point determines whether given subject can get information
1735 about the given file system. This check happens during statfs() syscalls,
1736 but is also used by other parts within the kernel such as the audit system.
1738 @return Return 0 if access is granted, otherwise an appropriate value for
1739 errno should be returned.
1742 typedef int mpo_mount_check_getattr_t(
1745 struct label
*mp_label
,
1746 struct vfs_attr
*vfa
1749 @brief Access control check for mount point relabeling
1750 @param cred Subject credential
1751 @param mp Object file system mount point
1752 @param mntlabel Policy label for fle system mount point
1754 Determine whether the subject identified by the credential can relabel
1755 the mount point. This call is made when a file system mount is updated.
1757 @return Return 0 if access is granted, otherwise an appropriate value for
1758 errno should be returned. Suggested failure: EACCES for label mismatch
1759 or EPERM for lack of privilege.
1761 typedef int mpo_mount_check_label_update_t(
1764 struct label
*mntlabel
1767 @brief Access control check for mounting a file system
1768 @param cred Subject credential
1769 @param vp Vnode that is to be the mount point
1770 @param vlabel Label associated with the vnode
1771 @param cnp Component name for vp
1772 @param vfc_name Filesystem type name
1774 Determine whether the subject identified by the credential can perform
1775 the mount operation on the target vnode.
1777 @return Return 0 if access is granted, otherwise an appropriate value for
1778 errno should be returned.
1780 typedef int mpo_mount_check_mount_t(
1783 struct label
*vlabel
,
1784 struct componentname
*cnp
,
1785 const char *vfc_name
1788 @brief Access control check for fs_snapshot_create
1789 @param cred Subject credential
1790 @mp Filesystem mount point to create snapshot of
1791 @name Name of snapshot to create
1793 Determine whether the subject identified by the credential can
1794 create a snapshot of the filesystem at the given mount point.
1796 @return Return 0 if access is granted, otherwise an appropriate value
1797 for errno should be returned.
1799 typedef int mpo_mount_check_snapshot_create_t(
1805 @brief Access control check for fs_snapshot_delete
1806 @param cred Subject credential
1807 @mp Filesystem mount point to delete snapshot of
1808 @name Name of snapshot to delete
1810 Determine whether the subject identified by the credential can
1811 delete the named snapshot from the filesystem at the given
1814 @return Return 0 if access is granted, otherwise an appropriate value
1815 for errno should be returned.
1817 typedef int mpo_mount_check_snapshot_delete_t(
1823 @brief Access control check remounting a filesystem
1824 @param cred Subject credential
1825 @param mp The mount point
1826 @param mlabel Label currently associated with the mount point
1828 Determine whether the subject identified by the credential can perform
1829 the remount operation on the target vnode.
1831 @return Return 0 if access is granted, otherwise an appropriate value for
1832 errno should be returned.
1834 typedef int mpo_mount_check_remount_t(
1837 struct label
*mlabel
1840 @brief Access control check for the settting of file system attributes
1841 @param cred Subject credential
1842 @param mp The mount structure of the file system
1843 @param vfa The attributes requested
1845 This entry point determines whether given subject can set information
1846 about the given file system, for example the volume name.
1848 @return Return 0 if access is granted, otherwise an appropriate value for
1849 errno should be returned.
1852 typedef int mpo_mount_check_setattr_t(
1855 struct label
*mp_label
,
1856 struct vfs_attr
*vfa
1859 @brief Access control check for file system statistics
1860 @param cred Subject credential
1861 @param mp Object file system mount
1862 @param mntlabel Policy label for mp
1864 Determine whether the subject identified by the credential can see
1865 the results of a statfs performed on the file system. This call may
1866 be made in a number of situations, including during invocations of
1867 statfs(2) and related calls, as well as to determine what file systems
1868 to exclude from listings of file systems, such as when getfsstat(2)
1871 @return Return 0 if access is granted, otherwise an appropriate value for
1872 errno should be returned. Suggested failure: EACCES for label mismatch
1873 or EPERM for lack of privilege.
1875 typedef int mpo_mount_check_stat_t(
1878 struct label
*mntlabel
1881 @brief Access control check for unmounting a filesystem
1882 @param cred Subject credential
1883 @param mp The mount point
1884 @param mlabel Label associated with the mount point
1886 Determine whether the subject identified by the credential can perform
1887 the unmount operation on the target vnode.
1889 @return Return 0 if access is granted, otherwise an appropriate value for
1890 errno should be returned.
1892 typedef int mpo_mount_check_umount_t(
1895 struct label
*mlabel
1898 @brief Create mount labels
1899 @param cred Subject credential
1900 @param mp Mount point of file system being mounted
1901 @param mntlabel Label to associate with the new mount point
1902 @see mpo_mount_label_init_t
1904 Fill out the labels on the mount point being created by the supplied
1905 user credential. This call is made when file systems are first mounted.
1907 typedef void mpo_mount_label_associate_t(
1910 struct label
*mntlabel
1913 @brief Destroy mount label
1914 @param label The label to be destroyed
1916 Destroy a file system mount label. Since the
1917 object is going out of scope, policy modules should free any
1918 internal storage associated with the label so that it may be
1921 typedef void mpo_mount_label_destroy_t(
1925 @brief Externalize a mount point label
1926 @param label Label to be externalized
1927 @param element_name Name of the label namespace for which labels should be
1929 @param sb String buffer to be filled with a text representation of the label
1931 Produce an external representation of the mount point label. An
1932 externalized label consists of a text representation of the label
1933 contents that can be used with user applications. Policy-agnostic
1934 user space tools will display this externalized version.
1936 The policy's externalize entry points will be called only if the
1937 policy has registered interest in the label namespace.
1939 @return 0 on success, return non-zero if an error occurs while
1940 externalizing the label data.
1943 typedef int mpo_mount_label_externalize_t(
1944 struct label
*label
,
1949 @brief Initialize mount point label
1950 @param label New label to initialize
1952 Initialize the label for a newly instantiated mount structure.
1953 This label is typically used to store a default label in the case
1954 that the file system has been mounted singlelabel. Since some
1955 file systems do not support persistent labels (extended attributes)
1956 or are read-only (such as CD-ROMs), it is often necessary to store
1957 a default label separately from the label of the mount point
1958 itself. Sleeping is permitted.
1960 typedef void mpo_mount_label_init_t(
1964 @brief Internalize a mount point label
1965 @param label Label to be internalized
1966 @param element_name Name of the label namespace for which the label should
1968 @param element_data Text data to be internalized
1970 Produce a mount point file system label from an external representation.
1971 An externalized label consists of a text representation of the label
1972 contents that can be used with user applications. Policy-agnostic
1973 user space tools will forward text version to the kernel for
1974 processing by individual policy modules.
1976 The policy's internalize entry points will be called only if the
1977 policy has registered interest in the label namespace.
1979 @return 0 on success, Otherwise, return non-zero if an error occurs
1980 while internalizing the label data.
1983 typedef int mpo_mount_label_internalize_t(
1984 struct label
*label
,
1989 @brief Set the label on an IPv4 datagram fragment
1990 @param datagram Datagram being fragmented
1991 @param datagramlabel Policy label for datagram
1992 @param fragment New fragment
1993 @param fragmentlabel Policy label for fragment
1995 Called when an IPv4 datagram is fragmented into several smaller datagrams.
1996 Policies implementing mbuf labels will typically copy the label from the
1997 source datagram to the new fragment.
1999 typedef void mpo_netinet_fragment_t(
2000 struct mbuf
*datagram
,
2001 struct label
*datagramlabel
,
2002 struct mbuf
*fragment
,
2003 struct label
*fragmentlabel
2006 @brief Set the label on an ICMP reply
2007 @param m mbuf containing the ICMP reply
2008 @param mlabel Policy label for m
2010 A policy may wish to update the label of an mbuf that refers to
2011 an ICMP packet being sent in response to an IP packet. This may
2012 be called in response to a bad packet or an ICMP request.
2014 typedef void mpo_netinet_icmp_reply_t(
2016 struct label
*mlabel
2019 @brief Set the label on a TCP reply
2020 @param m mbuf containing the TCP reply
2021 @param mlabel Policy label for m
2023 Called for outgoing TCP packets not associated with an actual socket.
2025 typedef void mpo_netinet_tcp_reply_t(
2027 struct label
*mlabel
2030 @brief Access control check for pipe ioctl
2031 @param cred Subject credential
2032 @param cpipe Object to be accessed
2033 @param pipelabel The label on the pipe
2034 @param cmd The ioctl command; see ioctl(2)
2036 Determine whether the subject identified by the credential can perform
2037 the ioctl operation indicated by cmd.
2039 @warning Since ioctl data is opaque from the standpoint of the MAC
2040 framework, policies must exercise extreme care when implementing
2041 access control checks.
2043 @return Return 0 if access is granted, otherwise an appropriate value for
2044 errno should be returned.
2047 typedef int mpo_pipe_check_ioctl_t(
2050 struct label
*pipelabel
,
2054 @brief Access control check for pipe kqfilter
2055 @param cred Subject credential
2056 @param kn Object knote
2057 @param cpipe Object to be accessed
2058 @param pipelabel Policy label for the pipe
2060 Determine whether the subject identified by the credential can
2061 receive the knote on the passed pipe.
2063 @return Return 0 if access if granted, otherwise an appropriate
2064 value for errno should be returned.
2066 typedef int mpo_pipe_check_kqfilter_t(
2070 struct label
*pipelabel
2073 @brief Access control check for pipe relabel
2074 @param cred Subject credential
2075 @param cpipe Object to be accessed
2076 @param pipelabel The current label on the pipe
2077 @param newlabel The new label to be used
2079 Determine whether the subject identified by the credential can
2080 perform a relabel operation on the passed pipe. The cred object holds
2081 the credentials of the subject performing the operation.
2083 @return Return 0 if access is granted, otherwise an appropriate value for
2084 errno should be returned.
2087 typedef int mpo_pipe_check_label_update_t(
2090 struct label
*pipelabel
,
2091 struct label
*newlabel
2094 @brief Access control check for pipe read
2095 @param cred Subject credential
2096 @param cpipe Object to be accessed
2097 @param pipelabel The label on the pipe
2099 Determine whether the subject identified by the credential can
2100 perform a read operation on the passed pipe. The cred object holds
2101 the credentials of the subject performing the operation.
2103 @return Return 0 if access is granted, otherwise an appropriate value for
2104 errno should be returned.
2107 typedef int mpo_pipe_check_read_t(
2110 struct label
*pipelabel
2113 @brief Access control check for pipe select
2114 @param cred Subject credential
2115 @param cpipe Object to be accessed
2116 @param pipelabel The label on the pipe
2117 @param which The operation selected on: FREAD or FWRITE
2119 Determine whether the subject identified by the credential can
2120 perform a select operation on the passed pipe. The cred object holds
2121 the credentials of the subject performing the operation.
2123 @return Return 0 if access is granted, otherwise an appropriate value for
2124 errno should be returned.
2127 typedef int mpo_pipe_check_select_t(
2130 struct label
*pipelabel
,
2134 @brief Access control check for pipe stat
2135 @param cred Subject credential
2136 @param cpipe Object to be accessed
2137 @param pipelabel The label on the pipe
2139 Determine whether the subject identified by the credential can
2140 perform a stat operation on the passed pipe. The cred object holds
2141 the credentials of the subject performing the operation.
2143 @return Return 0 if access is granted, otherwise an appropriate value for
2144 errno should be returned.
2147 typedef int mpo_pipe_check_stat_t(
2150 struct label
*pipelabel
2153 @brief Access control check for pipe write
2154 @param cred Subject credential
2155 @param cpipe Object to be accessed
2156 @param pipelabel The label on the pipe
2158 Determine whether the subject identified by the credential can
2159 perform a write operation on the passed pipe. The cred object holds
2160 the credentials of the subject performing the operation.
2162 @return Return 0 if access is granted, otherwise an appropriate value for
2163 errno should be returned.
2166 typedef int mpo_pipe_check_write_t(
2169 struct label
*pipelabel
2172 @brief Create a pipe label
2173 @param cred Subject credential
2174 @param cpipe object to be labeled
2175 @param pipelabel Label for the pipe object
2177 Create a label for the pipe object being created by the supplied
2178 user credential. This call is made when the pipe is being created
2179 XXXPIPE(for one or both sides of the pipe?).
2182 typedef void mpo_pipe_label_associate_t(
2185 struct label
*pipelabel
2188 @brief Copy a pipe label
2189 @param src Source pipe label
2190 @param dest Destination pipe label
2192 Copy the pipe label associated with src to dest.
2193 XXXPIPE Describe when this is used: most likely during pipe creation to
2194 copy from rpipe to wpipe.
2196 typedef void mpo_pipe_label_copy_t(
2201 @brief Destroy pipe label
2202 @param label The label to be destroyed
2204 Destroy a pipe label. Since the object is going out of scope,
2205 policy modules should free any internal storage associated with the
2206 label so that it may be destroyed.
2208 typedef void mpo_pipe_label_destroy_t(
2212 @brief Externalize a pipe label
2213 @param label Label to be externalized
2214 @param element_name Name of the label namespace for which labels should be
2216 @param sb String buffer to be filled with a text representation of the label
2218 Produce an external representation of the label on a pipe.
2219 An externalized label consists of a text representation
2220 of the label contents that can be used with user applications.
2221 Policy-agnostic user space tools will display this externalized
2224 The policy's externalize entry points will be called only if the
2225 policy has registered interest in the label namespace.
2227 @return 0 on success, return non-zero if an error occurs while
2228 externalizing the label data.
2231 typedef int mpo_pipe_label_externalize_t(
2232 struct label
*label
,
2237 @brief Initialize pipe label
2238 @param label New label to initialize
2240 Initialize label storage for use with a newly instantiated pipe object.
2241 Sleeping is permitted.
2243 typedef void mpo_pipe_label_init_t(
2247 @brief Internalize a pipe label
2248 @param label Label to be internalized
2249 @param element_name Name of the label namespace for which the label should
2251 @param element_data Text data to be internalized
2253 Produce a pipe label from an external representation. An
2254 externalized label consists of a text representation of the label
2255 contents that can be used with user applications. Policy-agnostic
2256 user space tools will forward text version to the kernel for
2257 processing by individual policy modules.
2259 The policy's internalize entry points will be called only if the
2260 policy has registered interest in the label namespace.
2262 @return 0 on success, Otherwise, return non-zero if an error occurs
2263 while internalizing the label data.
2266 typedef int mpo_pipe_label_internalize_t(
2267 struct label
*label
,
2272 @brief Update a pipe label
2273 @param cred Subject credential
2274 @param cpipe Object to be labeled
2275 @param oldlabel Existing pipe label
2276 @param newlabel New label to replace existing label
2277 @see mpo_pipe_check_label_update_t
2279 The subject identified by the credential has previously requested
2280 and was authorized to relabel the pipe; this entry point allows
2281 policies to perform the actual relabel operation. Policies should
2282 update oldlabel using the label stored in the newlabel parameter.
2285 typedef void mpo_pipe_label_update_t(
2288 struct label
*oldlabel
,
2289 struct label
*newlabel
2292 @brief Policy unload event
2293 @param mpc MAC policy configuration
2295 This is the MAC Framework policy unload event. This entry point will
2296 only be called if the module's policy configuration allows unload (if
2297 the MPC_LOADTIME_FLAG_UNLOADOK is set). Most security policies won't
2298 want to be unloaded; they should set their flags to prevent this
2299 entry point from being called.
2301 @warning During this call, the mac policy list mutex is held, so
2302 sleep operations cannot be performed, and calls out to other kernel
2303 subsystems must be made with caution.
2305 @see MPC_LOADTIME_FLAG_UNLOADOK
2307 typedef void mpo_policy_destroy_t(
2308 struct mac_policy_conf
*mpc
2311 @brief Policy initialization event
2312 @param mpc MAC policy configuration
2313 @see mac_policy_register
2314 @see mpo_policy_initbsd_t
2316 This is the MAC Framework policy initialization event. This entry
2317 point is called during mac_policy_register, when the policy module
2318 is first registered with the MAC Framework. This is often done very
2319 early in the boot process, after the kernel Mach subsystem has been
2320 initialized, but prior to the BSD subsystem being initialized.
2321 Since the kernel BSD services are not yet available, it is possible
2322 that some initialization must occur later, possibly in the
2323 mpo_policy_initbsd_t policy entry point, such as registering BSD system
2324 controls (sysctls). Policy modules loaded at boot time will be
2325 registered and initialized before labeled Mach objects are created.
2327 @warning During this call, the mac policy list mutex is held, so
2328 sleep operations cannot be performed, and calls out to other kernel
2329 subsystems must be made with caution.
2331 typedef void mpo_policy_init_t(
2332 struct mac_policy_conf
*mpc
2335 @brief Policy BSD initialization event
2336 @param mpc MAC policy configuration
2337 @see mpo_policy_init_t
2339 This entry point is called after the kernel BSD subsystem has been
2340 initialized. By this point, the module should already be loaded,
2341 registered, and initialized. Since policy modules are initialized
2342 before kernel BSD services are available, this second initialization
2343 phase is necessary. At this point, BSD services (memory management,
2344 synchronization primitives, vfs, etc.) are available, but the first
2345 process has not yet been created. Mach-related objects and tasks
2346 will already be fully initialized and may be in use--policies requiring
2347 ubiquitous labeling may also want to implement mpo_policy_init_t.
2349 @warning During this call, the mac policy list mutex is held, so
2350 sleep operations cannot be performed, and calls out to other kernel
2351 subsystems must be made with caution.
2353 typedef void mpo_policy_initbsd_t(
2354 struct mac_policy_conf
*mpc
2357 @brief Policy extension service
2358 @param p Calling process
2359 @param call Policy-specific syscall number
2360 @param arg Pointer to syscall arguments
2362 This entry point provides a policy-multiplexed system call so that
2363 policies may provide additional services to user processes without
2364 registering specific system calls. The policy name provided during
2365 registration is used to demux calls from userland, and the arguments
2366 will be forwarded to this entry point. When implementing new
2367 services, security modules should be sure to invoke appropriate
2368 access control checks from the MAC framework as needed. For
2369 example, if a policy implements an augmented signal functionality,
2370 it should call the necessary signal access control checks to invoke
2371 the MAC framework and other registered policies.
2373 @warning Since the format and contents of the policy-specific
2374 arguments are unknown to the MAC Framework, modules must perform the
2375 required copyin() of the syscall data on their own. No policy
2376 mediation is performed, so policies must perform any necessary
2377 access control checks themselves. If multiple policies are loaded,
2378 they will currently be unable to mediate calls to other policies.
2380 @return In the event of an error, an appropriate value for errno
2381 should be returned, otherwise return 0 upon success.
2383 typedef int mpo_policy_syscall_t(
2389 @brief Access control check for POSIX semaphore create
2390 @param cred Subject credential
2391 @param name String name of the semaphore
2393 Determine whether the subject identified by the credential can create
2394 a POSIX semaphore specified by name.
2396 @return Return 0 if access is granted, otherwise an appropriate value for
2397 errno should be returned.
2399 typedef int mpo_posixsem_check_create_t(
2404 @brief Access control check for POSIX semaphore open
2405 @param cred Subject credential
2406 @param ps Pointer to semaphore information structure
2407 @param semlabel Label associated with the semaphore
2409 Determine whether the subject identified by the credential can open
2410 the named POSIX semaphore with label semlabel.
2412 @return Return 0 if access is granted, otherwise an appropriate value for
2413 errno should be returned.
2415 typedef int mpo_posixsem_check_open_t(
2417 struct pseminfo
*ps
,
2418 struct label
*semlabel
2421 @brief Access control check for POSIX semaphore post
2422 @param cred Subject credential
2423 @param ps Pointer to semaphore information structure
2424 @param semlabel Label associated with the semaphore
2426 Determine whether the subject identified by the credential can unlock
2427 the named POSIX semaphore with label semlabel.
2429 @return Return 0 if access is granted, otherwise an appropriate value for
2430 errno should be returned.
2432 typedef int mpo_posixsem_check_post_t(
2434 struct pseminfo
*ps
,
2435 struct label
*semlabel
2438 @brief Access control check for POSIX semaphore unlink
2439 @param cred Subject credential
2440 @param ps Pointer to semaphore information structure
2441 @param semlabel Label associated with the semaphore
2442 @param name String name of the semaphore
2444 Determine whether the subject identified by the credential can remove
2445 the named POSIX semaphore with label semlabel.
2447 @return Return 0 if access is granted, otherwise an appropriate value for
2448 errno should be returned.
2450 typedef int mpo_posixsem_check_unlink_t(
2452 struct pseminfo
*ps
,
2453 struct label
*semlabel
,
2457 @brief Access control check for POSIX semaphore wait
2458 @param cred Subject credential
2459 @param ps Pointer to semaphore information structure
2460 @param semlabel Label associated with the semaphore
2462 Determine whether the subject identified by the credential can lock
2463 the named POSIX semaphore with label semlabel.
2465 @return Return 0 if access is granted, otherwise an appropriate value for
2466 errno should be returned.
2468 typedef int mpo_posixsem_check_wait_t(
2470 struct pseminfo
*ps
,
2471 struct label
*semlabel
2474 @brief Create a POSIX semaphore label
2475 @param cred Subject credential
2476 @param ps Pointer to semaphore information structure
2477 @param semlabel Label to associate with the new semaphore
2478 @param name String name of the semaphore
2480 Label a new POSIX semaphore. The label was previously
2481 initialized and associated with the semaphore. At this time, an
2482 appropriate initial label value should be assigned to the object and
2483 stored in semalabel.
2485 typedef void mpo_posixsem_label_associate_t(
2487 struct pseminfo
*ps
,
2488 struct label
*semlabel
,
2492 @brief Destroy POSIX semaphore label
2493 @param label The label to be destroyed
2495 Destroy a POSIX semaphore label. Since the object is
2496 going out of scope, policy modules should free any internal storage
2497 associated with the label so that it may be destroyed.
2499 typedef void mpo_posixsem_label_destroy_t(
2503 @brief Initialize POSIX semaphore label
2504 @param label New label to initialize
2506 Initialize the label for a newly instantiated POSIX semaphore. Sleeping
2509 typedef void mpo_posixsem_label_init_t(
2513 @brief Access control check for POSIX shared memory region create
2514 @param cred Subject credential
2515 @param name String name of the shared memory region
2517 Determine whether the subject identified by the credential can create
2518 the POSIX shared memory region referenced by name.
2520 @return Return 0 if access is granted, otherwise an appropriate value for
2521 errno should be returned.
2523 typedef int mpo_posixshm_check_create_t(
2528 @brief Access control check for mapping POSIX shared memory
2529 @param cred Subject credential
2530 @param ps Pointer to shared memory information structure
2531 @param shmlabel Label associated with the shared memory region
2532 @param prot mmap protections; see mmap(2)
2533 @param flags shmat flags; see shmat(2)
2535 Determine whether the subject identified by the credential can map
2536 the POSIX shared memory segment associated with shmlabel.
2538 @return Return 0 if access is granted, otherwise an appropriate value for
2539 errno should be returned.
2541 typedef int mpo_posixshm_check_mmap_t(
2543 struct pshminfo
*ps
,
2544 struct label
*shmlabel
,
2549 @brief Access control check for POSIX shared memory region open
2550 @param cred Subject credential
2551 @param ps Pointer to shared memory information structure
2552 @param shmlabel Label associated with the shared memory region
2553 @param fflags shm_open(2) open flags ('fflags' encoded)
2555 Determine whether the subject identified by the credential can open
2556 the POSIX shared memory region.
2558 @return Return 0 if access is granted, otherwise an appropriate value for
2559 errno should be returned.
2561 typedef int mpo_posixshm_check_open_t(
2563 struct pshminfo
*ps
,
2564 struct label
*shmlabel
,
2568 @brief Access control check for POSIX shared memory stat
2569 @param cred Subject credential
2570 @param ps Pointer to shared memory information structure
2571 @param shmlabel Label associated with the shared memory region
2573 Determine whether the subject identified by the credential can obtain
2574 status for the POSIX shared memory segment associated with shmlabel.
2576 @return Return 0 if access is granted, otherwise an appropriate value for
2577 errno should be returned.
2579 typedef int mpo_posixshm_check_stat_t(
2581 struct pshminfo
*ps
,
2582 struct label
*shmlabel
2585 @brief Access control check for POSIX shared memory truncate
2586 @param cred Subject credential
2587 @param ps Pointer to shared memory information structure
2588 @param shmlabel Label associated with the shared memory region
2589 @param len Length to truncate or extend shared memory segment
2591 Determine whether the subject identified by the credential can truncate
2592 or extend (to len) the POSIX shared memory segment associated with shmlabel.
2594 @return Return 0 if access is granted, otherwise an appropriate value for
2595 errno should be returned.
2597 typedef int mpo_posixshm_check_truncate_t(
2599 struct pshminfo
*ps
,
2600 struct label
*shmlabel
,
2604 @brief Access control check for POSIX shared memory unlink
2605 @param cred Subject credential
2606 @param ps Pointer to shared memory information structure
2607 @param shmlabel Label associated with the shared memory region
2608 @param name String name of the shared memory region
2610 Determine whether the subject identified by the credential can delete
2611 the POSIX shared memory segment associated with shmlabel.
2613 @return Return 0 if access is granted, otherwise an appropriate value for
2614 errno should be returned.
2616 typedef int mpo_posixshm_check_unlink_t(
2618 struct pshminfo
*ps
,
2619 struct label
*shmlabel
,
2623 @brief Create a POSIX shared memory region label
2624 @param cred Subject credential
2625 @param ps Pointer to shared memory information structure
2626 @param shmlabel Label to associate with the new shared memory region
2627 @param name String name of the shared memory region
2629 Label a new POSIX shared memory region. The label was previously
2630 initialized and associated with the shared memory region. At this
2631 time, an appropriate initial label value should be assigned to the
2632 object and stored in shmlabel.
2634 typedef void mpo_posixshm_label_associate_t(
2636 struct pshminfo
*ps
,
2637 struct label
*shmlabel
,
2641 @brief Destroy POSIX shared memory label
2642 @param label The label to be destroyed
2644 Destroy a POSIX shared memory region label. Since the
2645 object is going out of scope, policy modules should free any
2646 internal storage associated with the label so that it may be
2649 typedef void mpo_posixshm_label_destroy_t(
2653 @brief Initialize POSIX Shared Memory region label
2654 @param label New label to initialize
2656 Initialize the label for newly a instantiated POSIX Shared Memory
2657 region. Sleeping is permitted.
2659 typedef void mpo_posixshm_label_init_t(
2663 @brief Access control check for privileged operations
2664 @param cred Subject credential
2665 @param priv Requested privilege (see sys/priv.h)
2667 Determine whether the subject identified by the credential can perform
2668 a privileged operation. Privileged operations are allowed if the cred
2669 is the superuser or any policy returns zero for mpo_priv_grant, unless
2670 any policy returns nonzero for mpo_priv_check.
2672 @return Return 0 if access is granted, otherwise EPERM should be returned.
2674 typedef int mpo_priv_check_t(
2679 @brief Grant regular users the ability to perform privileged operations
2680 @param cred Subject credential
2681 @param priv Requested privilege (see sys/priv.h)
2683 Determine whether the subject identified by the credential should be
2684 allowed to perform a privileged operation that in the absense of any
2685 MAC policy it would not be able to perform. Privileged operations are
2686 allowed if the cred is the superuser or any policy returns zero for
2687 mpo_priv_grant, unless any policy returns nonzero for mpo_priv_check.
2689 Unlike other MAC hooks which can only reduce the privilege of a
2690 credential, this hook raises the privilege of a credential when it
2691 returns 0. Extreme care must be taken when implementing this hook to
2692 avoid undermining the security of the system.
2694 @return Return 0 if additional privilege is granted, otherwise EPERM
2697 typedef int mpo_priv_grant_t(
2702 @brief Access control check for debugging process
2703 @param cred Subject credential
2704 @param proc Object process
2706 Determine whether the subject identified by the credential can debug
2707 the passed process. This call may be made in a number of situations,
2708 including use of the ptrace(2) and ktrace(2) APIs, as well as for some
2709 types of procfs operations.
2711 @return Return 0 if access is granted, otherwise an appropriate value for
2712 errno should be returned. Suggested failure: EACCES for label mismatch,
2713 EPERM for lack of privilege, or ESRCH to hide visibility of the target.
2715 typedef int mpo_proc_check_debug_t(
2720 @brief Access control over fork
2721 @param cred Subject credential
2722 @param proc Subject process trying to fork
2724 Determine whether the subject identified is allowed to fork.
2726 @return Return 0 if access is granted, otherwise an appropriate value for
2727 errno should be returned.
2729 typedef int mpo_proc_check_fork_t(
2734 @brief Access control check for setting host special ports.
2735 @param cred Subject credential
2736 @param id The host special port to set
2737 @param port The new value to set for the special port
2739 @return Return 0 if access is granted, otherwise an appropriate value for
2740 errno should be returned.
2742 typedef int mpo_proc_check_set_host_special_port_t(
2745 struct ipc_port
*port
2748 @brief Access control check for setting host exception ports.
2749 @param cred Subject credential
2750 @param exception Exception port to set
2752 @return Return 0 if access is granted, otherwise an appropriate value for
2753 errno should be returned.
2755 typedef int mpo_proc_check_set_host_exception_port_t(
2757 unsigned int exception
2760 @brief Access control over pid_suspend and pid_resume
2761 @param cred Subject credential
2762 @param proc Subject process trying to run pid_suspend or pid_resume
2763 @param sr Call is suspend (0) or resume (1)
2765 Determine whether the subject identified is allowed to suspend or resume
2768 @return Return 0 if access is granted, otherwise an appropriate value for
2769 errno should be returned.
2771 typedef int mpo_proc_check_suspend_resume_t(
2777 @brief Access control check for retrieving audit information
2778 @param cred Subject credential
2780 Determine whether the subject identified by the credential can get
2781 audit information such as the audit user ID, the preselection mask,
2782 the terminal ID and the audit session ID, using the getaudit() system call.
2784 @return Return 0 if access is granted, otherwise an appropriate value for
2785 errno should be returned.
2787 typedef int mpo_proc_check_getaudit_t(
2791 @brief Access control check for retrieving audit user ID
2792 @param cred Subject credential
2794 Determine whether the subject identified by the credential can get
2795 the user identity being used by the auditing system, using the getauid()
2798 @return Return 0 if access is granted, otherwise an appropriate value for
2799 errno should be returned.
2801 typedef int mpo_proc_check_getauid_t(
2805 @brief Access control check for retrieving Login Context ID
2806 @param p0 Calling process
2807 @param p Effected process
2808 @param pid syscall PID argument
2810 Determine if getlcid(2) system call is permitted.
2812 Information returned by this system call is similar to that returned via
2813 process listings etc.
2815 @return Return 0 if access is granted, otherwise an appropriate value for
2816 errno should be returned.
2818 typedef int mpo_proc_check_getlcid_t(
2824 @brief Access control check for retrieving ledger information
2825 @param cred Subject credential
2826 @param target Object process
2827 @param op ledger operation
2829 Determine if ledger(2) system call is permitted.
2831 Information returned by this system call is similar to that returned via
2832 process listings etc.
2834 @return Return 0 if access is granted, otherwise an appropriate value for
2835 errno should be returned.
2837 typedef int mpo_proc_check_ledger_t(
2839 struct proc
*target
,
2843 @brief Access control check for escaping default CPU usage monitor parameters.
2844 @param cred Subject credential
2846 Determine if a credential has permission to program CPU usage monitor parameters
2847 that are less restrictive than the global system-wide defaults.
2849 @return Return 0 if access is granted, otherwise an appropriate value for
2850 errno should be returned.
2852 typedef int mpo_proc_check_cpumon_t(
2856 @brief Access control check for retrieving process information.
2857 @param cred Subject credential
2858 @param target Target process (may be null, may be zombie)
2860 Determine if a credential has permission to access process information as defined
2861 by call number and flavor on target process
2863 @return Return 0 if access is granted, otherwise an appropriate value for
2864 errno should be returned.
2866 typedef int mpo_proc_check_proc_info_t(
2868 struct proc
*target
,
2873 @brief Access control check for retrieving code signing information.
2874 @param cred Subject credential
2875 @param target Target process
2876 @param op Code signing operation being performed
2878 Determine whether the subject identified by the credential should be
2879 allowed to get code signing information about the target process.
2881 @return Return 0 if access is granted, otherwise an appropriate value for
2882 errno should be returned.
2884 typedef int mpo_proc_check_get_cs_info_t(
2886 struct proc
*target
,
2890 @brief Access control check for setting code signing information.
2891 @param cred Subject credential
2892 @param target Target process
2893 @param op Code signing operation being performed.
2895 Determine whether the subject identified by the credential should be
2896 allowed to set code signing information about the target process.
2898 @return Return 0 if permission is granted, otherwise an appropriate
2899 value of errno should be returned.
2901 typedef int mpo_proc_check_set_cs_info_t(
2903 struct proc
*target
,
2907 @brief Access control check for mmap MAP_ANON
2908 @param proc User process requesting the memory
2909 @param cred Subject credential
2910 @param u_addr Start address of the memory range
2911 @param u_size Length address of the memory range
2912 @param prot mmap protections; see mmap(2)
2913 @param flags Type of mapped object; see mmap(2)
2914 @param maxprot Maximum rights
2916 Determine whether the subject identified by the credential should be
2917 allowed to obtain anonymous memory using the specified flags and
2918 protections on the new mapping. MAP_ANON will always be present in the
2919 flags. Certain combinations of flags with a non-NULL addr may
2920 cause a mapping to be rejected before this hook is called. The maxprot field
2921 holds the maximum permissions on the new mapping, a combination of
2922 VM_PROT_READ, VM_PROT_WRITE and VM_PROT_EXECUTE. To avoid overriding prior
2923 access control checks, a policy should only remove flags from maxprot.
2925 @return Return 0 if access is granted, otherwise an appropriate value for
2926 errno should be returned. Suggested failure: EPERM for lack of privilege.
2928 typedef int mpo_proc_check_map_anon_t(
2938 @brief Access control check for setting memory protections
2939 @param cred Subject credential
2940 @param proc User process requesting the change
2941 @param addr Start address of the memory range
2942 @param size Length address of the memory range
2943 @param prot Memory protections, see mmap(2)
2945 Determine whether the subject identified by the credential should
2946 be allowed to set the specified memory protections on memory mapped
2947 in the process proc.
2949 @return Return 0 if access is granted, otherwise an appropriate value for
2950 errno should be returned.
2952 typedef int mpo_proc_check_mprotect_t(
2960 @brief Access control check for changing scheduling parameters
2961 @param cred Subject credential
2962 @param proc Object process
2964 Determine whether the subject identified by the credential can change
2965 the scheduling parameters of the passed process.
2967 @return Return 0 if access is granted, otherwise an appropriate value for
2968 errno should be returned. Suggested failure: EACCES for label mismatch,
2969 EPERM for lack of privilege, or ESRCH to limit visibility.
2971 typedef int mpo_proc_check_sched_t(
2976 @brief Access control check for setting audit information
2977 @param cred Subject credential
2978 @param ai Audit information
2980 Determine whether the subject identified by the credential can set
2981 audit information such as the the preselection mask, the terminal ID
2982 and the audit session ID, using the setaudit() system call.
2984 @return Return 0 if access is granted, otherwise an appropriate value for
2985 errno should be returned.
2987 typedef int mpo_proc_check_setaudit_t(
2989 struct auditinfo_addr
*ai
2992 @brief Access control check for setting audit user ID
2993 @param cred Subject credential
2994 @param auid Audit user ID
2996 Determine whether the subject identified by the credential can set
2997 the user identity used by the auditing system, using the setauid()
3000 @return Return 0 if access is granted, otherwise an appropriate value for
3001 errno should be returned.
3003 typedef int mpo_proc_check_setauid_t(
3008 @brief Access control check for setting the Login Context
3009 @param p0 Calling process
3010 @param p Effected process
3011 @param pid syscall PID argument
3012 @param lcid syscall LCID argument
3014 Determine if setlcid(2) system call is permitted.
3016 See xnu/bsd/kern/kern_prot.c:setlcid() implementation for example of
3017 decoding syscall arguments to determine action desired by caller.
3019 Five distinct actions are possible: CREATE JOIN LEAVE ADOPT ORPHAN
3021 @return Return 0 if access is granted, otherwise an appropriate value for
3022 errno should be returned.
3024 typedef int mpo_proc_check_setlcid_t(
3031 @brief Access control check for delivering signal
3032 @param cred Subject credential
3033 @param proc Object process
3034 @param signum Signal number; see kill(2)
3036 Determine whether the subject identified by the credential can deliver
3037 the passed signal to the passed process.
3039 @warning Programs typically expect to be able to send and receive
3040 signals as part or their normal process lifecycle; caution should be
3041 exercised when implementing access controls over signal events.
3043 @return Return 0 if access is granted, otherwise an appropriate value for
3044 errno should be returned. Suggested failure: EACCES for label mismatch,
3045 EPERM for lack of privilege, or ESRCH to limit visibility.
3047 typedef int mpo_proc_check_signal_t(
3053 @brief Access control check for wait
3054 @param cred Subject credential
3055 @param proc Object process
3057 Determine whether the subject identified by the credential can wait
3058 for process termination.
3060 @warning Caution should be exercised when implementing access
3061 controls for wait, since programs often wait for child processes to
3062 exit. Failure to be notified of a child process terminating may
3063 cause the parent process to hang, or may produce zombie processes.
3065 @return Return 0 if access is granted, otherwise an appropriate value for
3066 errno should be returned.
3068 typedef int mpo_proc_check_wait_t(
3073 @brief Destroy process label
3074 @param label The label to be destroyed
3076 Destroy a process label. Since the object is going
3077 out of scope, policy modules should free any internal storage
3078 associated with the label so that it may be destroyed.
3080 typedef void mpo_proc_label_destroy_t(
3084 @brief Initialize process label
3085 @param label New label to initialize
3086 @see mpo_cred_label_init_t
3088 Initialize the label for a newly instantiated BSD process structure.
3089 Normally, security policies will store the process label in the user
3090 credential rather than here in the process structure. However,
3091 there are some floating label policies that may need to temporarily
3092 store a label in the process structure until it is safe to update
3093 the user credential label. Sleeping is permitted.
3095 typedef void mpo_proc_label_init_t(
3099 @brief Access control check for socket accept
3100 @param cred Subject credential
3101 @param so Object socket
3102 @param socklabel Policy label for socket
3104 Determine whether the subject identified by the credential can accept()
3105 a new connection on the socket from the host specified by addr.
3107 @return Return 0 if access if granted, otherwise an appropriate
3108 value for errno should be returned.
3110 typedef int mpo_socket_check_accept_t(
3113 struct label
*socklabel
3116 @brief Access control check for a pending socket accept
3117 @param cred Subject credential
3118 @param so Object socket
3119 @param socklabel Policy label for socket
3120 @param addr Address of the listening socket (coming soon)
3122 Determine whether the subject identified by the credential can accept()
3123 a pending connection on the socket from the host specified by addr.
3125 @return Return 0 if access if granted, otherwise an appropriate
3126 value for errno should be returned.
3128 typedef int mpo_socket_check_accepted_t(
3131 struct label
*socklabel
,
3132 struct sockaddr
*addr
3135 @brief Access control check for socket bind
3136 @param cred Subject credential
3137 @param so Object socket
3138 @param socklabel Policy label for socket
3139 @param addr Name to assign to the socket
3141 Determine whether the subject identified by the credential can bind()
3142 the name (addr) to the socket.
3144 @return Return 0 if access if granted, otherwise an appropriate
3145 value for errno should be returned.
3147 typedef int mpo_socket_check_bind_t(
3150 struct label
*socklabel
,
3151 struct sockaddr
*addr
3154 @brief Access control check for socket connect
3155 @param cred Subject credential
3156 @param so Object socket
3157 @param socklabel Policy label for socket
3158 @param addr Name to assign to the socket
3160 Determine whether the subject identified by the credential can
3161 connect() the passed socket to the remote host specified by addr.
3163 @return Return 0 if access if granted, otherwise an appropriate
3164 value for errno should be returned.
3166 typedef int mpo_socket_check_connect_t(
3169 struct label
*socklabel
,
3170 struct sockaddr
*addr
3173 @brief Access control check for socket() system call.
3174 @param cred Subject credential
3175 @param domain communication domain
3176 @param type socket type
3177 @param protocol socket protocol
3179 Determine whether the subject identified by the credential can
3180 make the socket() call.
3182 @return Return 0 if access if granted, otherwise an appropriate
3183 value for errno should be returned.
3185 typedef int mpo_socket_check_create_t(
3192 @brief Access control check for delivering data to a user's receieve queue
3193 @param so The socket data is being delivered to
3194 @param so_label The label of so
3195 @param m The mbuf whose data will be deposited into the receive queue
3196 @param m_label The label of the sender of the data.
3198 A socket has a queue for receiving incoming data. When a packet arrives
3199 on the wire, it eventually gets deposited into this queue, which the
3200 owner of the socket drains when they read from the socket's file descriptor.
3202 This function determines whether the socket can receive data from
3203 the sender specified by m_label.
3205 @warning There is an outstanding design issue surrounding the placement
3206 of this function. The check must be placed either before or after the
3207 TCP sequence and ACK counters are updated. Placing the check before
3208 the counters are updated causes the incoming packet to be resent by
3209 the remote if the check rejects it. Placing the check after the counters
3210 are updated results in a completely silent drop. As far as each TCP stack
3211 is concerned the packet was received, however, the data will not be in the
3212 socket's receive queue. Another consideration is that the current design
3213 requires using the "failed label" occasionally. In that case, on rejection,
3214 we want the remote TCP to resend the data. Because of this, we chose to
3215 place this check before the counters are updated, so rejected packets will be
3216 resent by the remote host.
3218 If a policy keeps rejecting the same packet, eventually the connection will
3219 be dropped. Policies have several options if this design causes problems.
3220 For example, one options is to sanitize the mbuf such that it is acceptable,
3221 then accept it. That may require negotiation between policies as the
3222 Framework will not know to re-check the packet.
3224 The policy must handle NULL MBUF labels. This will likely be the case
3225 for non-local TCP sockets for example.
3227 @return Return 0 if access if granted, otherwise an appropriate
3228 value for errno should be returned.
3230 typedef int mpo_socket_check_deliver_t(
3232 struct label
*so_label
,
3234 struct label
*m_label
3237 @brief Access control check for socket kqfilter
3238 @param cred Subject credential
3239 @param kn Object knote
3240 @param so Object socket
3241 @param socklabel Policy label for socket
3243 Determine whether the subject identified by the credential can
3244 receive the knote on the passed 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_kqfilter_t(
3253 struct label
*socklabel
3256 @brief Access control check for socket relabel
3257 @param cred Subject credential
3258 @param so Object socket
3259 @param so_label The current label of so
3260 @param newlabel The label to be assigned to so
3262 Determine whether the subject identified by the credential can
3263 change the label on the socket.
3265 @return Return 0 if access if granted, otherwise an appropriate
3266 value for errno should be returned.
3268 typedef int mpo_socket_check_label_update_t(
3271 struct label
*so_label
,
3272 struct label
*newlabel
3275 @brief Access control check for socket listen
3276 @param cred Subject credential
3277 @param so Object socket
3278 @param socklabel Policy label for socket
3280 Determine whether the subject identified by the credential can
3281 listen() on the passed 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_listen_t(
3289 struct label
*socklabel
3292 @brief Access control check for socket receive
3293 @param cred Subject credential
3294 @param so Object socket
3295 @param socklabel Policy label for socket
3297 Determine whether the subject identified by the credential can
3298 receive data from the socket.
3300 @return Return 0 if access if granted, otherwise an appropriate
3301 value for errno should be returned.
3303 typedef int mpo_socket_check_receive_t(
3306 struct label
*socklabel
3310 @brief Access control check for socket receive
3311 @param cred Subject credential
3312 @param sock Object socket
3313 @param socklabel Policy label for socket
3314 @param saddr Name of the remote socket
3316 Determine whether the subject identified by the credential can
3317 receive data from the remote host specified by addr.
3319 @return Return 0 if access if granted, otherwise an appropriate
3320 value for errno should be returned.
3322 typedef int mpo_socket_check_received_t(
3324 struct socket
*sock
,
3325 struct label
*socklabel
,
3326 struct sockaddr
*saddr
3331 @brief Access control check for socket select
3332 @param cred Subject credential
3333 @param so Object socket
3334 @param socklabel Policy label for socket
3335 @param which The operation selected on: FREAD or FWRITE
3337 Determine whether the subject identified by the credential can use the
3338 socket in a call to select().
3340 @return Return 0 if access if granted, otherwise an appropriate
3341 value for errno should be returned.
3343 typedef int mpo_socket_check_select_t(
3346 struct label
*socklabel
,
3350 @brief Access control check for socket send
3351 @param cred Subject credential
3352 @param so Object socket
3353 @param socklabel Policy label for socket
3354 @param addr Address being sent to
3356 Determine whether the subject identified by the credential can send
3359 @return Return 0 if access if granted, otherwise an appropriate
3360 value for errno should be returned.
3362 typedef int mpo_socket_check_send_t(
3365 struct label
*socklabel
,
3366 struct sockaddr
*addr
3369 @brief Access control check for retrieving socket status
3370 @param cred Subject credential
3371 @param so Object socket
3372 @param socklabel Policy label for so
3374 Determine whether the subject identified by the credential can
3375 execute the stat() system call on the given socket.
3377 @return Return 0 if access if granted, otherwise an appropriate
3378 value for errno should be returned.
3380 typedef int mpo_socket_check_stat_t(
3383 struct label
*socklabel
3386 @brief Access control check for setting socket options
3387 @param cred Subject credential
3388 @param so Object socket
3389 @param socklabel Policy label for so
3390 @param sopt The options being set
3392 Determine whether the subject identified by the credential can
3393 execute the setsockopt system call on the given socket.
3395 @return Return 0 if access if granted, otherwise an appropriate
3396 value for errno should be returned.
3398 typedef int mpo_socket_check_setsockopt_t(
3401 struct label
*socklabel
,
3402 struct sockopt
*sopt
3405 @brief Access control check for getting socket options
3406 @param cred Subject credential
3407 @param so Object socket
3408 @param socklabel Policy label for so
3409 @param sopt The options to get
3411 Determine whether the subject identified by the credential can
3412 execute the getsockopt system call on the given socket.
3414 @return Return 0 if access if granted, otherwise an appropriate
3415 value for errno should be returned.
3417 typedef int mpo_socket_check_getsockopt_t(
3420 struct label
*socklabel
,
3421 struct sockopt
*sopt
3424 @brief Label a socket
3425 @param oldsock Listening socket
3426 @param oldlabel Policy label associated with oldsock
3427 @param newsock New socket
3428 @param newlabel Policy label associated with newsock
3430 A new socket is created when a connection is accept(2)ed. This
3431 function labels the new socket based on the existing listen(2)ing
3434 typedef void mpo_socket_label_associate_accept_t(
3436 struct label
*oldlabel
,
3438 struct label
*newlabel
3441 @brief Assign a label to a new socket
3442 @param cred Credential of the owning process
3443 @param so The socket being labeled
3444 @param solabel The label
3445 @warning cred can be NULL
3447 Set the label on a newly created socket from the passed subject
3448 credential. This call is made when a socket is created. The
3449 credentials may be null if the socket is being created by the
3452 typedef void mpo_socket_label_associate_t(
3455 struct label
*solabel
3458 @brief Copy a socket label
3459 @param src Source label
3460 @param dest Destination label
3462 Copy the socket label information in src into dest.
3464 typedef void mpo_socket_label_copy_t(
3469 @brief Destroy socket label
3470 @param label The label to be destroyed
3472 Destroy a socket label. Since the object is going out of
3473 scope, policy modules should free any internal storage associated
3474 with the label so that it may be destroyed.
3476 typedef void mpo_socket_label_destroy_t(
3480 @brief Externalize a socket label
3481 @param label Label to be externalized
3482 @param element_name Name of the label namespace for which labels should be
3484 @param sb String buffer to be filled with a text representation of label
3486 Produce an externalized socket label based on the label structure passed.
3487 An externalized label consists of a text representation of the label
3488 contents that can be used with userland applications and read by the
3489 user. If element_name does not match a namespace managed by the policy,
3490 simply return 0. Only return nonzero if an error occurs while externalizing
3493 @return In the event of an error, an appropriate value for errno
3494 should be returned, otherwise return 0 upon success.
3496 typedef int mpo_socket_label_externalize_t(
3497 struct label
*label
,
3502 @brief Initialize socket label
3503 @param label New label to initialize
3504 @param waitok Malloc flags
3506 Initialize the label of a newly instantiated socket. The waitok
3507 field may be one of M_WAITOK and M_NOWAIT, and should be employed to
3508 avoid performing a sleeping malloc(9) during this initialization
3509 call. It it not always safe to sleep during this entry point.
3511 @warning Since it is possible for the waitok flags to be set to
3512 M_NOWAIT, the malloc operation may fail.
3514 @return In the event of an error, an appropriate value for errno
3515 should be returned, otherwise return 0 upon success.
3517 typedef int mpo_socket_label_init_t(
3518 struct label
*label
,
3522 @brief Internalize a socket label
3523 @param label Label to be filled in
3524 @param element_name Name of the label namespace for which the label should
3526 @param element_data Text data to be internalized
3528 Produce an internal socket label structure based on externalized label
3529 data in text format.
3531 The policy's internalize entry points will be called only if the
3532 policy has registered interest in the label namespace.
3534 @return In the event of an error, an appropriate value for errno
3535 should be returned, otherwise return 0 upon success.
3537 typedef int mpo_socket_label_internalize_t(
3538 struct label
*label
,
3543 @brief Relabel socket
3544 @param cred Subject credential
3545 @param so Object; socket
3546 @param so_label Current label of the socket
3547 @param newlabel The label to be assigned to so
3549 The subject identified by the credential has previously requested
3550 and was authorized to relabel the socket; this entry point allows
3551 policies to perform the actual label update operation.
3553 @warning XXX This entry point will likely change in future versions.
3555 typedef void mpo_socket_label_update_t(
3558 struct label
*so_label
,
3559 struct label
*newlabel
3562 @brief Set the peer label on a socket from mbuf
3563 @param m Mbuf chain received on socket so
3564 @param m_label Label for m
3565 @param so Current label for the socket
3566 @param so_label Policy label to be filled out for the socket
3568 Set the peer label of a socket based on the label of the sender of the
3571 This is called for every TCP/IP packet received. The first call for a given
3572 socket operates on a newly initialized label, and subsequent calls operate
3573 on existing label data.
3575 @warning Because this can affect performance significantly, it has
3576 different sematics than other 'set' operations. Typically, 'set' operations
3577 operate on newly initialzed labels and policies do not need to worry about
3578 clobbering existing values. In this case, it is too inefficient to
3579 initialize and destroy a label every time data is received for the socket.
3580 Instead, it is up to the policies to determine how to replace the label data.
3581 Most policies should be able to replace the data inline.
3583 typedef void mpo_socketpeer_label_associate_mbuf_t(
3585 struct label
*m_label
,
3587 struct label
*so_label
3590 @brief Set the peer label on a socket from socket
3591 @param source Local socket
3592 @param sourcelabel Policy label for source
3593 @param target Peer socket
3594 @param targetlabel Policy label to fill in for target
3596 Set the peer label on a stream UNIX domain socket from the passed
3597 remote socket endpoint. This call will be made when the socket pair
3598 is connected, and will be made for both endpoints.
3600 Note that this call is only made on connection; it is currently not updated
3601 during communication.
3603 typedef void mpo_socketpeer_label_associate_socket_t(
3605 struct label
*sourcelabel
,
3607 struct label
*targetlabel
3610 @brief Destroy socket peer label
3611 @param label The peer label to be destroyed
3613 Destroy a socket peer label. Since the object is going out of
3614 scope, policy modules should free any internal storage associated
3615 with the label so that it may be destroyed.
3617 typedef void mpo_socketpeer_label_destroy_t(
3621 @brief Externalize a socket peer label
3622 @param label Label to be externalized
3623 @param element_name Name of the label namespace for which labels should be
3625 @param sb String buffer to be filled with a text representation of label
3627 Produce an externalized socket peer label based on the label structure
3628 passed. An externalized label consists of a text representation of the
3629 label contents that can be used with userland applications and read by the
3630 user. If element_name does not match a namespace managed by the policy,
3631 simply return 0. Only return nonzero if an error occurs while externalizing
3634 @return In the event of an error, an appropriate value for errno
3635 should be returned, otherwise return 0 upon success.
3637 typedef int mpo_socketpeer_label_externalize_t(
3638 struct label
*label
,
3643 @brief Initialize socket peer label
3644 @param label New label to initialize
3645 @param waitok Malloc flags
3647 Initialize the peer label of a newly instantiated socket. The
3648 waitok field may be one of M_WAITOK and M_NOWAIT, and should be
3649 employed to avoid performing a sleeping malloc(9) during this
3650 initialization call. It it not always safe to sleep during this
3653 @warning Since it is possible for the waitok flags to be set to
3654 M_NOWAIT, the malloc operation may fail.
3656 @return In the event of an error, an appropriate value for errno
3657 should be returned, otherwise return 0 upon success.
3659 typedef int mpo_socketpeer_label_init_t(
3660 struct label
*label
,
3664 @brief Access control check for enabling accounting
3665 @param cred Subject credential
3666 @param vp Accounting file
3667 @param vlabel Label associated with vp
3669 Determine whether the subject should be allowed to enable accounting,
3670 based on its label and the label of the accounting log file. See
3671 acct(5) for more information.
3673 As accounting is disabled by passing NULL to the acct(2) system call,
3674 the policy should be prepared for both 'vp' and 'vlabel' to be NULL.
3676 @return Return 0 if access is granted, otherwise an appropriate value for
3677 errno should be returned.
3679 typedef int mpo_system_check_acct_t(
3682 struct label
*vlabel
3685 @brief Access control check for audit
3686 @param cred Subject credential
3687 @param record Audit record
3688 @param length Audit record length
3690 Determine whether the subject identified by the credential can submit
3691 an audit record for inclusion in the audit log via the audit() system call.
3693 @return Return 0 if access is granted, otherwise an appropriate value for
3694 errno should be returned.
3696 typedef int mpo_system_check_audit_t(
3702 @brief Access control check for controlling audit
3703 @param cred Subject credential
3704 @param vp Audit file
3705 @param vl Label associated with vp
3707 Determine whether the subject should be allowed to enable auditing using
3708 the auditctl() system call, based on its label and the label of the proposed
3711 @return Return 0 if access is granted, otherwise an appropriate value for
3712 errno should be returned.
3714 typedef int mpo_system_check_auditctl_t(
3720 @brief Access control check for manipulating auditing
3721 @param cred Subject credential
3722 @param cmd Audit control command
3724 Determine whether the subject identified by the credential can perform
3725 the audit subsystem control operation cmd via the auditon() system call.
3727 @return Return 0 if access is granted, otherwise an appropriate value for
3728 errno should be returned.
3730 typedef int mpo_system_check_auditon_t(
3735 @brief Access control check for using CHUD facilities
3736 @param cred Subject credential
3738 Determine whether the subject identified by the credential can perform
3739 performance-related tasks using the CHUD system call.
3741 @return Return 0 if access is granted, otherwise an appropriate value for
3742 errno should be returned.
3744 typedef int mpo_system_check_chud_t(
3748 @brief Access control check for obtaining the host control port
3749 @param cred Subject credential
3751 Determine whether the subject identified by the credential can
3752 obtain the host control port.
3754 @return Return 0 if access is granted, or non-zero otherwise.
3756 typedef int mpo_system_check_host_priv_t(
3760 @brief Access control check for obtaining system information
3761 @param cred Subject credential
3762 @param info_type A description of the information requested
3764 Determine whether the subject identified by the credential should be
3765 allowed to obtain information about the system.
3767 This is a generic hook that can be used in a variety of situations where
3768 information is being returned that might be considered sensitive.
3769 Rather than adding a new MAC hook for every such interface, this hook can
3770 be called with a string identifying the type of information requested.
3772 @return Return 0 if access is granted, otherwise an appropriate value for
3773 errno should be returned.
3775 typedef int mpo_system_check_info_t(
3777 const char *info_type
3780 @brief Access control check for calling NFS services
3781 @param cred Subject credential
3783 Determine whether the subject identified by the credential should be
3784 allowed to call nfssrv(2).
3786 @return Return 0 if access is granted, otherwise an appropriate value for
3787 errno should be returned.
3789 typedef int mpo_system_check_nfsd_t(
3793 @brief Access control check for reboot
3794 @param cred Subject credential
3795 @param howto howto parameter from reboot(2)
3797 Determine whether the subject identified by the credential should be
3798 allowed to reboot the system in the specified manner.
3800 @return Return 0 if access is granted, otherwise an appropriate value for
3801 errno should be returned.
3803 typedef int mpo_system_check_reboot_t(
3808 @brief Access control check for setting system clock
3809 @param cred Subject credential
3811 Determine whether the subject identified by the credential should be
3812 allowed to set the system clock.
3814 @return Return 0 if access is granted, otherwise an appropriate value for
3815 errno should be returned.
3817 typedef int mpo_system_check_settime_t(
3821 @brief Access control check for removing swap devices
3822 @param cred Subject credential
3823 @param vp Swap device
3824 @param label Label associated with vp
3826 Determine whether the subject identified by the credential should be
3827 allowed to remove vp as a swap device.
3829 @return Return 0 if access is granted, otherwise an appropriate value for
3830 errno should be returned.
3832 typedef int mpo_system_check_swapoff_t(
3838 @brief Access control check for adding swap devices
3839 @param cred Subject credential
3840 @param vp Swap device
3841 @param label Label associated with vp
3843 Determine whether the subject identified by the credential should be
3844 allowed to add vp as a swap device.
3846 @return Return 0 if access is granted, otherwise an appropriate value for
3847 errno should be returned.
3849 typedef int mpo_system_check_swapon_t(
3855 @brief Access control check for sysctl
3856 @param cred Subject credential
3857 @param namestring String representation of sysctl name.
3858 @param name Integer name; see sysctl(3)
3859 @param namelen Length of name array of integers; see sysctl(3)
3860 @param old 0 or address where to store old value; see sysctl(3)
3861 @param oldlen Length of old buffer; see sysctl(3)
3862 @param newvalue 0 or address of new value; see sysctl(3)
3863 @param newlen Length of new buffer; see sysctl(3)
3865 Determine whether the subject identified by the credential should be
3866 allowed to make the specified sysctl(3) transaction.
3868 The sysctl(3) call specifies that if the old value is not desired,
3869 oldp and oldlenp should be set to NULL. Likewise, if a new value is
3870 not to be set, newp should be set to NULL and newlen set to 0.
3872 @return Return 0 if access is granted, otherwise an appropriate value for
3873 errno should be returned.
3875 typedef int mpo_system_check_sysctlbyname_t(
3877 const char *namestring
,
3880 user_addr_t old
, /* NULLOK */
3882 user_addr_t newvalue
, /* NULLOK */
3886 @brief Access control check for kas_info
3887 @param cred Subject credential
3888 @param selector Category of information to return. See kas_info.h
3890 Determine whether the subject identified by the credential can perform
3891 introspection of the kernel address space layout for
3892 debugging/performance analysis.
3894 @return Return 0 if access is granted, otherwise an appropriate value for
3895 errno should be returned.
3897 typedef int mpo_system_check_kas_info_t(
3902 @brief Create a System V message label
3903 @param cred Subject credential
3904 @param msqptr The message queue the message will be placed in
3905 @param msqlabel The label of the message queue
3906 @param msgptr The message
3907 @param msglabel The label of the message
3909 Label the message as its placed in the message queue.
3911 typedef void mpo_sysvmsg_label_associate_t(
3913 struct msqid_kernel
*msqptr
,
3914 struct label
*msqlabel
,
3916 struct label
*msglabel
3919 @brief Destroy System V message label
3920 @param label The label to be destroyed
3922 Destroy a System V message label. Since the object is
3923 going out of scope, policy modules should free any internal storage
3924 associated with the label so that it may be destroyed.
3926 typedef void mpo_sysvmsg_label_destroy_t(
3930 @brief Initialize System V message label
3931 @param label New label to initialize
3933 Initialize the label for a newly instantiated System V message.
3935 typedef void mpo_sysvmsg_label_init_t(
3939 @brief Clean up a System V message label
3940 @param label The label to be destroyed
3942 Clean up a System V message label. Darwin pre-allocates
3943 messages at system boot time and re-uses them rather than
3944 allocating new ones. Before messages are returned to the "free
3945 pool", policies can cleanup or overwrite any information present in
3948 typedef void mpo_sysvmsg_label_recycle_t(
3952 @brief Access control check for System V message enqueuing
3953 @param cred Subject credential
3954 @param msgptr The message
3955 @param msglabel The message's label
3956 @param msqptr The message queue
3957 @param msqlabel The message queue's label
3959 Determine whether the subject identified by the credential can add the
3960 given message to the given message queue.
3962 @return Return 0 if access is granted, otherwise an appropriate value for
3963 errno should be returned.
3965 typedef int mpo_sysvmsq_check_enqueue_t(
3968 struct label
*msglabel
,
3969 struct msqid_kernel
*msqptr
,
3970 struct label
*msqlabel
3973 @brief Access control check for System V message reception
3974 @param cred The credential of the intended recipient
3975 @param msgptr The message
3976 @param msglabel The message's label
3978 Determine whether the subject identified by the credential can receive
3981 @return Return 0 if access is granted, otherwise an appropriate value for
3982 errno should be returned.
3984 typedef int mpo_sysvmsq_check_msgrcv_t(
3987 struct label
*msglabel
3990 @brief Access control check for System V message queue removal
3991 @param cred The credential of the caller
3992 @param msgptr The message
3993 @param msglabel The message's label
3995 System V message queues are removed using the msgctl() system call.
3996 The system will iterate over each messsage in the queue, calling this
3997 function for each, to determine whether the caller has the appropriate
4000 @return Return 0 if access is granted, otherwise an appropriate value for
4001 errno should be returned.
4003 typedef int mpo_sysvmsq_check_msgrmid_t(
4006 struct label
*msglabel
4009 @brief Access control check for msgctl()
4010 @param cred The credential of the caller
4011 @param msqptr The message queue
4012 @param msqlabel The message queue's label
4014 This access check is performed to validate calls to msgctl().
4016 @return Return 0 if access is granted, otherwise an appropriate value for
4017 errno should be returned.
4019 typedef int mpo_sysvmsq_check_msqctl_t(
4021 struct msqid_kernel
*msqptr
,
4022 struct label
*msqlabel
,
4026 @brief Access control check to get a System V message queue
4027 @param cred The credential of the caller
4028 @param msqptr The message queue requested
4029 @param msqlabel The message queue's label
4031 On a call to msgget(), if the queue requested already exists,
4032 and it is a public queue, this check will be performed before the
4033 queue's ID is returned to the user.
4035 @return Return 0 if access is granted, otherwise an appropriate value for
4036 errno should be returned.
4038 typedef int mpo_sysvmsq_check_msqget_t(
4040 struct msqid_kernel
*msqptr
,
4041 struct label
*msqlabel
4044 @brief Access control check to receive a System V message from the given queue
4045 @param cred The credential of the caller
4046 @param msqptr The message queue to receive from
4047 @param msqlabel The message queue's label
4049 On a call to msgrcv(), this check is performed to determine whether the
4050 caller has receive rights on the given queue.
4052 @return Return 0 if access is granted, otherwise an appropriate value for
4053 errno should be returned.
4055 typedef int mpo_sysvmsq_check_msqrcv_t(
4057 struct msqid_kernel
*msqptr
,
4058 struct label
*msqlabel
4061 @brief Access control check to send a System V message to the given queue
4062 @param cred The credential of the caller
4063 @param msqptr The message queue to send to
4064 @param msqlabel The message queue's label
4066 On a call to msgsnd(), this check is performed to determine whether the
4067 caller has send rights on the given queue.
4069 @return Return 0 if access is granted, otherwise an appropriate value for
4070 errno should be returned.
4072 typedef int mpo_sysvmsq_check_msqsnd_t(
4074 struct msqid_kernel
*msqptr
,
4075 struct label
*msqlabel
4078 @brief Create a System V message queue label
4079 @param cred Subject credential
4080 @param msqptr The message queue
4081 @param msqlabel The label of the message queue
4084 typedef void mpo_sysvmsq_label_associate_t(
4086 struct msqid_kernel
*msqptr
,
4087 struct label
*msqlabel
4090 @brief Destroy System V message queue label
4091 @param label The label to be destroyed
4093 Destroy a System V message queue label. Since the object is
4094 going out of scope, policy modules should free any internal storage
4095 associated with the label so that it may be destroyed.
4097 typedef void mpo_sysvmsq_label_destroy_t(
4101 @brief Initialize System V message queue label
4102 @param label New label to initialize
4104 Initialize the label for a newly instantiated System V message queue.
4106 typedef void mpo_sysvmsq_label_init_t(
4110 @brief Clean up a System V message queue label
4111 @param label The label to be destroyed
4113 Clean up a System V message queue label. Darwin pre-allocates
4114 message queues at system boot time and re-uses them rather than
4115 allocating new ones. Before message queues are returned to the "free
4116 pool", policies can cleanup or overwrite any information present in
4119 typedef void mpo_sysvmsq_label_recycle_t(
4123 @brief Access control check for System V semaphore control operation
4124 @param cred Subject credential
4125 @param semakptr Pointer to semaphore identifier
4126 @param semaklabel Label associated with semaphore
4127 @param cmd Control operation to be performed; see semctl(2)
4129 Determine whether the subject identified by the credential can perform
4130 the operation indicated by cmd on the System V semaphore semakptr.
4132 @return Return 0 if access is granted, otherwise an appropriate value for
4133 errno should be returned.
4135 typedef int mpo_sysvsem_check_semctl_t(
4137 struct semid_kernel
*semakptr
,
4138 struct label
*semaklabel
,
4142 @brief Access control check for obtaining a System V semaphore
4143 @param cred Subject credential
4144 @param semakptr Pointer to semaphore identifier
4145 @param semaklabel Label to associate with the semaphore
4147 Determine whether the subject identified by the credential can
4148 obtain a System V semaphore.
4150 @return Return 0 if access is granted, otherwise an appropriate value for
4151 errno should be returned.
4153 typedef int mpo_sysvsem_check_semget_t(
4155 struct semid_kernel
*semakptr
,
4156 struct label
*semaklabel
4159 @brief Access control check for System V semaphore operations
4160 @param cred Subject credential
4161 @param semakptr Pointer to semaphore identifier
4162 @param semaklabel Label associated with the semaphore
4163 @param accesstype Flags to indicate access (read and/or write)
4165 Determine whether the subject identified by the credential can
4166 perform the operations on the System V semaphore indicated by
4167 semakptr. The accesstype flags hold the maximum set of permissions
4168 from the sem_op array passed to the semop system call. It may
4169 contain SEM_R for read-only operations or SEM_A for read/write
4172 @return Return 0 if access is granted, otherwise an appropriate value for
4173 errno should be returned.
4175 typedef int mpo_sysvsem_check_semop_t(
4177 struct semid_kernel
*semakptr
,
4178 struct label
*semaklabel
,
4182 @brief Create a System V semaphore label
4183 @param cred Subject credential
4184 @param semakptr The semaphore being created
4185 @param semalabel Label to associate with the new semaphore
4187 Label a new System V semaphore. The label was previously
4188 initialized and associated with the semaphore. At this time, an
4189 appropriate initial label value should be assigned to the object and
4190 stored in semalabel.
4192 typedef void mpo_sysvsem_label_associate_t(
4194 struct semid_kernel
*semakptr
,
4195 struct label
*semalabel
4198 @brief Destroy System V semaphore label
4199 @param label The label to be destroyed
4201 Destroy a System V semaphore label. Since the object is
4202 going out of scope, policy modules should free any internal storage
4203 associated with the label so that it may be destroyed.
4205 typedef void mpo_sysvsem_label_destroy_t(
4209 @brief Initialize System V semaphore label
4210 @param label New label to initialize
4212 Initialize the label for a newly instantiated System V semaphore. Sleeping
4215 typedef void mpo_sysvsem_label_init_t(
4219 @brief Clean up a System V semaphore label
4220 @param label The label to be cleaned
4222 Clean up a System V semaphore label. Darwin pre-allocates
4223 semaphores at system boot time and re-uses them rather than
4224 allocating new ones. Before semaphores are returned to the "free
4225 pool", policies can cleanup or overwrite any information present in
4228 typedef void mpo_sysvsem_label_recycle_t(
4232 @brief Access control check for mapping System V shared memory
4233 @param cred Subject credential
4234 @param shmsegptr Pointer to shared memory segment identifier
4235 @param shmseglabel Label associated with the shared memory segment
4236 @param shmflg shmat flags; see shmat(2)
4238 Determine whether the subject identified by the credential can map
4239 the System V shared memory segment associated with shmsegptr.
4241 @return Return 0 if access is granted, otherwise an appropriate value for
4242 errno should be returned.
4244 typedef int mpo_sysvshm_check_shmat_t(
4246 struct shmid_kernel
*shmsegptr
,
4247 struct label
*shmseglabel
,
4251 @brief Access control check for System V shared memory control operation
4252 @param cred Subject credential
4253 @param shmsegptr Pointer to shared memory segment identifier
4254 @param shmseglabel Label associated with the shared memory segment
4255 @param cmd Control operation to be performed; see shmctl(2)
4257 Determine whether the subject identified by the credential can perform
4258 the operation indicated by cmd on the System V shared memory segment
4261 @return Return 0 if access is granted, otherwise an appropriate value for
4262 errno should be returned.
4264 typedef int mpo_sysvshm_check_shmctl_t(
4266 struct shmid_kernel
*shmsegptr
,
4267 struct label
*shmseglabel
,
4271 @brief Access control check for unmapping System V shared memory
4272 @param cred Subject credential
4273 @param shmsegptr Pointer to shared memory segment identifier
4274 @param shmseglabel Label associated with the shared memory segment
4276 Determine whether the subject identified by the credential can unmap
4277 the System V shared memory segment associated with shmsegptr.
4279 @return Return 0 if access is granted, otherwise an appropriate value for
4280 errno should be returned.
4282 typedef int mpo_sysvshm_check_shmdt_t(
4284 struct shmid_kernel
*shmsegptr
,
4285 struct label
*shmseglabel
4288 @brief Access control check obtaining System V shared memory identifier
4289 @param cred Subject credential
4290 @param shmsegptr Pointer to shared memory segment identifier
4291 @param shmseglabel Label associated with the shared memory segment
4292 @param shmflg shmget flags; see shmget(2)
4294 Determine whether the subject identified by the credential can get
4295 the System V shared memory segment address.
4297 @return Return 0 if access is granted, otherwise an appropriate value for
4298 errno should be returned.
4300 typedef int mpo_sysvshm_check_shmget_t(
4302 struct shmid_kernel
*shmsegptr
,
4303 struct label
*shmseglabel
,
4307 @brief Create a System V shared memory region label
4308 @param cred Subject credential
4309 @param shmsegptr The shared memory region being created
4310 @param shmlabel Label to associate with the new shared memory region
4312 Label a new System V shared memory region. The label was previously
4313 initialized and associated with the shared memory region. At this
4314 time, an appropriate initial label value should be assigned to the
4315 object and stored in shmlabel.
4317 typedef void mpo_sysvshm_label_associate_t(
4319 struct shmid_kernel
*shmsegptr
,
4320 struct label
*shmlabel
4323 @brief Destroy System V shared memory label
4324 @param label The label to be destroyed
4326 Destroy a System V shared memory region label. Since the
4327 object is going out of scope, policy modules should free any
4328 internal storage associated with the label so that it may be
4331 typedef void mpo_sysvshm_label_destroy_t(
4335 @brief Initialize System V Shared Memory region label
4336 @param label New label to initialize
4338 Initialize the label for a newly instantiated System V Shared Memory
4339 region. Sleeping is permitted.
4341 typedef void mpo_sysvshm_label_init_t(
4345 @brief Clean up a System V Share Memory Region label
4346 @param shmlabel The label to be cleaned
4348 Clean up a System V Shared Memory Region label. Darwin
4349 pre-allocates these objects at system boot time and re-uses them
4350 rather than allocating new ones. Before the memory regions are
4351 returned to the "free pool", policies can cleanup or overwrite any
4352 information present in the label.
4354 typedef void mpo_sysvshm_label_recycle_t(
4355 struct label
*shmlabel
4358 @brief Access control check for getting a process's task name
4359 @param cred Subject credential
4360 @param p Object process
4362 Determine whether the subject identified by the credential can get
4363 the passed process's task name port.
4364 This call is used by the task_name_for_pid(2) API.
4366 @return Return 0 if access is granted, otherwise an appropriate value for
4367 errno should be returned. Suggested failure: EACCES for label mismatch,
4368 EPERM for lack of privilege, or ESRCH to hide visibility of the target.
4370 typedef int mpo_proc_check_get_task_name_t(
4375 @brief Access control check for getting a process's task port
4376 @param cred Subject credential
4377 @param p Object process
4379 Determine whether the subject identified by the credential can get
4380 the passed process's task control port.
4381 This call is used by the task_for_pid(2) API.
4383 @return Return 0 if access is granted, otherwise an appropriate value for
4384 errno should be returned. Suggested failure: EACCES for label mismatch,
4385 EPERM for lack of privilege, or ESRCH to hide visibility of the target.
4387 typedef int mpo_proc_check_get_task_t(
4393 @brief Access control check for exposing a process's task port
4394 @param cred Subject credential
4395 @param p Object process
4397 Determine whether the subject identified by the credential can expose
4398 the passed process's task control port.
4399 This call is used by the accessor APIs like processor_set_tasks() and
4400 processor_set_threads().
4402 @return Return 0 if access is granted, otherwise an appropriate value for
4403 errno should be returned. Suggested failure: EACCES for label mismatch,
4404 EPERM for lack of privilege, or ESRCH to hide visibility of the target.
4406 typedef int mpo_proc_check_expose_task_t(
4412 @brief Check whether task's IPC may inherit across process exec
4413 @param p current process instance
4414 @param cur_vp vnode pointer to current instance
4415 @param cur_offset offset of binary of currently executing image
4416 @param img_vp vnode pointer to to be exec'ed image
4417 @param img_offset offset into file which is selected for execution
4418 @param scriptvp vnode pointer of script file if any.
4419 @return Return 0 if access is granted.
4420 EPERM if parent does not have any entitlements.
4421 EACCESS if mismatch in entitlements
4423 typedef int mpo_proc_check_inherit_ipc_ports_t(
4425 struct vnode
*cur_vp
,
4427 struct vnode
*img_vp
,
4429 struct vnode
*scriptvp
4433 @brief Privilege check for a process to run invalid
4434 @param p Object process
4436 Determine whether the process may execute even though the system determined
4437 that it is untrusted (eg unidentified / modified code).
4439 @return Return 0 if access is granted, otherwise an appropriate value for
4440 errno should be returned.
4442 typedef int mpo_proc_check_run_cs_invalid_t(
4447 @brief Perform MAC-related events when a thread returns to user space
4448 @param thread Mach (not BSD) thread that is returning
4450 This entry point permits policy modules to perform MAC-related
4451 events when a thread returns to user space, via a system call
4452 return or trap return.
4454 typedef void mpo_thread_userret_t(
4455 struct thread
*thread
4459 @brief Check vnode access
4460 @param cred Subject credential
4461 @param vp Object vnode
4462 @param label Label for vp
4463 @param acc_mode access(2) flags
4465 Determine how invocations of access(2) and related calls by the
4466 subject identified by the credential should return when performed
4467 on the passed vnode using the passed access flags. This should
4468 generally be implemented using the same semantics used in
4469 mpo_vnode_check_open.
4471 @return Return 0 if access is granted, otherwise an appropriate value for
4472 errno should be returned. Suggested failure: EACCES for label mismatch or
4473 EPERM for lack of privilege.
4475 typedef int mpo_vnode_check_access_t(
4478 struct label
*label
,
4482 @brief Access control check for changing working directory
4483 @param cred Subject credential
4484 @param dvp Object; vnode to chdir(2) into
4485 @param dlabel Policy label for dvp
4487 Determine whether the subject identified by the credential can change
4488 the process working directory to the passed vnode.
4490 @return Return 0 if access is granted, otherwise an appropriate value for
4491 errno should be returned. Suggested failure: EACCES for label mismatch or
4492 EPERM for lack of privilege.
4494 typedef int mpo_vnode_check_chdir_t(
4497 struct label
*dlabel
4500 @brief Access control check for changing root directory
4501 @param cred Subject credential
4502 @param dvp Directory vnode
4503 @param dlabel Policy label associated with dvp
4504 @param cnp Component name for dvp
4506 Determine whether the subject identified by the credential should be
4507 allowed to chroot(2) into the specified directory (dvp).
4509 @return In the event of an error, an appropriate value for errno
4510 should be returned, otherwise return 0 upon success.
4512 typedef int mpo_vnode_check_chroot_t(
4515 struct label
*dlabel
,
4516 struct componentname
*cnp
4519 @brief Access control check for creating clone
4520 @param cred Subject credential
4521 @param dvp Vnode of directory to create the clone in
4522 @param dlabel Policy label associated with dvp
4523 @param vp Vnode of the file to clone from
4524 @param label Policy label associated with vp
4525 @param cnp Component name for the clone being created
4527 Determine whether the subject identified by the credential should be
4528 allowed to create a clone of the vnode vp with the name specified by cnp.
4530 @return Return 0 if access is granted, otherwise an appropriate value for
4531 errno should be returned.
4533 typedef int mpo_vnode_check_clone_t(
4536 struct label
*dlabel
,
4538 struct label
*label
,
4539 struct componentname
*cnp
4542 @brief Access control check for creating vnode
4543 @param cred Subject credential
4544 @param dvp Directory vnode
4545 @param dlabel Policy label for dvp
4546 @param cnp Component name for dvp
4547 @param vap vnode attributes for vap
4549 Determine whether the subject identified by the credential can create
4550 a vnode with the passed parent directory, passed name information,
4551 and passed attribute information. This call may be made in a number of
4552 situations, including as a result of calls to open(2) with O_CREAT,
4553 mknod(2), mkfifo(2), and others.
4555 @return Return 0 if access is granted, otherwise an appropriate value for
4556 errno should be returned. Suggested failure: EACCES for label mismatch or
4557 EPERM for lack of privilege.
4559 typedef int mpo_vnode_check_create_t(
4562 struct label
*dlabel
,
4563 struct componentname
*cnp
,
4564 struct vnode_attr
*vap
4567 @brief Access control check for deleting extended attribute
4568 @param cred Subject credential
4569 @param vp Object vnode
4570 @param vlabel Label associated with vp
4571 @param name Extended attribute name
4573 Determine whether the subject identified by the credential can delete
4574 the extended attribute from the passed vnode.
4576 @return Return 0 if access is granted, otherwise an appropriate value for
4577 errno should be returned. Suggested failure: EACCES for label mismatch or
4578 EPERM for lack of privilege.
4580 typedef int mpo_vnode_check_deleteextattr_t(
4583 struct label
*vlabel
,
4587 @brief Access control check for exchanging file data
4588 @param cred Subject credential
4589 @param v1 vnode 1 to swap
4590 @param vl1 Policy label for v1
4591 @param v2 vnode 2 to swap
4592 @param vl2 Policy label for v2
4594 Determine whether the subject identified by the credential can swap the data
4595 in the two supplied vnodes.
4597 @return Return 0 if access is granted, otherwise an appropriate value for
4598 errno should be returned. Suggested failure: EACCES for label mismatch or
4599 EPERM for lack of privilege.
4601 typedef int mpo_vnode_check_exchangedata_t(
4609 @brief Access control check for executing the vnode
4610 @param cred Subject credential
4611 @param vp Object vnode to execute
4612 @param scriptvp Script being executed by interpreter, if any.
4613 @param vnodelabel Label corresponding to vp
4614 @param scriptlabel Script vnode label
4615 @param execlabel Userspace provided execution label
4616 @param cnp Component name for file being executed
4617 @param macpolicyattr MAC policy-specific spawn attribute data.
4618 @param macpolicyattrlen Length of policy-specific spawn attribute data.
4620 Determine whether the subject identified by the credential can execute
4621 the passed vnode. Determination of execute privilege is made separately
4622 from decisions about any process label transitioning event.
4624 The final label, execlabel, corresponds to a label supplied by a
4625 user space application through the use of the mac_execve system call.
4626 This label will be NULL if the user application uses the the vendor
4627 execve(2) call instead of the MAC Framework mac_execve() call.
4629 @return Return 0 if access is granted, otherwise an appropriate value for
4630 errno should be returned. Suggested failure: EACCES for label mismatch or
4631 EPERM for lack of privilege.
4633 typedef int mpo_vnode_check_exec_t(
4636 struct vnode
*scriptvp
,
4637 struct label
*vnodelabel
,
4638 struct label
*scriptlabel
,
4639 struct label
*execlabel
, /* NULLOK */
4640 struct componentname
*cnp
,
4642 void *macpolicyattr
,
4643 size_t macpolicyattrlen
4646 @brief Access control check for fsgetpath
4647 @param cred Subject credential
4648 @param vp Vnode for which a path will be returned
4649 @param label Label associated with the vnode
4651 Determine whether the subject identified by the credential can get the path
4652 of the given vnode with fsgetpath.
4654 @return Return 0 if access is granted, otherwise an appropriate value for
4655 errno should be returned.
4657 typedef int mpo_vnode_check_fsgetpath_t(
4663 @brief Access control check after determining the code directory hash
4664 @param vp vnode vnode to combine into proc
4665 @param label label associated with the vnode
4666 @param cs_blob the code signature to check
4667 @param cs_flags update code signing flags if needed
4668 @param flags operational flag to mpo_vnode_check_signature
4669 @param fatal_failure_desc description of fatal failure
4670 @param fatal_failure_desc_len failure description len, failure is fatal if non-0
4672 @return Return 0 if access is granted, otherwise an appropriate value for
4673 errno should be returned.
4675 typedef int mpo_vnode_check_signature_t(
4677 struct label
*label
,
4678 struct cs_blob
*cs_blob
,
4679 unsigned int *cs_flags
,
4681 char **fatal_failure_desc
, size_t *fatal_failure_desc_len
);
4683 @brief Access control check for retrieving file attributes
4684 @param cred Subject credential
4685 @param vp Object vnode
4686 @param vlabel Policy label for vp
4687 @param alist List of attributes to retrieve
4689 Determine whether the subject identified by the credential can read
4690 various attributes of the specified vnode, or the filesystem or volume on
4691 which that vnode resides. See <sys/attr.h> for definitions of the
4694 @return Return 0 if access is granted, otherwise an appropriate value for
4695 errno should be returned. Suggested failure: EACCES for label mismatch or
4696 EPERM for lack of privilege. Access control covers all attributes requested
4697 with this call; the security policy is not permitted to change the set of
4698 attributes requested.
4700 typedef int mpo_vnode_check_getattrlist_t(
4703 struct label
*vlabel
,
4704 struct attrlist
*alist
4707 @brief Access control check for retrieving an extended attribute
4708 @param cred Subject credential
4709 @param vp Object vnode
4710 @param label Policy label for vp
4711 @param name Extended attribute name
4712 @param uio I/O structure pointer
4714 Determine whether the subject identified by the credential can retrieve
4715 the extended attribute from the passed vnode. The uio parameter
4716 will be NULL when the getxattr(2) call has been made with a NULL data
4717 value; this is done to request the size of the data only.
4719 @return Return 0 if access is granted, otherwise an appropriate value for
4720 errno should be returned. Suggested failure: EACCES for label mismatch or
4721 EPERM for lack of privilege.
4723 typedef int mpo_vnode_check_getextattr_t(
4726 struct label
*label
, /* NULLOK */
4728 struct uio
*uio
/* NULLOK */
4731 @brief Access control check for ioctl
4732 @param cred Subject credential
4733 @param vp Object vnode
4734 @param label Policy label for vp
4735 @param cmd Device-dependent request code; see ioctl(2)
4737 Determine whether the subject identified by the credential can perform
4738 the ioctl operation indicated by com.
4740 @warning Since ioctl data is opaque from the standpoint of the MAC
4741 framework, and since ioctls can affect many aspects of system
4742 operation, policies must exercise extreme care when implementing
4743 access control checks.
4745 @return Return 0 if access is granted, otherwise an appropriate value for
4746 errno should be returned.
4748 typedef int mpo_vnode_check_ioctl_t(
4751 struct label
*label
,
4755 @brief Access control check for vnode kqfilter
4756 @param active_cred Subject credential
4757 @param kn Object knote
4758 @param vp Object vnode
4759 @param label Policy label for vp
4761 Determine whether the subject identified by the credential can
4762 receive the knote on the passed vnode.
4764 @return Return 0 if access if granted, otherwise an appropriate
4765 value for errno should be returned.
4767 typedef int mpo_vnode_check_kqfilter_t(
4768 kauth_cred_t active_cred
,
4769 kauth_cred_t file_cred
, /* NULLOK */
4775 @brief Access control check for relabel
4776 @param cred Subject credential
4777 @param vp Object vnode
4778 @param vnodelabel Existing policy label for vp
4779 @param newlabel Policy label update to later be applied to vp
4780 @see mpo_relable_vnode_t
4782 Determine whether the subject identified by the credential can relabel
4783 the passed vnode to the passed label update. If all policies permit
4784 the label change, the actual relabel entry point (mpo_vnode_label_update)
4787 @return Return 0 if access is granted, otherwise an appropriate value for
4788 errno should be returned.
4790 typedef int mpo_vnode_check_label_update_t(
4793 struct label
*vnodelabel
,
4794 struct label
*newlabel
4797 @brief Access control check for creating link
4798 @param cred Subject credential
4799 @param dvp Directory vnode
4800 @param dlabel Policy label associated with dvp
4801 @param vp Link destination vnode
4802 @param label Policy label associated with vp
4803 @param cnp Component name for the link being created
4805 Determine whether the subject identified by the credential should be
4806 allowed to create a link to the vnode vp with the name specified by cnp.
4808 @return Return 0 if access is granted, otherwise an appropriate value for
4809 errno should be returned.
4811 typedef int mpo_vnode_check_link_t(
4814 struct label
*dlabel
,
4816 struct label
*label
,
4817 struct componentname
*cnp
4820 @brief Access control check for listing extended attributes
4821 @param cred Subject credential
4822 @param vp Object vnode
4823 @param vlabel Policy label associated with vp
4825 Determine whether the subject identified by the credential can retrieve
4826 a list of named extended attributes from a vnode.
4828 @return Return 0 if access is granted, otherwise an appropriate value for
4829 errno should be returned.
4831 typedef int mpo_vnode_check_listextattr_t(
4834 struct label
*vlabel
4837 @brief Access control check for lookup
4838 @param cred Subject credential
4839 @param dvp Object vnode
4840 @param dlabel Policy label for dvp
4841 @param cnp Component name being looked up
4843 Determine whether the subject identified by the credential can perform
4844 a lookup in the passed directory vnode for the passed name (cnp).
4846 @return Return 0 if access is granted, otherwise an appropriate value for
4847 errno should be returned. Suggested failure: EACCES for label mismatch or
4848 EPERM for lack of privilege.
4850 typedef int mpo_vnode_check_lookup_t(
4853 struct label
*dlabel
,
4854 struct componentname
*cnp
4857 @brief Access control check for open
4858 @param cred Subject credential
4859 @param vp Object vnode
4860 @param label Policy label associated with vp
4861 @param acc_mode open(2) access mode
4863 Determine whether the subject identified by the credential can perform
4864 an open operation on the passed vnode with the passed access mode.
4866 @return Return 0 if access is granted, otherwise an appropriate value for
4867 errno should be returned. Suggested failure: EACCES for label mismatch or
4868 EPERM for lack of privilege.
4870 typedef int mpo_vnode_check_open_t(
4873 struct label
*label
,
4877 @brief Access control check for read
4878 @param active_cred Subject credential
4879 @param file_cred Credential associated with the struct fileproc
4880 @param vp Object vnode
4881 @param label Policy label for vp
4883 Determine whether the subject identified by the credential can perform
4884 a read operation on the passed vnode. The active_cred hold the credentials
4885 of the subject performing the operation, and file_cred holds the
4886 credentials of the subject that originally opened the file.
4888 @return Return 0 if access is granted, otherwise an appropriate value for
4889 errno should be returned. Suggested failure: EACCES for label mismatch or
4890 EPERM for lack of privilege.
4892 typedef int mpo_vnode_check_read_t(
4893 kauth_cred_t active_cred
, /* SUBJECT */
4894 kauth_cred_t file_cred
, /* NULLOK */
4895 struct vnode
*vp
, /* OBJECT */
4896 struct label
*label
/* LABEL */
4899 @brief Access control check for read directory
4900 @param cred Subject credential
4901 @param dvp Object directory vnode
4902 @param dlabel Policy label for dvp
4904 Determine whether the subject identified by the credential can
4905 perform a readdir operation on the passed directory vnode.
4907 @return Return 0 if access is granted, otherwise an appropriate value for
4908 errno should be returned. Suggested failure: EACCES for label mismatch or
4909 EPERM for lack of privilege.
4911 typedef int mpo_vnode_check_readdir_t(
4912 kauth_cred_t cred
, /* SUBJECT */
4913 struct vnode
*dvp
, /* OBJECT */
4914 struct label
*dlabel
/* LABEL */
4917 @brief Access control check for read link
4918 @param cred Subject credential
4919 @param vp Object vnode
4920 @param label Policy label for vp
4922 Determine whether the subject identified by the credential can perform
4923 a readlink operation on the passed symlink vnode. This call can be made
4924 in a number of situations, including an explicit readlink call by the
4925 user process, or as a result of an implicit readlink during a name
4926 lookup by the process.
4928 @return Return 0 if access is granted, otherwise an appropriate value for
4929 errno should be returned. Suggested failure: EACCES for label mismatch or
4930 EPERM for lack of privilege.
4932 typedef int mpo_vnode_check_readlink_t(
4938 @brief Access control check for rename
4939 @param cred Subject credential
4940 @param dvp Directory vnode
4941 @param dlabel Policy label associated with dvp
4942 @param vp vnode to be renamed
4943 @param label Policy label associated with vp
4944 @param cnp Component name for vp
4945 @param tdvp Destination directory vnode
4946 @param tdlabel Policy label associated with tdvp
4947 @param tvp Overwritten vnode
4948 @param tlabel Policy label associated with tvp
4949 @param tcnp Destination component name
4951 Determine whether the subject identified by the credential should be allowed
4952 to rename the vnode vp to something else.
4954 @return Return 0 if access is granted, otherwise an appropriate value for
4955 errno should be returned.
4957 typedef int mpo_vnode_check_rename_t(
4960 struct label
*dlabel
,
4962 struct label
*label
,
4963 struct componentname
*cnp
,
4965 struct label
*tdlabel
,
4967 struct label
*tlabel
,
4968 struct componentname
*tcnp
4971 @brief Access control check for rename from
4972 @param cred Subject credential
4973 @param dvp Directory vnode
4974 @param dlabel Policy label associated with dvp
4975 @param vp vnode to be renamed
4976 @param label Policy label associated with vp
4977 @param cnp Component name for vp
4978 @see mpo_vnode_check_rename_t
4979 @see mpo_vnode_check_rename_to_t
4981 Determine whether the subject identified by the credential should be
4982 allowed to rename the vnode vp to something else.
4984 Due to VFS locking constraints (to make sure proper vnode locks are
4985 held during this entry point), the vnode relabel checks had to be
4986 split into two parts: relabel_from and relabel to.
4988 This hook is deprecated, mpo_vnode_check_rename_t should be used instead.
4990 @return Return 0 if access is granted, otherwise an appropriate value for
4991 errno should be returned.
4993 typedef int mpo_vnode_check_rename_from_t(
4996 struct label
*dlabel
,
4998 struct label
*label
,
4999 struct componentname
*cnp
5002 @brief Access control check for rename to
5003 @param cred Subject credential
5004 @param dvp Directory vnode
5005 @param dlabel Policy label associated with dvp
5006 @param vp Overwritten vnode
5007 @param label Policy label associated with vp
5008 @param samedir Boolean; 1 if the source and destination directories are the same
5009 @param cnp Destination component name
5010 @see mpo_vnode_check_rename_t
5011 @see mpo_vnode_check_rename_from_t
5013 Determine whether the subject identified by the credential should be
5014 allowed to rename to the vnode vp, into the directory dvp, or to the
5015 name represented by cnp. If there is no existing file to overwrite,
5016 vp and label will be NULL.
5018 Due to VFS locking constraints (to make sure proper vnode locks are
5019 held during this entry point), the vnode relabel checks had to be
5020 split into two parts: relabel_from and relabel to.
5022 This hook is deprecated, mpo_vnode_check_rename_t should be used instead.
5024 @return Return 0 if access is granted, otherwise an appropriate value for
5025 errno should be returned.
5027 typedef int mpo_vnode_check_rename_to_t(
5030 struct label
*dlabel
,
5031 struct vnode
*vp
, /* NULLOK */
5032 struct label
*label
, /* NULLOK */
5034 struct componentname
*cnp
5037 @brief Access control check for revoke
5038 @param cred Subject credential
5039 @param vp Object vnode
5040 @param label Policy label for vp
5042 Determine whether the subject identified by the credential can revoke
5043 access to the passed vnode.
5045 @return Return 0 if access is granted, otherwise an appropriate value for
5046 errno should be returned. Suggested failure: EACCES for label mismatch or
5047 EPERM for lack of privilege.
5049 typedef int mpo_vnode_check_revoke_t(
5055 @brief Access control check for searchfs
5056 @param cred Subject credential
5057 @param vp Object vnode
5058 @param vlabel Policy label for vp
5059 @param alist List of attributes used as search criteria
5061 Determine whether the subject identified by the credential can search the
5062 vnode using the searchfs system call.
5064 @return Return 0 if access is granted, otherwise an appropriate value for
5065 errno should be returned.
5067 typedef int mpo_vnode_check_searchfs_t(
5070 struct label
*vlabel
,
5071 struct attrlist
*alist
5074 @brief Access control check for select
5075 @param cred Subject credential
5076 @param vp Object vnode
5077 @param label Policy label for vp
5078 @param which The operation selected on: FREAD or FWRITE
5080 Determine whether the subject identified by the credential can select
5083 @return Return 0 if access is granted, otherwise an appropriate value for
5084 errno should be returned.
5086 typedef int mpo_vnode_check_select_t(
5089 struct label
*label
,
5093 @brief Access control check for setting ACL
5094 @param cred Subject credential
5095 @param vp Object node
5096 @param label Policy label for vp
5097 @param acl ACL structure pointer
5099 Determine whether the subject identified by the credential can set an ACL
5100 on the specified vnode. The ACL pointer will be NULL when removing an ACL.
5102 @return Return 0 if access is granted, otherwise an appropriate value for
5103 errno should be returned. Suggested failure: EACCES for label mismatch or
5104 EPERM for lack of privilege.
5106 typedef int mpo_vnode_check_setacl_t(
5109 struct label
*label
,
5110 struct kauth_acl
*acl
5113 @brief Access control check for setting file attributes
5114 @param cred Subject credential
5115 @param vp Object vnode
5116 @param vlabel Policy label for vp
5117 @param alist List of attributes to set
5119 Determine whether the subject identified by the credential can set
5120 various attributes of the specified vnode, or the filesystem or volume on
5121 which that vnode resides. See <sys/attr.h> for definitions of the
5124 @return Return 0 if access is granted, otherwise an appropriate value for
5125 errno should be returned. Suggested failure: EACCES for label mismatch or
5126 EPERM for lack of privilege. Access control covers all attributes requested
5129 typedef int mpo_vnode_check_setattrlist_t(
5132 struct label
*vlabel
,
5133 struct attrlist
*alist
5136 @brief Access control check for setting extended attribute
5137 @param cred Subject credential
5138 @param vp Object vnode
5139 @param label Policy label for vp
5140 @param name Extended attribute name
5141 @param uio I/O structure pointer
5143 Determine whether the subject identified by the credential can set the
5144 extended attribute of passed name and passed namespace on the passed
5145 vnode. Policies implementing security labels backed into extended
5146 attributes may want to provide additional protections for those
5147 attributes. Additionally, policies should avoid making decisions based
5148 on the data referenced from uio, as there is a potential race condition
5149 between this check and the actual operation. The uio may also be NULL
5150 if a delete operation is being performed.
5152 @return Return 0 if access is granted, otherwise an appropriate value for
5153 errno should be returned. Suggested failure: EACCES for label mismatch or
5154 EPERM for lack of privilege.
5156 typedef int mpo_vnode_check_setextattr_t(
5159 struct label
*label
,
5164 @brief Access control check for setting flags
5165 @param cred Subject credential
5166 @param vp Object vnode
5167 @param label Policy label for vp
5168 @param flags File flags; see chflags(2)
5170 Determine whether the subject identified by the credential can set
5171 the passed flags on the passed vnode.
5173 @return Return 0 if access is granted, otherwise an appropriate value for
5174 errno should be returned. Suggested failure: EACCES for label mismatch or
5175 EPERM for lack of privilege.
5177 typedef int mpo_vnode_check_setflags_t(
5180 struct label
*label
,
5184 @brief Access control check for setting mode
5185 @param cred Subject credential
5186 @param vp Object vnode
5187 @param label Policy label for vp
5188 @param mode File mode; see chmod(2)
5190 Determine whether the subject identified by the credential can set
5191 the passed mode on the passed vnode.
5193 @return Return 0 if access is granted, otherwise an appropriate value for
5194 errno should be returned. Suggested failure: EACCES for label mismatch or
5195 EPERM for lack of privilege.
5197 typedef int mpo_vnode_check_setmode_t(
5200 struct label
*label
,
5204 @brief Access control check for setting uid and gid
5205 @param cred Subject credential
5206 @param vp Object vnode
5207 @param label Policy label for vp
5211 Determine whether the subject identified by the credential can set
5212 the passed uid and passed gid as file uid and file gid on the passed
5213 vnode. The IDs may be set to (-1) to request no update.
5215 @return Return 0 if access is granted, otherwise an appropriate value for
5216 errno should be returned. Suggested failure: EACCES for label mismatch or
5217 EPERM for lack of privilege.
5219 typedef int mpo_vnode_check_setowner_t(
5222 struct label
*label
,
5227 @brief Access control check for setting timestamps
5228 @param cred Subject credential
5229 @param vp Object vnode
5230 @param label Policy label for vp
5231 @param atime Access time; see utimes(2)
5232 @param mtime Modification time; see utimes(2)
5234 Determine whether the subject identified by the credential can set
5235 the passed access timestamps on the passed vnode.
5237 @return Return 0 if access is granted, otherwise an appropriate value for
5238 errno should be returned. Suggested failure: EACCES for label mismatch or
5239 EPERM for lack of privilege.
5241 typedef int mpo_vnode_check_setutimes_t(
5244 struct label
*label
,
5245 struct timespec atime
,
5246 struct timespec mtime
5249 @brief Access control check for stat
5250 @param active_cred Subject credential
5251 @param file_cred Credential associated with the struct fileproc
5252 @param vp Object vnode
5253 @param label Policy label for vp
5255 Determine whether the subject identified by the credential can stat
5256 the passed vnode. See stat(2) for more information. The active_cred
5257 hold the credentials of the subject performing the operation, and
5258 file_cred holds the credentials of the subject that originally
5261 @return Return 0 if access is granted, otherwise an appropriate value for
5262 errno should be returned. Suggested failure: EACCES for label mismatch or
5263 EPERM for lack of privilege.
5265 typedef int mpo_vnode_check_stat_t(
5266 struct ucred
*active_cred
,
5267 struct ucred
*file_cred
, /* NULLOK */
5272 @brief Access control check for truncate/ftruncate
5273 @param active_cred Subject credential
5274 @param file_cred Credential associated with the struct fileproc
5275 @param vp Object vnode
5276 @param label Policy label for vp
5278 Determine whether the subject identified by the credential can
5279 perform a truncate operation on the passed vnode. The active_cred hold
5280 the credentials of the subject performing the operation, and
5281 file_cred holds the credentials of the subject that originally
5284 @return Return 0 if access is granted, otherwise an appropriate value for
5285 errno should be returned. Suggested failure: EACCES for label mismatch or
5286 EPERM for lack of privilege.
5288 typedef int mpo_vnode_check_truncate_t(
5289 kauth_cred_t active_cred
,
5290 kauth_cred_t file_cred
, /* NULLOK */
5295 @brief Access control check for binding UNIX domain socket
5296 @param cred Subject credential
5297 @param dvp Directory vnode
5298 @param dlabel Policy label for dvp
5299 @param cnp Component name for dvp
5300 @param vap vnode attributes for vap
5302 Determine whether the subject identified by the credential can perform a
5303 bind operation on a UNIX domain socket with the passed parent directory,
5304 passed name information, and passed attribute information.
5306 @return Return 0 if access is granted, otherwise an appropriate value for
5307 errno should be returned. Suggested failure: EACCES for label mismatch or
5308 EPERM for lack of privilege.
5310 typedef int mpo_vnode_check_uipc_bind_t(
5313 struct label
*dlabel
,
5314 struct componentname
*cnp
,
5315 struct vnode_attr
*vap
5318 @brief Access control check for connecting UNIX domain socket
5319 @param cred Subject credential
5320 @param vp Object vnode
5321 @param label Policy label associated with vp
5324 Determine whether the subject identified by the credential can perform a
5325 connect operation on the passed UNIX domain socket vnode.
5327 @return Return 0 if access is granted, otherwise an appropriate value for
5328 errno should be returned. Suggested failure: EACCES for label mismatch or
5329 EPERM for lack of privilege.
5331 typedef int mpo_vnode_check_uipc_connect_t(
5334 struct label
*label
,
5338 @brief Access control check for deleting vnode
5339 @param cred Subject credential
5340 @param dvp Parent directory vnode
5341 @param dlabel Policy label for dvp
5342 @param vp Object vnode to delete
5343 @param label Policy label for vp
5344 @param cnp Component name for vp
5345 @see mpo_check_rename_to_t
5347 Determine whether the subject identified by the credential can delete
5348 a vnode from the passed parent directory and passed name information.
5349 This call may be made in a number of situations, including as a
5350 results of calls to unlink(2) and rmdir(2). Policies implementing
5351 this entry point should also implement mpo_check_rename_to to
5352 authorize deletion of objects as a result of being the target of a rename.
5354 @return Return 0 if access is granted, otherwise an appropriate value for
5355 errno should be returned. Suggested failure: EACCES for label mismatch or
5356 EPERM for lack of privilege.
5358 typedef int mpo_vnode_check_unlink_t(
5361 struct label
*dlabel
,
5363 struct label
*label
,
5364 struct componentname
*cnp
5367 @brief Access control check for write
5368 @param active_cred Subject credential
5369 @param file_cred Credential associated with the struct fileproc
5370 @param vp Object vnode
5371 @param label Policy label for vp
5373 Determine whether the subject identified by the credential can
5374 perform a write operation on the passed vnode. The active_cred hold
5375 the credentials of the subject performing the operation, and
5376 file_cred holds the credentials of the subject that originally
5379 @return Return 0 if access is granted, otherwise an appropriate value for
5380 errno should be returned. Suggested failure: EACCES for label mismatch or
5381 EPERM for lack of privilege.
5383 typedef int mpo_vnode_check_write_t(
5384 kauth_cred_t active_cred
,
5385 kauth_cred_t file_cred
, /* NULLOK */
5390 @brief Associate a vnode with a devfs entry
5391 @param mp Devfs mount point
5392 @param mntlabel Devfs mount point label
5393 @param de Devfs directory entry
5394 @param delabel Label associated with de
5395 @param vp vnode associated with de
5396 @param vlabel Label associated with vp
5398 Fill in the label (vlabel) for a newly created devfs vnode. The
5399 label is typically derived from the label on the devfs directory
5400 entry or the label on the filesystem, supplied as parameters.
5402 typedef void mpo_vnode_label_associate_devfs_t(
5404 struct label
*mntlabel
,
5406 struct label
*delabel
,
5408 struct label
*vlabel
5411 @brief Associate a label with a vnode
5412 @param mp File system mount point
5413 @param mntlabel File system mount point label
5414 @param vp Vnode to label
5415 @param vlabel Label associated with vp
5417 Attempt to retrieve label information for the vnode, vp, from the
5418 file system extended attribute store. The label should be stored in
5419 the supplied vlabel parameter. If a policy cannot retrieve an
5420 extended attribute, sometimes it is acceptible to fallback to using
5423 If the policy requires vnodes to have a valid label elsewhere it
5424 MUST NOT return other than temporary errors, and must always provide
5425 a valid label of some sort. Returning an error will cause vnode
5426 labeling to be retried at a later access. Failure to handle policy
5427 centric errors internally (corrupt labels etc.) will result in
5430 @return In the event of an error, an appropriate value for errno
5431 should be returned, otherwise return 0 upon success.
5433 typedef int mpo_vnode_label_associate_extattr_t(
5435 struct label
*mntlabel
,
5437 struct label
*vlabel
5440 @brief Associate a file label with a vnode
5441 @param cred User credential
5442 @param mp Fdesc mount point
5443 @param mntlabel Fdesc mount point label
5444 @param fg Fileglob structure
5445 @param label Policy label for fg
5446 @param vp Vnode to label
5447 @param vlabel Label associated with vp
5449 Associate label information for the vnode, vp, with the label of
5450 the open file descriptor described by fg.
5451 The label should be stored in the supplied vlabel parameter.
5453 typedef void mpo_vnode_label_associate_file_t(
5456 struct label
*mntlabel
,
5457 struct fileglob
*fg
,
5458 struct label
*label
,
5460 struct label
*vlabel
5463 @brief Associate a pipe label with a vnode
5464 @param cred User credential for the process that opened the pipe
5465 @param cpipe Pipe structure
5466 @param pipelabel Label associated with pipe
5467 @param vp Vnode to label
5468 @param vlabel Label associated with vp
5470 Associate label information for the vnode, vp, with the label of
5471 the pipe described by the pipe structure cpipe.
5472 The label should be stored in the supplied vlabel parameter.
5474 typedef void mpo_vnode_label_associate_pipe_t(
5477 struct label
*pipelabel
,
5479 struct label
*vlabel
5482 @brief Associate a POSIX semaphore label with a vnode
5483 @param cred User credential for the process that create psem
5484 @param psem POSIX semaphore structure
5485 @param psemlabel Label associated with psem
5486 @param vp Vnode to label
5487 @param vlabel Label associated with vp
5489 Associate label information for the vnode, vp, with the label of
5490 the POSIX semaphore described by psem.
5491 The label should be stored in the supplied vlabel parameter.
5493 typedef void mpo_vnode_label_associate_posixsem_t(
5495 struct pseminfo
*psem
,
5496 struct label
*psemlabel
,
5498 struct label
*vlabel
5501 @brief Associate a POSIX shared memory label with a vnode
5502 @param cred User credential for the process that created pshm
5503 @param pshm POSIX shared memory structure
5504 @param pshmlabel Label associated with pshm
5505 @param vp Vnode to label
5506 @param vlabel Label associated with vp
5508 Associate label information for the vnode, vp, with the label of
5509 the POSIX shared memory region described by pshm.
5510 The label should be stored in the supplied vlabel parameter.
5512 typedef void mpo_vnode_label_associate_posixshm_t(
5514 struct pshminfo
*pshm
,
5515 struct label
*pshmlabel
,
5517 struct label
*vlabel
5520 @brief Associate a label with a vnode
5521 @param mp File system mount point
5522 @param mntlabel File system mount point label
5523 @param vp Vnode to label
5524 @param vlabel Label associated with vp
5526 On non-multilabel file systems, set the label for a vnode. The
5527 label will most likely be based on the file system label.
5529 typedef void mpo_vnode_label_associate_singlelabel_t(
5531 struct label
*mntlabel
,
5533 struct label
*vlabel
5536 @brief Associate a socket label with a vnode
5537 @param cred User credential for the process that opened the socket
5538 @param so Socket structure
5539 @param solabel Label associated with so
5540 @param vp Vnode to label
5541 @param vlabel Label associated with vp
5543 Associate label information for the vnode, vp, with the label of
5544 the open socket described by the socket structure so.
5545 The label should be stored in the supplied vlabel parameter.
5547 typedef void mpo_vnode_label_associate_socket_t(
5550 struct label
*solabel
,
5552 struct label
*vlabel
5555 @brief Copy a vnode label
5556 @param src Source vnode label
5557 @param dest Destination vnode label
5559 Copy the vnode label information from src to dest. On Darwin, this
5560 is currently only necessary when executing interpreted scripts, but
5561 will later be used if vnode label externalization cannot be an
5564 typedef void mpo_vnode_label_copy_t(
5569 @brief Destroy vnode label
5570 @param label The label to be destroyed
5572 Destroy a vnode label. Since the object is going out of scope,
5573 policy modules should free any internal storage associated with the
5574 label so that it may be destroyed.
5576 typedef void mpo_vnode_label_destroy_t(
5580 @brief Externalize a vnode label for auditing
5581 @param label Label to be externalized
5582 @param element_name Name of the label namespace for which labels should be
5584 @param sb String buffer to be filled with a text representation of the label
5586 Produce an external representation of the label on a vnode suitable for
5587 inclusion in an audit record. An externalized label consists of a text
5588 representation of the label contents that will be added to the audit record
5589 as part of a text token. Policy-agnostic user space tools will display
5590 this externalized version.
5592 @return 0 on success, return non-zero if an error occurs while
5593 externalizing the label data.
5596 typedef int mpo_vnode_label_externalize_audit_t(
5597 struct label
*label
,
5602 @brief Externalize a vnode label
5603 @param label Label to be externalized
5604 @param element_name Name of the label namespace for which labels should be
5606 @param sb String buffer to be filled with a text representation of the label
5608 Produce an external representation of the label on a vnode. An
5609 externalized label consists of a text representation of the label
5610 contents that can be used with user applications. Policy-agnostic
5611 user space tools will display this externalized version.
5613 @return 0 on success, return non-zero if an error occurs while
5614 externalizing the label data.
5617 typedef int mpo_vnode_label_externalize_t(
5618 struct label
*label
,
5623 @brief Initialize vnode label
5624 @param label New label to initialize
5626 Initialize label storage for use with a newly instantiated vnode, or
5627 for temporary storage associated with the copying in or out of a
5628 vnode label. While it is necessary to allocate space for a
5629 kernel-resident vnode label, it is not yet necessary to link this vnode
5630 with persistent label storage facilities, such as extended attributes.
5631 Sleeping is permitted.
5633 typedef void mpo_vnode_label_init_t(
5637 @brief Internalize a vnode label
5638 @param label Label to be internalized
5639 @param element_name Name of the label namespace for which the label should
5641 @param element_data Text data to be internalized
5643 Produce a vnode label from an external representation. An
5644 externalized label consists of a text representation of the label
5645 contents that can be used with user applications. Policy-agnostic
5646 user space tools will forward text version to the kernel for
5647 processing by individual policy modules.
5649 The policy's internalize entry points will be called only if the
5650 policy has registered interest in the label namespace.
5652 @return 0 on success, Otherwise, return non-zero if an error occurs
5653 while internalizing the label data.
5655 typedef int mpo_vnode_label_internalize_t(
5656 struct label
*label
,
5661 @brief Clean up a vnode label
5662 @param label The label to be cleaned for re-use
5664 Clean up a vnode label. Darwin (Tiger, 8.x) allocates vnodes on demand, but
5665 typically never frees them. Before vnodes are placed back on free lists for
5666 re-use, policies can cleanup or overwrite any information present in the label.
5668 typedef void mpo_vnode_label_recycle_t(
5672 @brief Write a label to a extended attribute
5673 @param cred Subject credential
5674 @param vp The vnode for which the label is being stored
5675 @param vlabel Label associated with vp
5676 @param intlabel The new label to store
5678 Store a new label in the extended attribute corresponding to the
5679 supplied vnode. The policy has already authorized the operation;
5680 this call must be implemented in order to perform the actual
5683 @return In the event of an error, an appropriate value for errno
5684 should be returned, otherwise return 0 upon success.
5686 @warning XXX After examining the extended attribute implementation on
5687 Apple's future release, this entry point may be changed.
5689 typedef int mpo_vnode_label_store_t(
5692 struct label
*vlabel
,
5693 struct label
*intlabel
5696 @brief Update vnode label from extended attributes
5697 @param mp File system mount point
5698 @param mntlabel Mount point label
5699 @param vp Vnode to label
5700 @param vlabel Label associated with vp
5701 @param name Name of the xattr
5702 @see mpo_vnode_check_setextattr_t
5704 When an extended attribute is updated via the Vendor attribute management
5705 functions, the MAC vnode label might also require an update.
5706 Policies should first determine if 'name' matches their xattr label
5707 name. If it does, the kernel is has either replaced or removed the
5708 named extended attribute that was previously associated with the
5709 vnode. Normally labels should only be modified via MAC Framework label
5710 management calls, but sometimes the user space components will directly
5711 modify extended attributes. For example, 'cp', 'tar', etc. manage
5712 extended attributes in userspace, not the kernel.
5714 This entry point is called after the label update has occurred, so
5715 it cannot return a failure. However, the operation is preceded by
5716 the mpo_vnode_check_setextattr() access control check.
5718 If the vnode label needs to be updated the policy should return
5719 a non-zero value. The vnode label will be marked for re-association
5722 typedef int mpo_vnode_label_update_extattr_t(
5724 struct label
*mntlabel
,
5726 struct label
*vlabel
,
5730 @brief Update a vnode label
5731 @param cred Subject credential
5732 @param vp The vnode to relabel
5733 @param vnodelabel Existing vnode label
5734 @param label New label to replace existing label
5735 @see mpo_vnode_check_label_update_t
5737 The subject identified by the credential has previously requested
5738 and was authorized to relabel the vnode; this entry point allows
5739 policies to perform the actual relabel operation. Policies should
5740 update vnodelabel using the label stored in the label parameter.
5742 typedef void mpo_vnode_label_update_t(
5745 struct label
*vnodelabel
,
5749 @brief Find deatched signatures for a shared library
5750 @param p file trying to find the signature
5751 @param vp The vnode to relabel
5752 @param offset offset in the macho that the signature is requested for (for fat binaries)
5753 @param label Existing vnode label
5756 typedef int mpo_vnode_find_sigs_t(
5763 @brief Create a new vnode, backed by extended attributes
5764 @param cred User credential for the creating process
5765 @param mp File system mount point
5766 @param mntlabel File system mount point label
5767 @param dvp Parent directory vnode
5768 @param dlabel Parent directory vnode label
5769 @param vp Newly created vnode
5770 @param vlabel Label to associate with the new vnode
5771 @param cnp Component name for vp
5773 Write out the label for the newly created vnode, most likely storing
5774 the results in a file system extended attribute. Most policies will
5775 derive the new vnode label using information from a combination
5776 of the subject (user) credential, the file system label, the parent
5777 directory label, and potentially the path name component.
5779 @return If the operation succeeds, store the new label in vlabel and
5780 return 0. Otherwise, return an appropriate errno value.
5782 typedef int mpo_vnode_notify_create_t(
5785 struct label
*mntlabel
,
5787 struct label
*dlabel
,
5789 struct label
*vlabel
,
5790 struct componentname
*cnp
5794 @brief Inform MAC policies that a vnode has been opened
5795 @param cred User credential for the creating process
5796 @param vp vnode opened
5797 @param label Policy label for the vp
5798 @param acc_mode open(2) access mode used
5800 Inform Mac policies that a vnode have been successfully opened
5801 (passing all MAC polices and DAC).
5803 typedef void mpo_vnode_notify_open_t(
5806 struct label
*label
,
5811 @brief Inform MAC policies that a vnode has been renamed
5812 @param cred User credential for the renaming process
5813 @param vp Vnode that's being renamed
5814 @param label Policy label for vp
5815 @param dvp Parent directory for the destination
5816 @param dlabel Policy label for dvp
5817 @param cnp Component name for the destination
5819 Inform MAC policies that a vnode has been renamed.
5821 typedef void mpo_vnode_notify_rename_t(
5824 struct label
*label
,
5826 struct label
*dlabel
,
5827 struct componentname
*cnp
5831 @brief Inform MAC policies that a vnode has been linked
5832 @param cred User credential for the renaming process
5833 @param dvp Parent directory for the destination
5834 @param dlabel Policy label for dvp
5835 @param vp Vnode that's being linked
5836 @param vlabel Policy label for vp
5837 @param cnp Component name for the destination
5839 Inform MAC policies that a vnode has been linked.
5841 typedef void mpo_vnode_notify_link_t(
5844 struct label
*dlabel
,
5846 struct label
*vlabel
,
5847 struct componentname
*cnp
5851 @brief Inform MAC policies that an extended attribute has been removed from a vnode
5852 @param cred Subject credential
5853 @param vp Object node
5854 @param label Policy label for vp
5855 @param name Extended attribute name
5857 Inform MAC policies that an extended attribute has been removed from a vnode.
5859 typedef void mpo_vnode_notify_deleteextattr_t(
5862 struct label
*label
,
5868 @brief Inform MAC policies that an ACL has been set on a vnode
5869 @param cred Subject credential
5870 @param vp Object node
5871 @param label Policy label for vp
5872 @param acl ACL structure pointer
5874 Inform MAC policies that an ACL has been set on a vnode.
5876 typedef void mpo_vnode_notify_setacl_t(
5879 struct label
*label
,
5880 struct kauth_acl
*acl
5884 @brief Inform MAC policies that an attributes have been set on a vnode
5885 @param cred Subject credential
5886 @param vp Object vnode
5887 @param label Policy label for vp
5888 @param alist List of attributes to set
5890 Inform MAC policies that an attributes have been set on a vnode.
5892 typedef void mpo_vnode_notify_setattrlist_t(
5895 struct label
*label
,
5896 struct attrlist
*alist
5900 @brief Inform MAC policies that an extended attribute has been set on a vnode
5901 @param cred Subject credential
5902 @param vp Object vnode
5903 @param label Policy label for vp
5904 @param name Extended attribute name
5905 @param uio I/O structure pointer
5907 Inform MAC policies that an extended attribute has been set on a vnode.
5909 typedef void mpo_vnode_notify_setextattr_t(
5912 struct label
*label
,
5918 @brief Inform MAC policies that flags have been set on a vnode
5919 @param cred Subject credential
5920 @param vp Object vnode
5921 @param label Policy label for vp
5922 @param flags File flags; see chflags(2)
5924 Inform MAC policies that flags have been set on a vnode.
5926 typedef void mpo_vnode_notify_setflags_t(
5929 struct label
*label
,
5934 @brief Inform MAC policies that a new mode has been set on a vnode
5935 @param cred Subject credential
5936 @param vp Object vnode
5937 @param label Policy label for vp
5938 @param mode File mode; see chmod(2)
5940 Inform MAC policies that a new mode has been set on a vnode.
5942 typedef void mpo_vnode_notify_setmode_t(
5945 struct label
*label
,
5950 @brief Inform MAC policies that new uid/gid have been set on a vnode
5951 @param cred Subject credential
5952 @param vp Object vnode
5953 @param label Policy label for vp
5957 Inform MAC policies that new uid/gid have been set on a vnode.
5959 typedef void mpo_vnode_notify_setowner_t(
5962 struct label
*label
,
5968 @brief Inform MAC policies that new timestamps have been set on a vnode
5969 @param cred Subject credential
5970 @param vp Object vnode
5971 @param label Policy label for vp
5972 @param atime Access time; see utimes(2)
5973 @param mtime Modification time; see utimes(2)
5975 Inform MAC policies that new timestamps have been set on a vnode.
5977 typedef void mpo_vnode_notify_setutimes_t(
5980 struct label
*label
,
5981 struct timespec atime
,
5982 struct timespec mtime
5986 @brief Inform MAC policies that a vnode has been truncated
5987 @param cred Subject credential
5988 @param file_cred Credential associated with the struct fileproc
5989 @param vp Object vnode
5990 @param label Policy label for vp
5992 Inform MAC policies that a vnode has been truncated.
5994 typedef void mpo_vnode_notify_truncate_t(
5996 kauth_cred_t file_cred
,
6003 @brief Inform MAC policies that a pty slave has been granted
6004 @param p Responsible process
6005 @param tp tty data structure
6006 @param dev Major and minor numbers of device
6007 @param label Policy label for tp
6009 Inform MAC policies that a pty slave has been granted.
6011 typedef void mpo_pty_notify_grant_t(
6019 @brief Inform MAC policies that a pty master has been closed
6020 @param p Responsible process
6021 @param tp tty data structure
6022 @param dev Major and minor numbers of device
6023 @param label Policy label for tp
6025 Inform MAC policies that a pty master has been closed.
6027 typedef void mpo_pty_notify_close_t(
6035 @brief Access control check for kext loading
6036 @param cred Subject credential
6037 @param identifier Kext identifier
6039 Determine whether the subject identified by the credential can load the
6042 @return Return 0 if access is granted, otherwise an appropriate value for
6043 errno should be returned. Suggested failure: EPERM for lack of privilege.
6045 typedef int mpo_kext_check_load_t(
6047 const char *identifier
6051 @brief Access control check for kext unloading
6052 @param cred Subject credential
6053 @param identifier Kext identifier
6055 Determine whether the subject identified by the credential can unload the
6058 @return Return 0 if access is granted, otherwise an appropriate value for
6059 errno should be returned. Suggested failure: EPERM for lack of privilege.
6061 typedef int mpo_kext_check_unload_t(
6063 const char *identifier
6067 @brief Access control check for querying information about loaded kexts
6068 @param cred Subject credential
6070 Determine whether the subject identified by the credential can query
6071 information about loaded kexts.
6073 @return Return 0 if access is granted, otherwise an appropriate value for
6074 errno should be returned. Suggested failure: EPERM for lack of privilege.
6076 typedef int mpo_kext_check_query_t(
6081 @brief Access control check for getting NVRAM variables.
6082 @param cred Subject credential
6083 @param name NVRAM variable to get
6085 Determine whether the subject identifier by the credential can get the
6086 value of the named NVRAM variable.
6088 @return Return 0 if access is granted, otherwise an appropriate value for
6089 errno should be returned. Suggested failure: EPERM for lack of privilege.
6091 typedef int mpo_iokit_check_nvram_get_t(
6097 @brief Access control check for setting NVRAM variables.
6098 @param cred Subject credential
6099 @param name NVRAM variable to set
6100 @param value The new value for the NVRAM variable
6102 Determine whether the subject identifier by the credential can set the
6103 value of the named NVRAM variable.
6105 @return Return 0 if access is granted, otherwise an appropriate value for
6106 errno should be returned. Suggested failure: EPERM for lack of privilege.
6108 typedef int mpo_iokit_check_nvram_set_t(
6115 @brief Access control check for deleting NVRAM variables.
6116 @param cred Subject credential
6117 @param name NVRAM variable to delete
6119 Determine whether the subject identifier by the credential can delete the
6120 named NVRAM variable.
6122 @return Return 0 if access is granted, otherwise an appropriate value for
6123 errno should be returned. Suggested failure: EPERM for lack of privilege.
6125 typedef int mpo_iokit_check_nvram_delete_t(
6131 * Placeholder for future events that may need mac hooks.
6133 typedef void mpo_reserved_hook_t(void);
6136 * Policy module operations.
6138 * Please note that this should be kept in sync with the check assumptions
6139 * policy in bsd/kern/policy_check.c (policy_ops struct).
6141 #define MAC_POLICY_OPS_VERSION 45 /* inc when new reserved slots are taken */
6142 struct mac_policy_ops
{
6143 mpo_audit_check_postselect_t
*mpo_audit_check_postselect
;
6144 mpo_audit_check_preselect_t
*mpo_audit_check_preselect
;
6146 mpo_bpfdesc_label_associate_t
*mpo_bpfdesc_label_associate
;
6147 mpo_bpfdesc_label_destroy_t
*mpo_bpfdesc_label_destroy
;
6148 mpo_bpfdesc_label_init_t
*mpo_bpfdesc_label_init
;
6149 mpo_bpfdesc_check_receive_t
*mpo_bpfdesc_check_receive
;
6151 mpo_cred_check_label_update_execve_t
*mpo_cred_check_label_update_execve
;
6152 mpo_cred_check_label_update_t
*mpo_cred_check_label_update
;
6153 mpo_cred_check_visible_t
*mpo_cred_check_visible
;
6154 mpo_cred_label_associate_fork_t
*mpo_cred_label_associate_fork
;
6155 mpo_cred_label_associate_kernel_t
*mpo_cred_label_associate_kernel
;
6156 mpo_cred_label_associate_t
*mpo_cred_label_associate
;
6157 mpo_cred_label_associate_user_t
*mpo_cred_label_associate_user
;
6158 mpo_cred_label_destroy_t
*mpo_cred_label_destroy
;
6159 mpo_cred_label_externalize_audit_t
*mpo_cred_label_externalize_audit
;
6160 mpo_cred_label_externalize_t
*mpo_cred_label_externalize
;
6161 mpo_cred_label_init_t
*mpo_cred_label_init
;
6162 mpo_cred_label_internalize_t
*mpo_cred_label_internalize
;
6163 mpo_cred_label_update_execve_t
*mpo_cred_label_update_execve
;
6164 mpo_cred_label_update_t
*mpo_cred_label_update
;
6166 mpo_devfs_label_associate_device_t
*mpo_devfs_label_associate_device
;
6167 mpo_devfs_label_associate_directory_t
*mpo_devfs_label_associate_directory
;
6168 mpo_devfs_label_copy_t
*mpo_devfs_label_copy
;
6169 mpo_devfs_label_destroy_t
*mpo_devfs_label_destroy
;
6170 mpo_devfs_label_init_t
*mpo_devfs_label_init
;
6171 mpo_devfs_label_update_t
*mpo_devfs_label_update
;
6173 mpo_file_check_change_offset_t
*mpo_file_check_change_offset
;
6174 mpo_file_check_create_t
*mpo_file_check_create
;
6175 mpo_file_check_dup_t
*mpo_file_check_dup
;
6176 mpo_file_check_fcntl_t
*mpo_file_check_fcntl
;
6177 mpo_file_check_get_offset_t
*mpo_file_check_get_offset
;
6178 mpo_file_check_get_t
*mpo_file_check_get
;
6179 mpo_file_check_inherit_t
*mpo_file_check_inherit
;
6180 mpo_file_check_ioctl_t
*mpo_file_check_ioctl
;
6181 mpo_file_check_lock_t
*mpo_file_check_lock
;
6182 mpo_file_check_mmap_downgrade_t
*mpo_file_check_mmap_downgrade
;
6183 mpo_file_check_mmap_t
*mpo_file_check_mmap
;
6184 mpo_file_check_receive_t
*mpo_file_check_receive
;
6185 mpo_file_check_set_t
*mpo_file_check_set
;
6186 mpo_file_label_init_t
*mpo_file_label_init
;
6187 mpo_file_label_destroy_t
*mpo_file_label_destroy
;
6188 mpo_file_label_associate_t
*mpo_file_label_associate
;
6190 mpo_ifnet_check_label_update_t
*mpo_ifnet_check_label_update
;
6191 mpo_ifnet_check_transmit_t
*mpo_ifnet_check_transmit
;
6192 mpo_ifnet_label_associate_t
*mpo_ifnet_label_associate
;
6193 mpo_ifnet_label_copy_t
*mpo_ifnet_label_copy
;
6194 mpo_ifnet_label_destroy_t
*mpo_ifnet_label_destroy
;
6195 mpo_ifnet_label_externalize_t
*mpo_ifnet_label_externalize
;
6196 mpo_ifnet_label_init_t
*mpo_ifnet_label_init
;
6197 mpo_ifnet_label_internalize_t
*mpo_ifnet_label_internalize
;
6198 mpo_ifnet_label_update_t
*mpo_ifnet_label_update
;
6199 mpo_ifnet_label_recycle_t
*mpo_ifnet_label_recycle
;
6201 mpo_inpcb_check_deliver_t
*mpo_inpcb_check_deliver
;
6202 mpo_inpcb_label_associate_t
*mpo_inpcb_label_associate
;
6203 mpo_inpcb_label_destroy_t
*mpo_inpcb_label_destroy
;
6204 mpo_inpcb_label_init_t
*mpo_inpcb_label_init
;
6205 mpo_inpcb_label_recycle_t
*mpo_inpcb_label_recycle
;
6206 mpo_inpcb_label_update_t
*mpo_inpcb_label_update
;
6208 mpo_iokit_check_device_t
*mpo_iokit_check_device
;
6210 mpo_ipq_label_associate_t
*mpo_ipq_label_associate
;
6211 mpo_ipq_label_compare_t
*mpo_ipq_label_compare
;
6212 mpo_ipq_label_destroy_t
*mpo_ipq_label_destroy
;
6213 mpo_ipq_label_init_t
*mpo_ipq_label_init
;
6214 mpo_ipq_label_update_t
*mpo_ipq_label_update
;
6216 mpo_file_check_library_validation_t
*mpo_file_check_library_validation
;
6217 mpo_vnode_notify_setacl_t
*mpo_vnode_notify_setacl
;
6218 mpo_vnode_notify_setattrlist_t
*mpo_vnode_notify_setattrlist
;
6219 mpo_vnode_notify_setextattr_t
*mpo_vnode_notify_setextattr
;
6220 mpo_vnode_notify_setflags_t
*mpo_vnode_notify_setflags
;
6221 mpo_vnode_notify_setmode_t
*mpo_vnode_notify_setmode
;
6222 mpo_vnode_notify_setowner_t
*mpo_vnode_notify_setowner
;
6223 mpo_vnode_notify_setutimes_t
*mpo_vnode_notify_setutimes
;
6224 mpo_vnode_notify_truncate_t
*mpo_vnode_notify_truncate
;
6226 mpo_mbuf_label_associate_bpfdesc_t
*mpo_mbuf_label_associate_bpfdesc
;
6227 mpo_mbuf_label_associate_ifnet_t
*mpo_mbuf_label_associate_ifnet
;
6228 mpo_mbuf_label_associate_inpcb_t
*mpo_mbuf_label_associate_inpcb
;
6229 mpo_mbuf_label_associate_ipq_t
*mpo_mbuf_label_associate_ipq
;
6230 mpo_mbuf_label_associate_linklayer_t
*mpo_mbuf_label_associate_linklayer
;
6231 mpo_mbuf_label_associate_multicast_encap_t
*mpo_mbuf_label_associate_multicast_encap
;
6232 mpo_mbuf_label_associate_netlayer_t
*mpo_mbuf_label_associate_netlayer
;
6233 mpo_mbuf_label_associate_socket_t
*mpo_mbuf_label_associate_socket
;
6234 mpo_mbuf_label_copy_t
*mpo_mbuf_label_copy
;
6235 mpo_mbuf_label_destroy_t
*mpo_mbuf_label_destroy
;
6236 mpo_mbuf_label_init_t
*mpo_mbuf_label_init
;
6238 mpo_mount_check_fsctl_t
*mpo_mount_check_fsctl
;
6239 mpo_mount_check_getattr_t
*mpo_mount_check_getattr
;
6240 mpo_mount_check_label_update_t
*mpo_mount_check_label_update
;
6241 mpo_mount_check_mount_t
*mpo_mount_check_mount
;
6242 mpo_mount_check_remount_t
*mpo_mount_check_remount
;
6243 mpo_mount_check_setattr_t
*mpo_mount_check_setattr
;
6244 mpo_mount_check_stat_t
*mpo_mount_check_stat
;
6245 mpo_mount_check_umount_t
*mpo_mount_check_umount
;
6246 mpo_mount_label_associate_t
*mpo_mount_label_associate
;
6247 mpo_mount_label_destroy_t
*mpo_mount_label_destroy
;
6248 mpo_mount_label_externalize_t
*mpo_mount_label_externalize
;
6249 mpo_mount_label_init_t
*mpo_mount_label_init
;
6250 mpo_mount_label_internalize_t
*mpo_mount_label_internalize
;
6252 mpo_netinet_fragment_t
*mpo_netinet_fragment
;
6253 mpo_netinet_icmp_reply_t
*mpo_netinet_icmp_reply
;
6254 mpo_netinet_tcp_reply_t
*mpo_netinet_tcp_reply
;
6256 mpo_pipe_check_ioctl_t
*mpo_pipe_check_ioctl
;
6257 mpo_pipe_check_kqfilter_t
*mpo_pipe_check_kqfilter
;
6258 mpo_pipe_check_label_update_t
*mpo_pipe_check_label_update
;
6259 mpo_pipe_check_read_t
*mpo_pipe_check_read
;
6260 mpo_pipe_check_select_t
*mpo_pipe_check_select
;
6261 mpo_pipe_check_stat_t
*mpo_pipe_check_stat
;
6262 mpo_pipe_check_write_t
*mpo_pipe_check_write
;
6263 mpo_pipe_label_associate_t
*mpo_pipe_label_associate
;
6264 mpo_pipe_label_copy_t
*mpo_pipe_label_copy
;
6265 mpo_pipe_label_destroy_t
*mpo_pipe_label_destroy
;
6266 mpo_pipe_label_externalize_t
*mpo_pipe_label_externalize
;
6267 mpo_pipe_label_init_t
*mpo_pipe_label_init
;
6268 mpo_pipe_label_internalize_t
*mpo_pipe_label_internalize
;
6269 mpo_pipe_label_update_t
*mpo_pipe_label_update
;
6271 mpo_policy_destroy_t
*mpo_policy_destroy
;
6272 mpo_policy_init_t
*mpo_policy_init
;
6273 mpo_policy_initbsd_t
*mpo_policy_initbsd
;
6274 mpo_policy_syscall_t
*mpo_policy_syscall
;
6276 mpo_system_check_sysctlbyname_t
*mpo_system_check_sysctlbyname
;
6277 mpo_proc_check_inherit_ipc_ports_t
*mpo_proc_check_inherit_ipc_ports
;
6278 mpo_vnode_check_rename_t
*mpo_vnode_check_rename
;
6279 mpo_kext_check_query_t
*mpo_kext_check_query
;
6280 mpo_iokit_check_nvram_get_t
*mpo_iokit_check_nvram_get
;
6281 mpo_iokit_check_nvram_set_t
*mpo_iokit_check_nvram_set
;
6282 mpo_iokit_check_nvram_delete_t
*mpo_iokit_check_nvram_delete
;
6283 mpo_proc_check_expose_task_t
*mpo_proc_check_expose_task
;
6284 mpo_proc_check_set_host_special_port_t
*mpo_proc_check_set_host_special_port
;
6285 mpo_proc_check_set_host_exception_port_t
*mpo_proc_check_set_host_exception_port
;
6286 mpo_exc_action_check_exception_send_t
*mpo_exc_action_check_exception_send
;
6287 mpo_exc_action_label_associate_t
*mpo_exc_action_label_associate
;
6288 mpo_exc_action_label_copy_t
*mpo_exc_action_label_copy
;
6289 mpo_exc_action_label_destroy_t
*mpo_exc_action_label_destroy
;
6290 mpo_exc_action_label_init_t
*mpo_exc_action_label_init
;
6291 mpo_exc_action_label_update_t
*mpo_exc_action_label_update
;
6293 mpo_reserved_hook_t
*mpo_reserved17
;
6294 mpo_reserved_hook_t
*mpo_reserved18
;
6295 mpo_reserved_hook_t
*mpo_reserved19
;
6296 mpo_reserved_hook_t
*mpo_reserved20
;
6297 mpo_reserved_hook_t
*mpo_reserved21
;
6298 mpo_reserved_hook_t
*mpo_reserved22
;
6300 mpo_posixsem_check_create_t
*mpo_posixsem_check_create
;
6301 mpo_posixsem_check_open_t
*mpo_posixsem_check_open
;
6302 mpo_posixsem_check_post_t
*mpo_posixsem_check_post
;
6303 mpo_posixsem_check_unlink_t
*mpo_posixsem_check_unlink
;
6304 mpo_posixsem_check_wait_t
*mpo_posixsem_check_wait
;
6305 mpo_posixsem_label_associate_t
*mpo_posixsem_label_associate
;
6306 mpo_posixsem_label_destroy_t
*mpo_posixsem_label_destroy
;
6307 mpo_posixsem_label_init_t
*mpo_posixsem_label_init
;
6308 mpo_posixshm_check_create_t
*mpo_posixshm_check_create
;
6309 mpo_posixshm_check_mmap_t
*mpo_posixshm_check_mmap
;
6310 mpo_posixshm_check_open_t
*mpo_posixshm_check_open
;
6311 mpo_posixshm_check_stat_t
*mpo_posixshm_check_stat
;
6312 mpo_posixshm_check_truncate_t
*mpo_posixshm_check_truncate
;
6313 mpo_posixshm_check_unlink_t
*mpo_posixshm_check_unlink
;
6314 mpo_posixshm_label_associate_t
*mpo_posixshm_label_associate
;
6315 mpo_posixshm_label_destroy_t
*mpo_posixshm_label_destroy
;
6316 mpo_posixshm_label_init_t
*mpo_posixshm_label_init
;
6318 mpo_proc_check_debug_t
*mpo_proc_check_debug
;
6319 mpo_proc_check_fork_t
*mpo_proc_check_fork
;
6320 mpo_proc_check_get_task_name_t
*mpo_proc_check_get_task_name
;
6321 mpo_proc_check_get_task_t
*mpo_proc_check_get_task
;
6322 mpo_proc_check_getaudit_t
*mpo_proc_check_getaudit
;
6323 mpo_proc_check_getauid_t
*mpo_proc_check_getauid
;
6324 mpo_proc_check_getlcid_t
*mpo_proc_check_getlcid
;
6325 mpo_proc_check_mprotect_t
*mpo_proc_check_mprotect
;
6326 mpo_proc_check_sched_t
*mpo_proc_check_sched
;
6327 mpo_proc_check_setaudit_t
*mpo_proc_check_setaudit
;
6328 mpo_proc_check_setauid_t
*mpo_proc_check_setauid
;
6329 mpo_proc_check_setlcid_t
*mpo_proc_check_setlcid
;
6330 mpo_proc_check_signal_t
*mpo_proc_check_signal
;
6331 mpo_proc_check_wait_t
*mpo_proc_check_wait
;
6332 mpo_proc_label_destroy_t
*mpo_proc_label_destroy
;
6333 mpo_proc_label_init_t
*mpo_proc_label_init
;
6335 mpo_socket_check_accept_t
*mpo_socket_check_accept
;
6336 mpo_socket_check_accepted_t
*mpo_socket_check_accepted
;
6337 mpo_socket_check_bind_t
*mpo_socket_check_bind
;
6338 mpo_socket_check_connect_t
*mpo_socket_check_connect
;
6339 mpo_socket_check_create_t
*mpo_socket_check_create
;
6340 mpo_socket_check_deliver_t
*mpo_socket_check_deliver
;
6341 mpo_socket_check_kqfilter_t
*mpo_socket_check_kqfilter
;
6342 mpo_socket_check_label_update_t
*mpo_socket_check_label_update
;
6343 mpo_socket_check_listen_t
*mpo_socket_check_listen
;
6344 mpo_socket_check_receive_t
*mpo_socket_check_receive
;
6345 mpo_socket_check_received_t
*mpo_socket_check_received
;
6346 mpo_socket_check_select_t
*mpo_socket_check_select
;
6347 mpo_socket_check_send_t
*mpo_socket_check_send
;
6348 mpo_socket_check_stat_t
*mpo_socket_check_stat
;
6349 mpo_socket_check_setsockopt_t
*mpo_socket_check_setsockopt
;
6350 mpo_socket_check_getsockopt_t
*mpo_socket_check_getsockopt
;
6351 mpo_socket_label_associate_accept_t
*mpo_socket_label_associate_accept
;
6352 mpo_socket_label_associate_t
*mpo_socket_label_associate
;
6353 mpo_socket_label_copy_t
*mpo_socket_label_copy
;
6354 mpo_socket_label_destroy_t
*mpo_socket_label_destroy
;
6355 mpo_socket_label_externalize_t
*mpo_socket_label_externalize
;
6356 mpo_socket_label_init_t
*mpo_socket_label_init
;
6357 mpo_socket_label_internalize_t
*mpo_socket_label_internalize
;
6358 mpo_socket_label_update_t
*mpo_socket_label_update
;
6360 mpo_socketpeer_label_associate_mbuf_t
*mpo_socketpeer_label_associate_mbuf
;
6361 mpo_socketpeer_label_associate_socket_t
*mpo_socketpeer_label_associate_socket
;
6362 mpo_socketpeer_label_destroy_t
*mpo_socketpeer_label_destroy
;
6363 mpo_socketpeer_label_externalize_t
*mpo_socketpeer_label_externalize
;
6364 mpo_socketpeer_label_init_t
*mpo_socketpeer_label_init
;
6366 mpo_system_check_acct_t
*mpo_system_check_acct
;
6367 mpo_system_check_audit_t
*mpo_system_check_audit
;
6368 mpo_system_check_auditctl_t
*mpo_system_check_auditctl
;
6369 mpo_system_check_auditon_t
*mpo_system_check_auditon
;
6370 mpo_system_check_host_priv_t
*mpo_system_check_host_priv
;
6371 mpo_system_check_nfsd_t
*mpo_system_check_nfsd
;
6372 mpo_system_check_reboot_t
*mpo_system_check_reboot
;
6373 mpo_system_check_settime_t
*mpo_system_check_settime
;
6374 mpo_system_check_swapoff_t
*mpo_system_check_swapoff
;
6375 mpo_system_check_swapon_t
*mpo_system_check_swapon
;
6376 mpo_reserved_hook_t
*mpo_reserved31
;
6378 mpo_sysvmsg_label_associate_t
*mpo_sysvmsg_label_associate
;
6379 mpo_sysvmsg_label_destroy_t
*mpo_sysvmsg_label_destroy
;
6380 mpo_sysvmsg_label_init_t
*mpo_sysvmsg_label_init
;
6381 mpo_sysvmsg_label_recycle_t
*mpo_sysvmsg_label_recycle
;
6382 mpo_sysvmsq_check_enqueue_t
*mpo_sysvmsq_check_enqueue
;
6383 mpo_sysvmsq_check_msgrcv_t
*mpo_sysvmsq_check_msgrcv
;
6384 mpo_sysvmsq_check_msgrmid_t
*mpo_sysvmsq_check_msgrmid
;
6385 mpo_sysvmsq_check_msqctl_t
*mpo_sysvmsq_check_msqctl
;
6386 mpo_sysvmsq_check_msqget_t
*mpo_sysvmsq_check_msqget
;
6387 mpo_sysvmsq_check_msqrcv_t
*mpo_sysvmsq_check_msqrcv
;
6388 mpo_sysvmsq_check_msqsnd_t
*mpo_sysvmsq_check_msqsnd
;
6389 mpo_sysvmsq_label_associate_t
*mpo_sysvmsq_label_associate
;
6390 mpo_sysvmsq_label_destroy_t
*mpo_sysvmsq_label_destroy
;
6391 mpo_sysvmsq_label_init_t
*mpo_sysvmsq_label_init
;
6392 mpo_sysvmsq_label_recycle_t
*mpo_sysvmsq_label_recycle
;
6393 mpo_sysvsem_check_semctl_t
*mpo_sysvsem_check_semctl
;
6394 mpo_sysvsem_check_semget_t
*mpo_sysvsem_check_semget
;
6395 mpo_sysvsem_check_semop_t
*mpo_sysvsem_check_semop
;
6396 mpo_sysvsem_label_associate_t
*mpo_sysvsem_label_associate
;
6397 mpo_sysvsem_label_destroy_t
*mpo_sysvsem_label_destroy
;
6398 mpo_sysvsem_label_init_t
*mpo_sysvsem_label_init
;
6399 mpo_sysvsem_label_recycle_t
*mpo_sysvsem_label_recycle
;
6400 mpo_sysvshm_check_shmat_t
*mpo_sysvshm_check_shmat
;
6401 mpo_sysvshm_check_shmctl_t
*mpo_sysvshm_check_shmctl
;
6402 mpo_sysvshm_check_shmdt_t
*mpo_sysvshm_check_shmdt
;
6403 mpo_sysvshm_check_shmget_t
*mpo_sysvshm_check_shmget
;
6404 mpo_sysvshm_label_associate_t
*mpo_sysvshm_label_associate
;
6405 mpo_sysvshm_label_destroy_t
*mpo_sysvshm_label_destroy
;
6406 mpo_sysvshm_label_init_t
*mpo_sysvshm_label_init
;
6407 mpo_sysvshm_label_recycle_t
*mpo_sysvshm_label_recycle
;
6409 mpo_reserved_hook_t
*mpo_reserved23
;
6410 mpo_reserved_hook_t
*mpo_reserved24
;
6411 mpo_reserved_hook_t
*mpo_reserved25
;
6412 mpo_mount_check_snapshot_create_t
*mpo_mount_check_snapshot_create
;
6413 mpo_mount_check_snapshot_delete_t
*mpo_mount_check_snapshot_delete
;
6414 mpo_vnode_check_clone_t
*mpo_vnode_check_clone
;
6415 mpo_proc_check_get_cs_info_t
*mpo_proc_check_get_cs_info
;
6416 mpo_proc_check_set_cs_info_t
*mpo_proc_check_set_cs_info
;
6418 mpo_iokit_check_hid_control_t
*mpo_iokit_check_hid_control
;
6420 mpo_vnode_check_access_t
*mpo_vnode_check_access
;
6421 mpo_vnode_check_chdir_t
*mpo_vnode_check_chdir
;
6422 mpo_vnode_check_chroot_t
*mpo_vnode_check_chroot
;
6423 mpo_vnode_check_create_t
*mpo_vnode_check_create
;
6424 mpo_vnode_check_deleteextattr_t
*mpo_vnode_check_deleteextattr
;
6425 mpo_vnode_check_exchangedata_t
*mpo_vnode_check_exchangedata
;
6426 mpo_vnode_check_exec_t
*mpo_vnode_check_exec
;
6427 mpo_vnode_check_getattrlist_t
*mpo_vnode_check_getattrlist
;
6428 mpo_vnode_check_getextattr_t
*mpo_vnode_check_getextattr
;
6429 mpo_vnode_check_ioctl_t
*mpo_vnode_check_ioctl
;
6430 mpo_vnode_check_kqfilter_t
*mpo_vnode_check_kqfilter
;
6431 mpo_vnode_check_label_update_t
*mpo_vnode_check_label_update
;
6432 mpo_vnode_check_link_t
*mpo_vnode_check_link
;
6433 mpo_vnode_check_listextattr_t
*mpo_vnode_check_listextattr
;
6434 mpo_vnode_check_lookup_t
*mpo_vnode_check_lookup
;
6435 mpo_vnode_check_open_t
*mpo_vnode_check_open
;
6436 mpo_vnode_check_read_t
*mpo_vnode_check_read
;
6437 mpo_vnode_check_readdir_t
*mpo_vnode_check_readdir
;
6438 mpo_vnode_check_readlink_t
*mpo_vnode_check_readlink
;
6439 mpo_vnode_check_rename_from_t
*mpo_vnode_check_rename_from
;
6440 mpo_vnode_check_rename_to_t
*mpo_vnode_check_rename_to
;
6441 mpo_vnode_check_revoke_t
*mpo_vnode_check_revoke
;
6442 mpo_vnode_check_select_t
*mpo_vnode_check_select
;
6443 mpo_vnode_check_setattrlist_t
*mpo_vnode_check_setattrlist
;
6444 mpo_vnode_check_setextattr_t
*mpo_vnode_check_setextattr
;
6445 mpo_vnode_check_setflags_t
*mpo_vnode_check_setflags
;
6446 mpo_vnode_check_setmode_t
*mpo_vnode_check_setmode
;
6447 mpo_vnode_check_setowner_t
*mpo_vnode_check_setowner
;
6448 mpo_vnode_check_setutimes_t
*mpo_vnode_check_setutimes
;
6449 mpo_vnode_check_stat_t
*mpo_vnode_check_stat
;
6450 mpo_vnode_check_truncate_t
*mpo_vnode_check_truncate
;
6451 mpo_vnode_check_unlink_t
*mpo_vnode_check_unlink
;
6452 mpo_vnode_check_write_t
*mpo_vnode_check_write
;
6453 mpo_vnode_label_associate_devfs_t
*mpo_vnode_label_associate_devfs
;
6454 mpo_vnode_label_associate_extattr_t
*mpo_vnode_label_associate_extattr
;
6455 mpo_vnode_label_associate_file_t
*mpo_vnode_label_associate_file
;
6456 mpo_vnode_label_associate_pipe_t
*mpo_vnode_label_associate_pipe
;
6457 mpo_vnode_label_associate_posixsem_t
*mpo_vnode_label_associate_posixsem
;
6458 mpo_vnode_label_associate_posixshm_t
*mpo_vnode_label_associate_posixshm
;
6459 mpo_vnode_label_associate_singlelabel_t
*mpo_vnode_label_associate_singlelabel
;
6460 mpo_vnode_label_associate_socket_t
*mpo_vnode_label_associate_socket
;
6461 mpo_vnode_label_copy_t
*mpo_vnode_label_copy
;
6462 mpo_vnode_label_destroy_t
*mpo_vnode_label_destroy
;
6463 mpo_vnode_label_externalize_audit_t
*mpo_vnode_label_externalize_audit
;
6464 mpo_vnode_label_externalize_t
*mpo_vnode_label_externalize
;
6465 mpo_vnode_label_init_t
*mpo_vnode_label_init
;
6466 mpo_vnode_label_internalize_t
*mpo_vnode_label_internalize
;
6467 mpo_vnode_label_recycle_t
*mpo_vnode_label_recycle
;
6468 mpo_vnode_label_store_t
*mpo_vnode_label_store
;
6469 mpo_vnode_label_update_extattr_t
*mpo_vnode_label_update_extattr
;
6470 mpo_vnode_label_update_t
*mpo_vnode_label_update
;
6471 mpo_vnode_notify_create_t
*mpo_vnode_notify_create
;
6472 mpo_vnode_check_signature_t
*mpo_vnode_check_signature
;
6473 mpo_vnode_check_uipc_bind_t
*mpo_vnode_check_uipc_bind
;
6474 mpo_vnode_check_uipc_connect_t
*mpo_vnode_check_uipc_connect
;
6476 mpo_proc_check_run_cs_invalid_t
*mpo_proc_check_run_cs_invalid
;
6477 mpo_proc_check_suspend_resume_t
*mpo_proc_check_suspend_resume
;
6479 mpo_thread_userret_t
*mpo_thread_userret
;
6481 mpo_iokit_check_set_properties_t
*mpo_iokit_check_set_properties
;
6483 mpo_system_check_chud_t
*mpo_system_check_chud
;
6485 mpo_vnode_check_searchfs_t
*mpo_vnode_check_searchfs
;
6487 mpo_priv_check_t
*mpo_priv_check
;
6488 mpo_priv_grant_t
*mpo_priv_grant
;
6490 mpo_proc_check_map_anon_t
*mpo_proc_check_map_anon
;
6492 mpo_vnode_check_fsgetpath_t
*mpo_vnode_check_fsgetpath
;
6494 mpo_iokit_check_open_t
*mpo_iokit_check_open
;
6496 mpo_proc_check_ledger_t
*mpo_proc_check_ledger
;
6498 mpo_vnode_notify_rename_t
*mpo_vnode_notify_rename
;
6500 mpo_vnode_check_setacl_t
*mpo_vnode_check_setacl
;
6502 mpo_vnode_notify_deleteextattr_t
*mpo_vnode_notify_deleteextattr
;
6504 mpo_system_check_kas_info_t
*mpo_system_check_kas_info
;
6506 mpo_proc_check_cpumon_t
*mpo_proc_check_cpumon
;
6508 mpo_vnode_notify_open_t
*mpo_vnode_notify_open
;
6510 mpo_system_check_info_t
*mpo_system_check_info
;
6512 mpo_pty_notify_grant_t
*mpo_pty_notify_grant
;
6513 mpo_pty_notify_close_t
*mpo_pty_notify_close
;
6515 mpo_vnode_find_sigs_t
*mpo_vnode_find_sigs
;
6517 mpo_kext_check_load_t
*mpo_kext_check_load
;
6518 mpo_kext_check_unload_t
*mpo_kext_check_unload
;
6520 mpo_proc_check_proc_info_t
*mpo_proc_check_proc_info
;
6521 mpo_vnode_notify_link_t
*mpo_vnode_notify_link
;
6522 mpo_iokit_check_filter_properties_t
*mpo_iokit_check_filter_properties
;
6523 mpo_iokit_check_get_property_t
*mpo_iokit_check_get_property
;
6527 @brief MAC policy handle type
6529 The MAC handle is used to uniquely identify a loaded policy within
6532 A variable of this type is set by mac_policy_register().
6534 typedef unsigned int mac_policy_handle_t
;
6536 #define mpc_t struct mac_policy_conf *
6539 @brief Mac policy configuration
6541 This structure specifies the configuration information for a
6542 MAC policy module. A policy module developer must supply
6543 a short unique policy name, a more descriptive full name, a list of label
6544 namespaces and count, a pointer to the registered enty point operations,
6545 any load time flags, and optionally, a pointer to a label slot identifier.
6547 The Framework will update the runtime flags (mpc_runtime_flags) to
6548 indicate that the module has been registered.
6550 If the label slot identifier (mpc_field_off) is NULL, the Framework
6551 will not provide label storage for the policy. Otherwise, the
6552 Framework will store the label location (slot) in this field.
6554 The mpc_list field is used by the Framework and should not be
6555 modified by policies.
6557 /* XXX - reorder these for better aligment on 64bit platforms */
6558 struct mac_policy_conf
{
6559 const char *mpc_name
; /** policy name */
6560 const char *mpc_fullname
; /** full name */
6561 const char **mpc_labelnames
; /** managed label namespaces */
6562 unsigned int mpc_labelname_count
; /** number of managed label namespaces */
6563 struct mac_policy_ops
*mpc_ops
; /** operation vector */
6564 int mpc_loadtime_flags
; /** load time flags */
6565 int *mpc_field_off
; /** label slot */
6566 int mpc_runtime_flags
; /** run time flags */
6567 mpc_t mpc_list
; /** List reference */
6568 void *mpc_data
; /** module data */
6572 @brief MAC policy module registration routine
6574 This function is called to register a policy with the
6575 MAC framework. A policy module will typically call this from the
6576 Darwin KEXT registration routine.
6578 int mac_policy_register(struct mac_policy_conf
*mpc
,
6579 mac_policy_handle_t
*handlep
, void *xd
);
6582 @brief MAC policy module de-registration routine
6584 This function is called to de-register a policy with theD
6585 MAC framework. A policy module will typically call this from the
6586 Darwin KEXT de-registration routine.
6588 int mac_policy_unregister(mac_policy_handle_t handle
);
6591 * Framework entry points for the policies to add audit data.
6593 int mac_audit_text(char *text
, mac_policy_handle_t handle
);
6596 * Calls to assist with use of Apple XATTRs within policy modules.
6598 int mac_vnop_setxattr(struct vnode
*, const char *, char *, size_t);
6599 int mac_vnop_getxattr(struct vnode
*, const char *, char *, size_t,
6601 int mac_vnop_removexattr(struct vnode
*, const char *);
6604 @brief Set an extended attribute on a vnode-based fileglob.
6605 @param fg fileglob representing file to attach the extended attribute
6606 @param name extended attribute name
6607 @param buf buffer of data to use as the extended attribute value
6608 @param len size of buffer
6610 Sets the value of an extended attribute on a file.
6612 Caller must hold an iocount on the vnode represented by the fileglob.
6614 int mac_file_setxattr(struct fileglob
*fg
, const char *name
, char *buf
, size_t len
);
6617 @brief Get an extended attribute from a vnode-based fileglob.
6618 @param fg fileglob representing file to read the extended attribute
6619 @param name extended attribute name
6620 @param buf buffer of data to hold the extended attribute value
6621 @param len size of buffer
6622 @param attrlen size of full extended attribute value
6624 Gets the value of an extended attribute on a file.
6626 Caller must hold an iocount on the vnode represented by the fileglob.
6628 int mac_file_getxattr(struct fileglob
*fg
, const char *name
, char *buf
, size_t len
,
6632 @brief Remove an extended attribute from a vnode-based fileglob.
6633 @param fg fileglob representing file to remove the extended attribute
6634 @param name extended attribute name
6636 Removes the named extended attribute from the file.
6638 Caller must hold an iocount on the vnode represented by the fileglob.
6640 int mac_file_removexattr(struct fileglob
*fg
, const char *name
);
6644 * Arbitrary limit on how much data will be logged by the audit
6645 * entry points above.
6647 #define MAC_AUDIT_DATA_LIMIT 1024
6650 * Values returned by mac_audit_{pre,post}select. To combine the responses
6651 * of the security policies into a single decision,
6652 * mac_audit_{pre,post}select() choose the greatest value returned.
6654 #define MAC_AUDIT_DEFAULT 0 /* use system behavior */
6655 #define MAC_AUDIT_NO 1 /* force not auditing this event */
6656 #define MAC_AUDIT_YES 2 /* force auditing this event */
6658 // \defgroup mpc_loadtime_flags Flags for the mpc_loadtime_flags field
6661 @name Flags for the mpc_loadtime_flags field
6662 @see mac_policy_conf
6664 This is the complete list of flags that are supported by the
6665 mpc_loadtime_flags field of the mac_policy_conf structure. These
6666 flags specify the load time behavior of MAC Framework policy
6673 @brief Flag to indicate registration preference
6675 This flag indicates that the policy module must be loaded and
6676 initialized early in the boot process. If the flag is specified,
6677 attempts to register the module following boot will be rejected. The
6678 flag may be used by policies that require pervasive labeling of all
6679 system objects, and cannot handle objects that have not been
6680 properly initialized by the policy.
6682 #define MPC_LOADTIME_FLAG_NOTLATE 0x00000001
6685 @brief Flag to indicate unload preference
6687 This flag indicates that the policy module may be unloaded. If this
6688 flag is not set, then the policy framework will reject requests to
6689 unload the module. This flag might be used by modules that allocate
6690 label state and are unable to free that state at runtime, or for
6691 modules that simply do not want to permit unload operations.
6693 #define MPC_LOADTIME_FLAG_UNLOADOK 0x00000002
6698 XXX This flag is not yet supported.
6700 #define MPC_LOADTIME_FLAG_LABELMBUFS 0x00000004
6703 @brief Flag to indicate a base policy
6705 This flag indicates that the policy module is a base policy. Only
6706 one module can declare itself as base, otherwise the boot process
6709 #define MPC_LOADTIME_BASE_POLICY 0x00000008
6714 @brief Policy registration flag
6715 @see mac_policy_conf
6717 This flag indicates that the policy module has been successfully
6718 registered with the TrustedBSD MAC Framework. The Framework will
6719 set this flag in the mpc_runtime_flags field of the policy's
6720 mac_policy_conf structure after registering the policy.
6722 #define MPC_RUNTIME_FLAG_REGISTERED 0x00000001
6725 * Depends on POLICY_VER
6729 #define POLICY_VER 1.0
6732 #define MAC_POLICY_SET(handle, mpops, mpname, mpfullname, lnames, lcount, slot, lflags, rflags) \
6733 static struct mac_policy_conf mpname##_mac_policy_conf = { \
6734 .mpc_name = #mpname, \
6735 .mpc_fullname = mpfullname, \
6736 .mpc_labelnames = lnames, \
6737 .mpc_labelname_count = lcount, \
6739 .mpc_loadtime_flags = lflags, \
6740 .mpc_field_off = slot, \
6741 .mpc_runtime_flags = rflags \
6744 static kern_return_t \
6745 kmod_start(kmod_info_t *ki, void *xd) \
6747 return mac_policy_register(&mpname##_mac_policy_conf, \
6751 static kern_return_t \
6752 kmod_stop(kmod_info_t *ki, void *xd) \
6754 return mac_policy_unregister(handle); \
6757 extern kern_return_t _start(kmod_info_t *ki, void *data); \
6758 extern kern_return_t _stop(kmod_info_t *ki, void *data); \
6760 KMOD_EXPLICIT_DECL(security.mpname, POLICY_VER, _start, _stop) \
6761 kmod_start_func_t *_realmain = kmod_start; \
6762 kmod_stop_func_t *_antimain = kmod_stop; \
6763 int _kext_apple_cc = __APPLE_CC__
6766 #define LABEL_TO_SLOT(l, s) (l)->l_perpolicy[s]
6769 * Policy interface to map a struct label pointer to per-policy data.
6770 * Typically, policies wrap this in their own accessor macro that casts an
6771 * intptr_t to a policy-specific data type.
6773 intptr_t mac_label_get(struct label
*l
, int slot
);
6774 void mac_label_set(struct label
*l
, int slot
, intptr_t v
);
6776 #define mac_get_mpc(h) (mac_policy_list.entries[h].mpc)
6779 @name Flags for MAC allocator interfaces
6781 These flags are passed to the Darwin kernel allocator routines to
6782 indicate whether the allocation is permitted to block or not.
6783 Caution should be taken; some operations are not permitted to sleep,
6784 and some types of locks cannot be held when sleeping.
6790 @brief Allocation operations may block
6792 If memory is not immediately available, the allocation routine
6793 will block (typically sleeping) until memory is available.
6795 @warning Inappropriate use of this flag may cause kernel panics.
6797 #define MAC_WAITOK 0
6800 @brief Allocation operations may not block
6802 Rather than blocking, the allocator may return an error if memory
6803 is not immediately available. This type of allocation will not
6804 sleep, preserving locking semantics.
6806 #define MAC_NOWAIT 1
6810 #endif /* !_SECURITY_MAC_POLICY_H_ */