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.
1741 @note Policies may change the contents of vfa to alter the list of
1742 file system attributes returned.
1745 typedef int mpo_mount_check_getattr_t(
1748 struct label
*mp_label
,
1749 struct vfs_attr
*vfa
1752 @brief Access control check for mount point relabeling
1753 @param cred Subject credential
1754 @param mp Object file system mount point
1755 @param mntlabel Policy label for fle system mount point
1757 Determine whether the subject identified by the credential can relabel
1758 the mount point. This call is made when a file system mount is updated.
1760 @return Return 0 if access is granted, otherwise an appropriate value for
1761 errno should be returned. Suggested failure: EACCES for label mismatch
1762 or EPERM for lack of privilege.
1764 typedef int mpo_mount_check_label_update_t(
1767 struct label
*mntlabel
1770 @brief Access control check for mounting a file system
1771 @param cred Subject credential
1772 @param vp Vnode that is to be the mount point
1773 @param vlabel Label associated with the vnode
1774 @param cnp Component name for vp
1775 @param vfc_name Filesystem type name
1777 Determine whether the subject identified by the credential can perform
1778 the mount operation on the target vnode.
1780 @return Return 0 if access is granted, otherwise an appropriate value for
1781 errno should be returned.
1783 typedef int mpo_mount_check_mount_t(
1786 struct label
*vlabel
,
1787 struct componentname
*cnp
,
1788 const char *vfc_name
1791 @brief Access control check for fs_snapshot_create
1792 @param cred Subject credential
1793 @mp Filesystem mount point to create snapshot of
1794 @name Name of snapshot to create
1796 Determine whether the subject identified by the credential can
1797 create a snapshot of the filesystem at the given mount point.
1799 @return Return 0 if access is granted, otherwise an appropriate value
1800 for errno should be returned.
1802 typedef int mpo_mount_check_snapshot_create_t(
1808 @brief Access control check for fs_snapshot_delete
1809 @param cred Subject credential
1810 @mp Filesystem mount point to delete snapshot of
1811 @name Name of snapshot to delete
1813 Determine whether the subject identified by the credential can
1814 delete the named snapshot from the filesystem at the given
1817 @return Return 0 if access is granted, otherwise an appropriate value
1818 for errno should be returned.
1820 typedef int mpo_mount_check_snapshot_delete_t(
1826 @brief Access control check for fs_snapshot_revert
1827 @param cred Subject credential
1828 @mp Filesystem mount point to revert to snapshot
1829 @name Name of snapshot to revert to
1831 Determine whether the subject identified by the credential can
1832 revert the filesystem at the given mount point to the named snapshot.
1834 @return Return 0 if access is granted, otherwise an appropriate value
1835 for errno should be returned.
1837 typedef int mpo_mount_check_snapshot_revert_t(
1843 @brief Access control check remounting a filesystem
1844 @param cred Subject credential
1845 @param mp The mount point
1846 @param mlabel Label currently associated with the mount point
1848 Determine whether the subject identified by the credential can perform
1849 the remount operation on the target vnode.
1851 @return Return 0 if access is granted, otherwise an appropriate value for
1852 errno should be returned.
1854 typedef int mpo_mount_check_remount_t(
1857 struct label
*mlabel
1860 @brief Access control check for the settting of file system attributes
1861 @param cred Subject credential
1862 @param mp The mount structure of the file system
1863 @param vfa The attributes requested
1865 This entry point determines whether given subject can set information
1866 about the given file system, for example the volume name.
1868 @return Return 0 if access is granted, otherwise an appropriate value for
1869 errno should be returned.
1872 typedef int mpo_mount_check_setattr_t(
1875 struct label
*mp_label
,
1876 struct vfs_attr
*vfa
1879 @brief Access control check for file system statistics
1880 @param cred Subject credential
1881 @param mp Object file system mount
1882 @param mntlabel Policy label for mp
1884 Determine whether the subject identified by the credential can see
1885 the results of a statfs performed on the file system. This call may
1886 be made in a number of situations, including during invocations of
1887 statfs(2) and related calls, as well as to determine what file systems
1888 to exclude from listings of file systems, such as when getfsstat(2)
1891 @return Return 0 if access is granted, otherwise an appropriate value for
1892 errno should be returned. Suggested failure: EACCES for label mismatch
1893 or EPERM for lack of privilege.
1895 typedef int mpo_mount_check_stat_t(
1898 struct label
*mntlabel
1901 @brief Access control check for unmounting a filesystem
1902 @param cred Subject credential
1903 @param mp The mount point
1904 @param mlabel Label associated with the mount point
1906 Determine whether the subject identified by the credential can perform
1907 the unmount operation on the target vnode.
1909 @return Return 0 if access is granted, otherwise an appropriate value for
1910 errno should be returned.
1912 typedef int mpo_mount_check_umount_t(
1915 struct label
*mlabel
1918 @brief Create mount labels
1919 @param cred Subject credential
1920 @param mp Mount point of file system being mounted
1921 @param mntlabel Label to associate with the new mount point
1922 @see mpo_mount_label_init_t
1924 Fill out the labels on the mount point being created by the supplied
1925 user credential. This call is made when file systems are first mounted.
1927 typedef void mpo_mount_label_associate_t(
1930 struct label
*mntlabel
1933 @brief Destroy mount label
1934 @param label The label to be destroyed
1936 Destroy a file system mount label. Since the
1937 object is going out of scope, policy modules should free any
1938 internal storage associated with the label so that it may be
1941 typedef void mpo_mount_label_destroy_t(
1945 @brief Externalize a mount point label
1946 @param label Label to be externalized
1947 @param element_name Name of the label namespace for which labels should be
1949 @param sb String buffer to be filled with a text representation of the label
1951 Produce an external representation of the mount point label. An
1952 externalized label consists of a text representation of the label
1953 contents that can be used with user applications. Policy-agnostic
1954 user space tools will display this externalized version.
1956 The policy's externalize entry points will be called only if the
1957 policy has registered interest in the label namespace.
1959 @return 0 on success, return non-zero if an error occurs while
1960 externalizing the label data.
1963 typedef int mpo_mount_label_externalize_t(
1964 struct label
*label
,
1969 @brief Initialize mount point label
1970 @param label New label to initialize
1972 Initialize the label for a newly instantiated mount structure.
1973 This label is typically used to store a default label in the case
1974 that the file system has been mounted singlelabel. Since some
1975 file systems do not support persistent labels (extended attributes)
1976 or are read-only (such as CD-ROMs), it is often necessary to store
1977 a default label separately from the label of the mount point
1978 itself. Sleeping is permitted.
1980 typedef void mpo_mount_label_init_t(
1984 @brief Internalize a mount point label
1985 @param label Label to be internalized
1986 @param element_name Name of the label namespace for which the label should
1988 @param element_data Text data to be internalized
1990 Produce a mount point file system label from an external representation.
1991 An externalized label consists of a text representation of the label
1992 contents that can be used with user applications. Policy-agnostic
1993 user space tools will forward text version to the kernel for
1994 processing by individual policy modules.
1996 The policy's internalize entry points will be called only if the
1997 policy has registered interest in the label namespace.
1999 @return 0 on success, Otherwise, return non-zero if an error occurs
2000 while internalizing the label data.
2003 typedef int mpo_mount_label_internalize_t(
2004 struct label
*label
,
2009 @brief Set the label on an IPv4 datagram fragment
2010 @param datagram Datagram being fragmented
2011 @param datagramlabel Policy label for datagram
2012 @param fragment New fragment
2013 @param fragmentlabel Policy label for fragment
2015 Called when an IPv4 datagram is fragmented into several smaller datagrams.
2016 Policies implementing mbuf labels will typically copy the label from the
2017 source datagram to the new fragment.
2019 typedef void mpo_netinet_fragment_t(
2020 struct mbuf
*datagram
,
2021 struct label
*datagramlabel
,
2022 struct mbuf
*fragment
,
2023 struct label
*fragmentlabel
2026 @brief Set the label on an ICMP reply
2027 @param m mbuf containing the ICMP reply
2028 @param mlabel Policy label for m
2030 A policy may wish to update the label of an mbuf that refers to
2031 an ICMP packet being sent in response to an IP packet. This may
2032 be called in response to a bad packet or an ICMP request.
2034 typedef void mpo_netinet_icmp_reply_t(
2036 struct label
*mlabel
2039 @brief Set the label on a TCP reply
2040 @param m mbuf containing the TCP reply
2041 @param mlabel Policy label for m
2043 Called for outgoing TCP packets not associated with an actual socket.
2045 typedef void mpo_netinet_tcp_reply_t(
2047 struct label
*mlabel
2050 @brief Access control check for pipe ioctl
2051 @param cred Subject credential
2052 @param cpipe Object to be accessed
2053 @param pipelabel The label on the pipe
2054 @param cmd The ioctl command; see ioctl(2)
2056 Determine whether the subject identified by the credential can perform
2057 the ioctl operation indicated by cmd.
2059 @warning Since ioctl data is opaque from the standpoint of the MAC
2060 framework, policies must exercise extreme care when implementing
2061 access control checks.
2063 @return Return 0 if access is granted, otherwise an appropriate value for
2064 errno should be returned.
2067 typedef int mpo_pipe_check_ioctl_t(
2070 struct label
*pipelabel
,
2074 @brief Access control check for pipe kqfilter
2075 @param cred Subject credential
2076 @param kn Object knote
2077 @param cpipe Object to be accessed
2078 @param pipelabel Policy label for the pipe
2080 Determine whether the subject identified by the credential can
2081 receive the knote on the passed pipe.
2083 @return Return 0 if access if granted, otherwise an appropriate
2084 value for errno should be returned.
2086 typedef int mpo_pipe_check_kqfilter_t(
2090 struct label
*pipelabel
2093 @brief Access control check for pipe relabel
2094 @param cred Subject credential
2095 @param cpipe Object to be accessed
2096 @param pipelabel The current label on the pipe
2097 @param newlabel The new label to be used
2099 Determine whether the subject identified by the credential can
2100 perform a relabel 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_label_update_t(
2110 struct label
*pipelabel
,
2111 struct label
*newlabel
2114 @brief Access control check for pipe read
2115 @param cred Subject credential
2116 @param cpipe Object to be accessed
2117 @param pipelabel The label on the pipe
2119 Determine whether the subject identified by the credential can
2120 perform a read 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_read_t(
2130 struct label
*pipelabel
2133 @brief Access control check for pipe select
2134 @param cred Subject credential
2135 @param cpipe Object to be accessed
2136 @param pipelabel The label on the pipe
2137 @param which The operation selected on: FREAD or FWRITE
2139 Determine whether the subject identified by the credential can
2140 perform a select 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_select_t(
2150 struct label
*pipelabel
,
2154 @brief Access control check for pipe stat
2155 @param cred Subject credential
2156 @param cpipe Object to be accessed
2157 @param pipelabel The label on the pipe
2159 Determine whether the subject identified by the credential can
2160 perform a stat operation on the passed pipe. The cred object holds
2161 the credentials of the subject performing the operation.
2163 @return Return 0 if access is granted, otherwise an appropriate value for
2164 errno should be returned.
2167 typedef int mpo_pipe_check_stat_t(
2170 struct label
*pipelabel
2173 @brief Access control check for pipe write
2174 @param cred Subject credential
2175 @param cpipe Object to be accessed
2176 @param pipelabel The label on the pipe
2178 Determine whether the subject identified by the credential can
2179 perform a write operation on the passed pipe. The cred object holds
2180 the credentials of the subject performing the operation.
2182 @return Return 0 if access is granted, otherwise an appropriate value for
2183 errno should be returned.
2186 typedef int mpo_pipe_check_write_t(
2189 struct label
*pipelabel
2192 @brief Create a pipe label
2193 @param cred Subject credential
2194 @param cpipe object to be labeled
2195 @param pipelabel Label for the pipe object
2197 Create a label for the pipe object being created by the supplied
2198 user credential. This call is made when the pipe is being created
2199 XXXPIPE(for one or both sides of the pipe?).
2202 typedef void mpo_pipe_label_associate_t(
2205 struct label
*pipelabel
2208 @brief Copy a pipe label
2209 @param src Source pipe label
2210 @param dest Destination pipe label
2212 Copy the pipe label associated with src to dest.
2213 XXXPIPE Describe when this is used: most likely during pipe creation to
2214 copy from rpipe to wpipe.
2216 typedef void mpo_pipe_label_copy_t(
2221 @brief Destroy pipe label
2222 @param label The label to be destroyed
2224 Destroy a pipe label. Since the object is going out of scope,
2225 policy modules should free any internal storage associated with the
2226 label so that it may be destroyed.
2228 typedef void mpo_pipe_label_destroy_t(
2232 @brief Externalize a pipe label
2233 @param label Label to be externalized
2234 @param element_name Name of the label namespace for which labels should be
2236 @param sb String buffer to be filled with a text representation of the label
2238 Produce an external representation of the label on a pipe.
2239 An externalized label consists of a text representation
2240 of the label contents that can be used with user applications.
2241 Policy-agnostic user space tools will display this externalized
2244 The policy's externalize entry points will be called only if the
2245 policy has registered interest in the label namespace.
2247 @return 0 on success, return non-zero if an error occurs while
2248 externalizing the label data.
2251 typedef int mpo_pipe_label_externalize_t(
2252 struct label
*label
,
2257 @brief Initialize pipe label
2258 @param label New label to initialize
2260 Initialize label storage for use with a newly instantiated pipe object.
2261 Sleeping is permitted.
2263 typedef void mpo_pipe_label_init_t(
2267 @brief Internalize a pipe label
2268 @param label Label to be internalized
2269 @param element_name Name of the label namespace for which the label should
2271 @param element_data Text data to be internalized
2273 Produce a pipe label from an external representation. An
2274 externalized label consists of a text representation of the label
2275 contents that can be used with user applications. Policy-agnostic
2276 user space tools will forward text version to the kernel for
2277 processing by individual policy modules.
2279 The policy's internalize entry points will be called only if the
2280 policy has registered interest in the label namespace.
2282 @return 0 on success, Otherwise, return non-zero if an error occurs
2283 while internalizing the label data.
2286 typedef int mpo_pipe_label_internalize_t(
2287 struct label
*label
,
2292 @brief Update a pipe label
2293 @param cred Subject credential
2294 @param cpipe Object to be labeled
2295 @param oldlabel Existing pipe label
2296 @param newlabel New label to replace existing label
2297 @see mpo_pipe_check_label_update_t
2299 The subject identified by the credential has previously requested
2300 and was authorized to relabel the pipe; this entry point allows
2301 policies to perform the actual relabel operation. Policies should
2302 update oldlabel using the label stored in the newlabel parameter.
2305 typedef void mpo_pipe_label_update_t(
2308 struct label
*oldlabel
,
2309 struct label
*newlabel
2312 @brief Policy unload event
2313 @param mpc MAC policy configuration
2315 This is the MAC Framework policy unload event. This entry point will
2316 only be called if the module's policy configuration allows unload (if
2317 the MPC_LOADTIME_FLAG_UNLOADOK is set). Most security policies won't
2318 want to be unloaded; they should set their flags to prevent this
2319 entry point from being called.
2321 @warning During this call, the mac policy list mutex is held, so
2322 sleep operations cannot be performed, and calls out to other kernel
2323 subsystems must be made with caution.
2325 @see MPC_LOADTIME_FLAG_UNLOADOK
2327 typedef void mpo_policy_destroy_t(
2328 struct mac_policy_conf
*mpc
2331 @brief Policy initialization event
2332 @param mpc MAC policy configuration
2333 @see mac_policy_register
2334 @see mpo_policy_initbsd_t
2336 This is the MAC Framework policy initialization event. This entry
2337 point is called during mac_policy_register, when the policy module
2338 is first registered with the MAC Framework. This is often done very
2339 early in the boot process, after the kernel Mach subsystem has been
2340 initialized, but prior to the BSD subsystem being initialized.
2341 Since the kernel BSD services are not yet available, it is possible
2342 that some initialization must occur later, possibly in the
2343 mpo_policy_initbsd_t policy entry point, such as registering BSD system
2344 controls (sysctls). Policy modules loaded at boot time will be
2345 registered and initialized before labeled Mach objects are created.
2347 @warning During this call, the mac policy list mutex is held, so
2348 sleep operations cannot be performed, and calls out to other kernel
2349 subsystems must be made with caution.
2351 typedef void mpo_policy_init_t(
2352 struct mac_policy_conf
*mpc
2355 @brief Policy BSD initialization event
2356 @param mpc MAC policy configuration
2357 @see mpo_policy_init_t
2359 This entry point is called after the kernel BSD subsystem has been
2360 initialized. By this point, the module should already be loaded,
2361 registered, and initialized. Since policy modules are initialized
2362 before kernel BSD services are available, this second initialization
2363 phase is necessary. At this point, BSD services (memory management,
2364 synchronization primitives, vfs, etc.) are available, but the first
2365 process has not yet been created. Mach-related objects and tasks
2366 will already be fully initialized and may be in use--policies requiring
2367 ubiquitous labeling may also want to implement mpo_policy_init_t.
2369 @warning During this call, the mac policy list mutex is held, so
2370 sleep operations cannot be performed, and calls out to other kernel
2371 subsystems must be made with caution.
2373 typedef void mpo_policy_initbsd_t(
2374 struct mac_policy_conf
*mpc
2377 @brief Policy extension service
2378 @param p Calling process
2379 @param call Policy-specific syscall number
2380 @param arg Pointer to syscall arguments
2382 This entry point provides a policy-multiplexed system call so that
2383 policies may provide additional services to user processes without
2384 registering specific system calls. The policy name provided during
2385 registration is used to demux calls from userland, and the arguments
2386 will be forwarded to this entry point. When implementing new
2387 services, security modules should be sure to invoke appropriate
2388 access control checks from the MAC framework as needed. For
2389 example, if a policy implements an augmented signal functionality,
2390 it should call the necessary signal access control checks to invoke
2391 the MAC framework and other registered policies.
2393 @warning Since the format and contents of the policy-specific
2394 arguments are unknown to the MAC Framework, modules must perform the
2395 required copyin() of the syscall data on their own. No policy
2396 mediation is performed, so policies must perform any necessary
2397 access control checks themselves. If multiple policies are loaded,
2398 they will currently be unable to mediate calls to other policies.
2400 @return In the event of an error, an appropriate value for errno
2401 should be returned, otherwise return 0 upon success.
2403 typedef int mpo_policy_syscall_t(
2409 @brief Access control check for POSIX semaphore create
2410 @param cred Subject credential
2411 @param name String name of the semaphore
2413 Determine whether the subject identified by the credential can create
2414 a POSIX semaphore specified by name.
2416 @return Return 0 if access is granted, otherwise an appropriate value for
2417 errno should be returned.
2419 typedef int mpo_posixsem_check_create_t(
2424 @brief Access control check for POSIX semaphore open
2425 @param cred Subject credential
2426 @param ps Pointer to semaphore information structure
2427 @param semlabel Label associated with the semaphore
2429 Determine whether the subject identified by the credential can open
2430 the named POSIX semaphore with label semlabel.
2432 @return Return 0 if access is granted, otherwise an appropriate value for
2433 errno should be returned.
2435 typedef int mpo_posixsem_check_open_t(
2437 struct pseminfo
*ps
,
2438 struct label
*semlabel
2441 @brief Access control check for POSIX semaphore post
2442 @param cred Subject credential
2443 @param ps Pointer to semaphore information structure
2444 @param semlabel Label associated with the semaphore
2446 Determine whether the subject identified by the credential can unlock
2447 the named POSIX semaphore with label semlabel.
2449 @return Return 0 if access is granted, otherwise an appropriate value for
2450 errno should be returned.
2452 typedef int mpo_posixsem_check_post_t(
2454 struct pseminfo
*ps
,
2455 struct label
*semlabel
2458 @brief Access control check for POSIX semaphore unlink
2459 @param cred Subject credential
2460 @param ps Pointer to semaphore information structure
2461 @param semlabel Label associated with the semaphore
2462 @param name String name of the semaphore
2464 Determine whether the subject identified by the credential can remove
2465 the named POSIX semaphore with label semlabel.
2467 @return Return 0 if access is granted, otherwise an appropriate value for
2468 errno should be returned.
2470 typedef int mpo_posixsem_check_unlink_t(
2472 struct pseminfo
*ps
,
2473 struct label
*semlabel
,
2477 @brief Access control check for POSIX semaphore wait
2478 @param cred Subject credential
2479 @param ps Pointer to semaphore information structure
2480 @param semlabel Label associated with the semaphore
2482 Determine whether the subject identified by the credential can lock
2483 the named POSIX semaphore with label semlabel.
2485 @return Return 0 if access is granted, otherwise an appropriate value for
2486 errno should be returned.
2488 typedef int mpo_posixsem_check_wait_t(
2490 struct pseminfo
*ps
,
2491 struct label
*semlabel
2494 @brief Create a POSIX semaphore label
2495 @param cred Subject credential
2496 @param ps Pointer to semaphore information structure
2497 @param semlabel Label to associate with the new semaphore
2498 @param name String name of the semaphore
2500 Label a new POSIX semaphore. The label was previously
2501 initialized and associated with the semaphore. At this time, an
2502 appropriate initial label value should be assigned to the object and
2503 stored in semalabel.
2505 typedef void mpo_posixsem_label_associate_t(
2507 struct pseminfo
*ps
,
2508 struct label
*semlabel
,
2512 @brief Destroy POSIX semaphore label
2513 @param label The label to be destroyed
2515 Destroy a POSIX semaphore label. Since the object is
2516 going out of scope, policy modules should free any internal storage
2517 associated with the label so that it may be destroyed.
2519 typedef void mpo_posixsem_label_destroy_t(
2523 @brief Initialize POSIX semaphore label
2524 @param label New label to initialize
2526 Initialize the label for a newly instantiated POSIX semaphore. Sleeping
2529 typedef void mpo_posixsem_label_init_t(
2533 @brief Access control check for POSIX shared memory region create
2534 @param cred Subject credential
2535 @param name String name of the shared memory region
2537 Determine whether the subject identified by the credential can create
2538 the POSIX shared memory region referenced by name.
2540 @return Return 0 if access is granted, otherwise an appropriate value for
2541 errno should be returned.
2543 typedef int mpo_posixshm_check_create_t(
2548 @brief Access control check for mapping POSIX shared memory
2549 @param cred Subject credential
2550 @param ps Pointer to shared memory information structure
2551 @param shmlabel Label associated with the shared memory region
2552 @param prot mmap protections; see mmap(2)
2553 @param flags shmat flags; see shmat(2)
2555 Determine whether the subject identified by the credential can map
2556 the POSIX shared memory segment associated with shmlabel.
2558 @return Return 0 if access is granted, otherwise an appropriate value for
2559 errno should be returned.
2561 typedef int mpo_posixshm_check_mmap_t(
2563 struct pshminfo
*ps
,
2564 struct label
*shmlabel
,
2569 @brief Access control check for POSIX shared memory region open
2570 @param cred Subject credential
2571 @param ps Pointer to shared memory information structure
2572 @param shmlabel Label associated with the shared memory region
2573 @param fflags shm_open(2) open flags ('fflags' encoded)
2575 Determine whether the subject identified by the credential can open
2576 the POSIX shared memory region.
2578 @return Return 0 if access is granted, otherwise an appropriate value for
2579 errno should be returned.
2581 typedef int mpo_posixshm_check_open_t(
2583 struct pshminfo
*ps
,
2584 struct label
*shmlabel
,
2588 @brief Access control check for POSIX shared memory stat
2589 @param cred Subject credential
2590 @param ps Pointer to shared memory information structure
2591 @param shmlabel Label associated with the shared memory region
2593 Determine whether the subject identified by the credential can obtain
2594 status for the POSIX shared memory segment associated with shmlabel.
2596 @return Return 0 if access is granted, otherwise an appropriate value for
2597 errno should be returned.
2599 typedef int mpo_posixshm_check_stat_t(
2601 struct pshminfo
*ps
,
2602 struct label
*shmlabel
2605 @brief Access control check for POSIX shared memory truncate
2606 @param cred Subject credential
2607 @param ps Pointer to shared memory information structure
2608 @param shmlabel Label associated with the shared memory region
2609 @param len Length to truncate or extend shared memory segment
2611 Determine whether the subject identified by the credential can truncate
2612 or extend (to len) the POSIX shared memory segment associated with shmlabel.
2614 @return Return 0 if access is granted, otherwise an appropriate value for
2615 errno should be returned.
2617 typedef int mpo_posixshm_check_truncate_t(
2619 struct pshminfo
*ps
,
2620 struct label
*shmlabel
,
2624 @brief Access control check for POSIX shared memory unlink
2625 @param cred Subject credential
2626 @param ps Pointer to shared memory information structure
2627 @param shmlabel Label associated with the shared memory region
2628 @param name String name of the shared memory region
2630 Determine whether the subject identified by the credential can delete
2631 the POSIX shared memory segment associated with shmlabel.
2633 @return Return 0 if access is granted, otherwise an appropriate value for
2634 errno should be returned.
2636 typedef int mpo_posixshm_check_unlink_t(
2638 struct pshminfo
*ps
,
2639 struct label
*shmlabel
,
2643 @brief Create a POSIX shared memory region label
2644 @param cred Subject credential
2645 @param ps Pointer to shared memory information structure
2646 @param shmlabel Label to associate with the new shared memory region
2647 @param name String name of the shared memory region
2649 Label a new POSIX shared memory region. The label was previously
2650 initialized and associated with the shared memory region. At this
2651 time, an appropriate initial label value should be assigned to the
2652 object and stored in shmlabel.
2654 typedef void mpo_posixshm_label_associate_t(
2656 struct pshminfo
*ps
,
2657 struct label
*shmlabel
,
2661 @brief Destroy POSIX shared memory label
2662 @param label The label to be destroyed
2664 Destroy a POSIX shared memory region label. Since the
2665 object is going out of scope, policy modules should free any
2666 internal storage associated with the label so that it may be
2669 typedef void mpo_posixshm_label_destroy_t(
2673 @brief Initialize POSIX Shared Memory region label
2674 @param label New label to initialize
2676 Initialize the label for newly a instantiated POSIX Shared Memory
2677 region. Sleeping is permitted.
2679 typedef void mpo_posixshm_label_init_t(
2683 @brief Access control check for privileged operations
2684 @param cred Subject credential
2685 @param priv Requested privilege (see sys/priv.h)
2687 Determine whether the subject identified by the credential can perform
2688 a privileged operation. Privileged operations are allowed if the cred
2689 is the superuser or any policy returns zero for mpo_priv_grant, unless
2690 any policy returns nonzero for mpo_priv_check.
2692 @return Return 0 if access is granted, otherwise EPERM should be returned.
2694 typedef int mpo_priv_check_t(
2699 @brief Grant regular users the ability to perform privileged operations
2700 @param cred Subject credential
2701 @param priv Requested privilege (see sys/priv.h)
2703 Determine whether the subject identified by the credential should be
2704 allowed to perform a privileged operation that in the absense of any
2705 MAC policy it would not be able to perform. Privileged operations are
2706 allowed if the cred is the superuser or any policy returns zero for
2707 mpo_priv_grant, unless any policy returns nonzero for mpo_priv_check.
2709 Unlike other MAC hooks which can only reduce the privilege of a
2710 credential, this hook raises the privilege of a credential when it
2711 returns 0. Extreme care must be taken when implementing this hook to
2712 avoid undermining the security of the system.
2714 @return Return 0 if additional privilege is granted, otherwise EPERM
2717 typedef int mpo_priv_grant_t(
2722 @brief Access control check for debugging process
2723 @param cred Subject credential
2724 @param proc Object process
2726 Determine whether the subject identified by the credential can debug
2727 the passed process. This call may be made in a number of situations,
2728 including use of the ptrace(2) and ktrace(2) APIs, as well as for some
2729 types of procfs operations.
2731 @return Return 0 if access is granted, otherwise an appropriate value for
2732 errno should be returned. Suggested failure: EACCES for label mismatch,
2733 EPERM for lack of privilege, or ESRCH to hide visibility of the target.
2735 typedef int mpo_proc_check_debug_t(
2740 @brief Access control over fork
2741 @param cred Subject credential
2742 @param proc Subject process trying to fork
2744 Determine whether the subject identified is allowed to fork.
2746 @return Return 0 if access is granted, otherwise an appropriate value for
2747 errno should be returned.
2749 typedef int mpo_proc_check_fork_t(
2754 @brief Access control check for setting host special ports.
2755 @param cred Subject credential
2756 @param id The host special port to set
2757 @param port The new value to set for the special port
2759 @return Return 0 if access is granted, otherwise an appropriate value for
2760 errno should be returned.
2762 typedef int mpo_proc_check_set_host_special_port_t(
2765 struct ipc_port
*port
2768 @brief Access control check for setting host exception ports.
2769 @param cred Subject credential
2770 @param exception Exception port to set
2772 @return Return 0 if access is granted, otherwise an appropriate value for
2773 errno should be returned.
2775 typedef int mpo_proc_check_set_host_exception_port_t(
2777 unsigned int exception
2780 @brief Access control over pid_suspend and pid_resume
2781 @param cred Subject credential
2782 @param proc Subject process trying to run pid_suspend or pid_resume
2783 @param sr Call is suspend (0) or resume (1)
2785 Determine whether the subject identified is allowed to suspend or resume
2788 @return Return 0 if access is granted, otherwise an appropriate value for
2789 errno should be returned.
2791 typedef int mpo_proc_check_suspend_resume_t(
2797 @brief Access control check for retrieving audit information
2798 @param cred Subject credential
2800 Determine whether the subject identified by the credential can get
2801 audit information such as the audit user ID, the preselection mask,
2802 the terminal ID and the audit session ID, using the getaudit() system call.
2804 @return Return 0 if access is granted, otherwise an appropriate value for
2805 errno should be returned.
2807 typedef int mpo_proc_check_getaudit_t(
2811 @brief Access control check for retrieving audit user ID
2812 @param cred Subject credential
2814 Determine whether the subject identified by the credential can get
2815 the user identity being used by the auditing system, using the getauid()
2818 @return Return 0 if access is granted, otherwise an appropriate value for
2819 errno should be returned.
2821 typedef int mpo_proc_check_getauid_t(
2825 @brief Access control check for retrieving Login Context ID
2826 @param p0 Calling process
2827 @param p Effected process
2828 @param pid syscall PID argument
2830 Determine if getlcid(2) system call is permitted.
2832 Information returned by this system call is similar to that returned via
2833 process listings etc.
2835 @return Return 0 if access is granted, otherwise an appropriate value for
2836 errno should be returned.
2838 typedef int mpo_proc_check_getlcid_t(
2844 @brief Access control check for retrieving ledger information
2845 @param cred Subject credential
2846 @param target Object process
2847 @param op ledger operation
2849 Determine if ledger(2) system call is permitted.
2851 Information returned by this system call is similar to that returned via
2852 process listings etc.
2854 @return Return 0 if access is granted, otherwise an appropriate value for
2855 errno should be returned.
2857 typedef int mpo_proc_check_ledger_t(
2859 struct proc
*target
,
2863 @brief Access control check for escaping default CPU usage monitor parameters.
2864 @param cred Subject credential
2866 Determine if a credential has permission to program CPU usage monitor parameters
2867 that are less restrictive than the global system-wide defaults.
2869 @return Return 0 if access is granted, otherwise an appropriate value for
2870 errno should be returned.
2872 typedef int mpo_proc_check_cpumon_t(
2876 @brief Access control check for retrieving process information.
2877 @param cred Subject credential
2878 @param target Target process (may be null, may be zombie)
2880 Determine if a credential has permission to access process information as defined
2881 by call number and flavor on target process
2883 @return Return 0 if access is granted, otherwise an appropriate value for
2884 errno should be returned.
2886 typedef int mpo_proc_check_proc_info_t(
2888 struct proc
*target
,
2893 @brief Access control check for retrieving code signing information.
2894 @param cred Subject credential
2895 @param target Target process
2896 @param op Code signing operation being performed
2898 Determine whether the subject identified by the credential should be
2899 allowed to get code signing information about the target process.
2901 @return Return 0 if access is granted, otherwise an appropriate value for
2902 errno should be returned.
2904 typedef int mpo_proc_check_get_cs_info_t(
2906 struct proc
*target
,
2910 @brief Access control check for setting code signing information.
2911 @param cred Subject credential
2912 @param target Target process
2913 @param op Code signing operation being performed.
2915 Determine whether the subject identified by the credential should be
2916 allowed to set code signing information about the target process.
2918 @return Return 0 if permission is granted, otherwise an appropriate
2919 value of errno should be returned.
2921 typedef int mpo_proc_check_set_cs_info_t(
2923 struct proc
*target
,
2927 @brief Access control check for mmap MAP_ANON
2928 @param proc User process requesting the memory
2929 @param cred Subject credential
2930 @param u_addr Start address of the memory range
2931 @param u_size Length address of the memory range
2932 @param prot mmap protections; see mmap(2)
2933 @param flags Type of mapped object; see mmap(2)
2934 @param maxprot Maximum rights
2936 Determine whether the subject identified by the credential should be
2937 allowed to obtain anonymous memory using the specified flags and
2938 protections on the new mapping. MAP_ANON will always be present in the
2939 flags. Certain combinations of flags with a non-NULL addr may
2940 cause a mapping to be rejected before this hook is called. The maxprot field
2941 holds the maximum permissions on the new mapping, a combination of
2942 VM_PROT_READ, VM_PROT_WRITE and VM_PROT_EXECUTE. To avoid overriding prior
2943 access control checks, a policy should only remove flags from maxprot.
2945 @return Return 0 if access is granted, otherwise an appropriate value for
2946 errno should be returned. Suggested failure: EPERM for lack of privilege.
2948 typedef int mpo_proc_check_map_anon_t(
2958 @brief Access control check for setting memory protections
2959 @param cred Subject credential
2960 @param proc User process requesting the change
2961 @param addr Start address of the memory range
2962 @param size Length address of the memory range
2963 @param prot Memory protections, see mmap(2)
2965 Determine whether the subject identified by the credential should
2966 be allowed to set the specified memory protections on memory mapped
2967 in the process proc.
2969 @return Return 0 if access is granted, otherwise an appropriate value for
2970 errno should be returned.
2972 typedef int mpo_proc_check_mprotect_t(
2980 @brief Access control check for changing scheduling parameters
2981 @param cred Subject credential
2982 @param proc Object process
2984 Determine whether the subject identified by the credential can change
2985 the scheduling parameters of the passed process.
2987 @return Return 0 if access is granted, otherwise an appropriate value for
2988 errno should be returned. Suggested failure: EACCES for label mismatch,
2989 EPERM for lack of privilege, or ESRCH to limit visibility.
2991 typedef int mpo_proc_check_sched_t(
2996 @brief Access control check for setting audit information
2997 @param cred Subject credential
2998 @param ai Audit information
3000 Determine whether the subject identified by the credential can set
3001 audit information such as the the preselection mask, the terminal ID
3002 and the audit session ID, using the setaudit() system call.
3004 @return Return 0 if access is granted, otherwise an appropriate value for
3005 errno should be returned.
3007 typedef int mpo_proc_check_setaudit_t(
3009 struct auditinfo_addr
*ai
3012 @brief Access control check for setting audit user ID
3013 @param cred Subject credential
3014 @param auid Audit user ID
3016 Determine whether the subject identified by the credential can set
3017 the user identity used by the auditing system, using the setauid()
3020 @return Return 0 if access is granted, otherwise an appropriate value for
3021 errno should be returned.
3023 typedef int mpo_proc_check_setauid_t(
3028 @brief Access control check for setting the Login Context
3029 @param p0 Calling process
3030 @param p Effected process
3031 @param pid syscall PID argument
3032 @param lcid syscall LCID argument
3034 Determine if setlcid(2) system call is permitted.
3036 See xnu/bsd/kern/kern_prot.c:setlcid() implementation for example of
3037 decoding syscall arguments to determine action desired by caller.
3039 Five distinct actions are possible: CREATE JOIN LEAVE ADOPT ORPHAN
3041 @return Return 0 if access is granted, otherwise an appropriate value for
3042 errno should be returned.
3044 typedef int mpo_proc_check_setlcid_t(
3051 @brief Access control check for delivering signal
3052 @param cred Subject credential
3053 @param proc Object process
3054 @param signum Signal number; see kill(2)
3056 Determine whether the subject identified by the credential can deliver
3057 the passed signal to the passed process.
3059 @warning Programs typically expect to be able to send and receive
3060 signals as part or their normal process lifecycle; caution should be
3061 exercised when implementing access controls over signal events.
3063 @return Return 0 if access is granted, otherwise an appropriate value for
3064 errno should be returned. Suggested failure: EACCES for label mismatch,
3065 EPERM for lack of privilege, or ESRCH to limit visibility.
3067 typedef int mpo_proc_check_signal_t(
3073 @brief Access control check for wait
3074 @param cred Subject credential
3075 @param proc Object process
3077 Determine whether the subject identified by the credential can wait
3078 for process termination.
3080 @warning Caution should be exercised when implementing access
3081 controls for wait, since programs often wait for child processes to
3082 exit. Failure to be notified of a child process terminating may
3083 cause the parent process to hang, or may produce zombie processes.
3085 @return Return 0 if access is granted, otherwise an appropriate value for
3086 errno should be returned.
3088 typedef int mpo_proc_check_wait_t(
3093 @brief Destroy process label
3094 @param label The label to be destroyed
3096 Destroy a process label. Since the object is going
3097 out of scope, policy modules should free any internal storage
3098 associated with the label so that it may be destroyed.
3100 typedef void mpo_proc_label_destroy_t(
3104 @brief Initialize process label
3105 @param label New label to initialize
3106 @see mpo_cred_label_init_t
3108 Initialize the label for a newly instantiated BSD process structure.
3109 Normally, security policies will store the process label in the user
3110 credential rather than here in the process structure. However,
3111 there are some floating label policies that may need to temporarily
3112 store a label in the process structure until it is safe to update
3113 the user credential label. Sleeping is permitted.
3115 typedef void mpo_proc_label_init_t(
3119 @brief Access control check for socket accept
3120 @param cred Subject credential
3121 @param so Object socket
3122 @param socklabel Policy label for socket
3124 Determine whether the subject identified by the credential can accept()
3125 a new connection on the socket from the host specified by addr.
3127 @return Return 0 if access if granted, otherwise an appropriate
3128 value for errno should be returned.
3130 typedef int mpo_socket_check_accept_t(
3133 struct label
*socklabel
3136 @brief Access control check for a pending socket accept
3137 @param cred Subject credential
3138 @param so Object socket
3139 @param socklabel Policy label for socket
3140 @param addr Address of the listening socket (coming soon)
3142 Determine whether the subject identified by the credential can accept()
3143 a pending connection on the socket from the host specified by addr.
3145 @return Return 0 if access if granted, otherwise an appropriate
3146 value for errno should be returned.
3148 typedef int mpo_socket_check_accepted_t(
3151 struct label
*socklabel
,
3152 struct sockaddr
*addr
3155 @brief Access control check for socket bind
3156 @param cred Subject credential
3157 @param so Object socket
3158 @param socklabel Policy label for socket
3159 @param addr Name to assign to the socket
3161 Determine whether the subject identified by the credential can bind()
3162 the name (addr) to the socket.
3164 @return Return 0 if access if granted, otherwise an appropriate
3165 value for errno should be returned.
3167 typedef int mpo_socket_check_bind_t(
3170 struct label
*socklabel
,
3171 struct sockaddr
*addr
3174 @brief Access control check for socket connect
3175 @param cred Subject credential
3176 @param so Object socket
3177 @param socklabel Policy label for socket
3178 @param addr Name to assign to the socket
3180 Determine whether the subject identified by the credential can
3181 connect() the passed socket to the remote host specified by addr.
3183 @return Return 0 if access if granted, otherwise an appropriate
3184 value for errno should be returned.
3186 typedef int mpo_socket_check_connect_t(
3189 struct label
*socklabel
,
3190 struct sockaddr
*addr
3193 @brief Access control check for socket() system call.
3194 @param cred Subject credential
3195 @param domain communication domain
3196 @param type socket type
3197 @param protocol socket protocol
3199 Determine whether the subject identified by the credential can
3200 make the socket() call.
3202 @return Return 0 if access if granted, otherwise an appropriate
3203 value for errno should be returned.
3205 typedef int mpo_socket_check_create_t(
3212 @brief Access control check for delivering data to a user's receieve queue
3213 @param so The socket data is being delivered to
3214 @param so_label The label of so
3215 @param m The mbuf whose data will be deposited into the receive queue
3216 @param m_label The label of the sender of the data.
3218 A socket has a queue for receiving incoming data. When a packet arrives
3219 on the wire, it eventually gets deposited into this queue, which the
3220 owner of the socket drains when they read from the socket's file descriptor.
3222 This function determines whether the socket can receive data from
3223 the sender specified by m_label.
3225 @warning There is an outstanding design issue surrounding the placement
3226 of this function. The check must be placed either before or after the
3227 TCP sequence and ACK counters are updated. Placing the check before
3228 the counters are updated causes the incoming packet to be resent by
3229 the remote if the check rejects it. Placing the check after the counters
3230 are updated results in a completely silent drop. As far as each TCP stack
3231 is concerned the packet was received, however, the data will not be in the
3232 socket's receive queue. Another consideration is that the current design
3233 requires using the "failed label" occasionally. In that case, on rejection,
3234 we want the remote TCP to resend the data. Because of this, we chose to
3235 place this check before the counters are updated, so rejected packets will be
3236 resent by the remote host.
3238 If a policy keeps rejecting the same packet, eventually the connection will
3239 be dropped. Policies have several options if this design causes problems.
3240 For example, one options is to sanitize the mbuf such that it is acceptable,
3241 then accept it. That may require negotiation between policies as the
3242 Framework will not know to re-check the packet.
3244 The policy must handle NULL MBUF labels. This will likely be the case
3245 for non-local TCP sockets for example.
3247 @return Return 0 if access if granted, otherwise an appropriate
3248 value for errno should be returned.
3250 typedef int mpo_socket_check_deliver_t(
3252 struct label
*so_label
,
3254 struct label
*m_label
3257 @brief Access control check for socket kqfilter
3258 @param cred Subject credential
3259 @param kn Object knote
3260 @param so Object socket
3261 @param socklabel Policy label for socket
3263 Determine whether the subject identified by the credential can
3264 receive the knote on the passed socket.
3266 @return Return 0 if access if granted, otherwise an appropriate
3267 value for errno should be returned.
3269 typedef int mpo_socket_check_kqfilter_t(
3273 struct label
*socklabel
3276 @brief Access control check for socket relabel
3277 @param cred Subject credential
3278 @param so Object socket
3279 @param so_label The current label of so
3280 @param newlabel The label to be assigned to so
3282 Determine whether the subject identified by the credential can
3283 change the label on the socket.
3285 @return Return 0 if access if granted, otherwise an appropriate
3286 value for errno should be returned.
3288 typedef int mpo_socket_check_label_update_t(
3291 struct label
*so_label
,
3292 struct label
*newlabel
3295 @brief Access control check for socket listen
3296 @param cred Subject credential
3297 @param so Object socket
3298 @param socklabel Policy label for socket
3300 Determine whether the subject identified by the credential can
3301 listen() on the passed socket.
3303 @return Return 0 if access if granted, otherwise an appropriate
3304 value for errno should be returned.
3306 typedef int mpo_socket_check_listen_t(
3309 struct label
*socklabel
3312 @brief Access control check for socket receive
3313 @param cred Subject credential
3314 @param so Object socket
3315 @param socklabel Policy label for socket
3317 Determine whether the subject identified by the credential can
3318 receive data from the socket.
3320 @return Return 0 if access if granted, otherwise an appropriate
3321 value for errno should be returned.
3323 typedef int mpo_socket_check_receive_t(
3326 struct label
*socklabel
3330 @brief Access control check for socket receive
3331 @param cred Subject credential
3332 @param sock Object socket
3333 @param socklabel Policy label for socket
3334 @param saddr Name of the remote socket
3336 Determine whether the subject identified by the credential can
3337 receive data from the remote host specified by addr.
3339 @return Return 0 if access if granted, otherwise an appropriate
3340 value for errno should be returned.
3342 typedef int mpo_socket_check_received_t(
3344 struct socket
*sock
,
3345 struct label
*socklabel
,
3346 struct sockaddr
*saddr
3351 @brief Access control check for socket select
3352 @param cred Subject credential
3353 @param so Object socket
3354 @param socklabel Policy label for socket
3355 @param which The operation selected on: FREAD or FWRITE
3357 Determine whether the subject identified by the credential can use the
3358 socket in a call to select().
3360 @return Return 0 if access if granted, otherwise an appropriate
3361 value for errno should be returned.
3363 typedef int mpo_socket_check_select_t(
3366 struct label
*socklabel
,
3370 @brief Access control check for socket send
3371 @param cred Subject credential
3372 @param so Object socket
3373 @param socklabel Policy label for socket
3374 @param addr Address being sent to
3376 Determine whether the subject identified by the credential can send
3379 @return Return 0 if access if granted, otherwise an appropriate
3380 value for errno should be returned.
3382 typedef int mpo_socket_check_send_t(
3385 struct label
*socklabel
,
3386 struct sockaddr
*addr
3389 @brief Access control check for retrieving socket status
3390 @param cred Subject credential
3391 @param so Object socket
3392 @param socklabel Policy label for so
3394 Determine whether the subject identified by the credential can
3395 execute the stat() system call on the given socket.
3397 @return Return 0 if access if granted, otherwise an appropriate
3398 value for errno should be returned.
3400 typedef int mpo_socket_check_stat_t(
3403 struct label
*socklabel
3406 @brief Access control check for setting socket options
3407 @param cred Subject credential
3408 @param so Object socket
3409 @param socklabel Policy label for so
3410 @param sopt The options being set
3412 Determine whether the subject identified by the credential can
3413 execute the setsockopt system call on the given socket.
3415 @return Return 0 if access if granted, otherwise an appropriate
3416 value for errno should be returned.
3418 typedef int mpo_socket_check_setsockopt_t(
3421 struct label
*socklabel
,
3422 struct sockopt
*sopt
3425 @brief Access control check for getting socket options
3426 @param cred Subject credential
3427 @param so Object socket
3428 @param socklabel Policy label for so
3429 @param sopt The options to get
3431 Determine whether the subject identified by the credential can
3432 execute the getsockopt system call on the given socket.
3434 @return Return 0 if access if granted, otherwise an appropriate
3435 value for errno should be returned.
3437 typedef int mpo_socket_check_getsockopt_t(
3440 struct label
*socklabel
,
3441 struct sockopt
*sopt
3444 @brief Label a socket
3445 @param oldsock Listening socket
3446 @param oldlabel Policy label associated with oldsock
3447 @param newsock New socket
3448 @param newlabel Policy label associated with newsock
3450 A new socket is created when a connection is accept(2)ed. This
3451 function labels the new socket based on the existing listen(2)ing
3454 typedef void mpo_socket_label_associate_accept_t(
3456 struct label
*oldlabel
,
3458 struct label
*newlabel
3461 @brief Assign a label to a new socket
3462 @param cred Credential of the owning process
3463 @param so The socket being labeled
3464 @param solabel The label
3465 @warning cred can be NULL
3467 Set the label on a newly created socket from the passed subject
3468 credential. This call is made when a socket is created. The
3469 credentials may be null if the socket is being created by the
3472 typedef void mpo_socket_label_associate_t(
3475 struct label
*solabel
3478 @brief Copy a socket label
3479 @param src Source label
3480 @param dest Destination label
3482 Copy the socket label information in src into dest.
3484 typedef void mpo_socket_label_copy_t(
3489 @brief Destroy socket label
3490 @param label The label to be destroyed
3492 Destroy a socket label. Since the object is going out of
3493 scope, policy modules should free any internal storage associated
3494 with the label so that it may be destroyed.
3496 typedef void mpo_socket_label_destroy_t(
3500 @brief Externalize a socket label
3501 @param label Label to be externalized
3502 @param element_name Name of the label namespace for which labels should be
3504 @param sb String buffer to be filled with a text representation of label
3506 Produce an externalized socket label based on the label structure passed.
3507 An externalized label consists of a text representation of the label
3508 contents that can be used with userland applications and read by the
3509 user. If element_name does not match a namespace managed by the policy,
3510 simply return 0. Only return nonzero if an error occurs while externalizing
3513 @return In the event of an error, an appropriate value for errno
3514 should be returned, otherwise return 0 upon success.
3516 typedef int mpo_socket_label_externalize_t(
3517 struct label
*label
,
3522 @brief Initialize socket label
3523 @param label New label to initialize
3524 @param waitok Malloc flags
3526 Initialize the label of a newly instantiated socket. The waitok
3527 field may be one of M_WAITOK and M_NOWAIT, and should be employed to
3528 avoid performing a sleeping malloc(9) during this initialization
3529 call. It it not always safe to sleep during this entry point.
3531 @warning Since it is possible for the waitok flags to be set to
3532 M_NOWAIT, the malloc operation may fail.
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_init_t(
3538 struct label
*label
,
3542 @brief Internalize a socket label
3543 @param label Label to be filled in
3544 @param element_name Name of the label namespace for which the label should
3546 @param element_data Text data to be internalized
3548 Produce an internal socket label structure based on externalized label
3549 data in text format.
3551 The policy's internalize entry points will be called only if the
3552 policy has registered interest in the label namespace.
3554 @return In the event of an error, an appropriate value for errno
3555 should be returned, otherwise return 0 upon success.
3557 typedef int mpo_socket_label_internalize_t(
3558 struct label
*label
,
3563 @brief Relabel socket
3564 @param cred Subject credential
3565 @param so Object; socket
3566 @param so_label Current label of the socket
3567 @param newlabel The label to be assigned to so
3569 The subject identified by the credential has previously requested
3570 and was authorized to relabel the socket; this entry point allows
3571 policies to perform the actual label update operation.
3573 @warning XXX This entry point will likely change in future versions.
3575 typedef void mpo_socket_label_update_t(
3578 struct label
*so_label
,
3579 struct label
*newlabel
3582 @brief Set the peer label on a socket from mbuf
3583 @param m Mbuf chain received on socket so
3584 @param m_label Label for m
3585 @param so Current label for the socket
3586 @param so_label Policy label to be filled out for the socket
3588 Set the peer label of a socket based on the label of the sender of the
3591 This is called for every TCP/IP packet received. The first call for a given
3592 socket operates on a newly initialized label, and subsequent calls operate
3593 on existing label data.
3595 @warning Because this can affect performance significantly, it has
3596 different sematics than other 'set' operations. Typically, 'set' operations
3597 operate on newly initialzed labels and policies do not need to worry about
3598 clobbering existing values. In this case, it is too inefficient to
3599 initialize and destroy a label every time data is received for the socket.
3600 Instead, it is up to the policies to determine how to replace the label data.
3601 Most policies should be able to replace the data inline.
3603 typedef void mpo_socketpeer_label_associate_mbuf_t(
3605 struct label
*m_label
,
3607 struct label
*so_label
3610 @brief Set the peer label on a socket from socket
3611 @param source Local socket
3612 @param sourcelabel Policy label for source
3613 @param target Peer socket
3614 @param targetlabel Policy label to fill in for target
3616 Set the peer label on a stream UNIX domain socket from the passed
3617 remote socket endpoint. This call will be made when the socket pair
3618 is connected, and will be made for both endpoints.
3620 Note that this call is only made on connection; it is currently not updated
3621 during communication.
3623 typedef void mpo_socketpeer_label_associate_socket_t(
3625 struct label
*sourcelabel
,
3627 struct label
*targetlabel
3630 @brief Destroy socket peer label
3631 @param label The peer label to be destroyed
3633 Destroy a socket peer label. Since the object is going out of
3634 scope, policy modules should free any internal storage associated
3635 with the label so that it may be destroyed.
3637 typedef void mpo_socketpeer_label_destroy_t(
3641 @brief Externalize a socket peer label
3642 @param label Label to be externalized
3643 @param element_name Name of the label namespace for which labels should be
3645 @param sb String buffer to be filled with a text representation of label
3647 Produce an externalized socket peer label based on the label structure
3648 passed. An externalized label consists of a text representation of the
3649 label contents that can be used with userland applications and read by the
3650 user. If element_name does not match a namespace managed by the policy,
3651 simply return 0. Only return nonzero if an error occurs while externalizing
3654 @return In the event of an error, an appropriate value for errno
3655 should be returned, otherwise return 0 upon success.
3657 typedef int mpo_socketpeer_label_externalize_t(
3658 struct label
*label
,
3663 @brief Initialize socket peer label
3664 @param label New label to initialize
3665 @param waitok Malloc flags
3667 Initialize the peer label of a newly instantiated socket. The
3668 waitok field may be one of M_WAITOK and M_NOWAIT, and should be
3669 employed to avoid performing a sleeping malloc(9) during this
3670 initialization call. It it not always safe to sleep during this
3673 @warning Since it is possible for the waitok flags to be set to
3674 M_NOWAIT, the malloc operation may fail.
3676 @return In the event of an error, an appropriate value for errno
3677 should be returned, otherwise return 0 upon success.
3679 typedef int mpo_socketpeer_label_init_t(
3680 struct label
*label
,
3684 @brief Access control check for enabling accounting
3685 @param cred Subject credential
3686 @param vp Accounting file
3687 @param vlabel Label associated with vp
3689 Determine whether the subject should be allowed to enable accounting,
3690 based on its label and the label of the accounting log file. See
3691 acct(5) for more information.
3693 As accounting is disabled by passing NULL to the acct(2) system call,
3694 the policy should be prepared for both 'vp' and 'vlabel' to be NULL.
3696 @return Return 0 if access is granted, otherwise an appropriate value for
3697 errno should be returned.
3699 typedef int mpo_system_check_acct_t(
3702 struct label
*vlabel
3705 @brief Access control check for audit
3706 @param cred Subject credential
3707 @param record Audit record
3708 @param length Audit record length
3710 Determine whether the subject identified by the credential can submit
3711 an audit record for inclusion in the audit log via the audit() system call.
3713 @return Return 0 if access is granted, otherwise an appropriate value for
3714 errno should be returned.
3716 typedef int mpo_system_check_audit_t(
3722 @brief Access control check for controlling audit
3723 @param cred Subject credential
3724 @param vp Audit file
3725 @param vl Label associated with vp
3727 Determine whether the subject should be allowed to enable auditing using
3728 the auditctl() system call, based on its label and the label of the proposed
3731 @return Return 0 if access is granted, otherwise an appropriate value for
3732 errno should be returned.
3734 typedef int mpo_system_check_auditctl_t(
3740 @brief Access control check for manipulating auditing
3741 @param cred Subject credential
3742 @param cmd Audit control command
3744 Determine whether the subject identified by the credential can perform
3745 the audit subsystem control operation cmd via the auditon() system call.
3747 @return Return 0 if access is granted, otherwise an appropriate value for
3748 errno should be returned.
3750 typedef int mpo_system_check_auditon_t(
3755 @brief Access control check for using CHUD facilities
3756 @param cred Subject credential
3758 Determine whether the subject identified by the credential can perform
3759 performance-related tasks using the CHUD system call.
3761 @return Return 0 if access is granted, otherwise an appropriate value for
3762 errno should be returned.
3764 typedef int mpo_system_check_chud_t(
3768 @brief Access control check for obtaining the host control port
3769 @param cred Subject credential
3771 Determine whether the subject identified by the credential can
3772 obtain the host control port.
3774 @return Return 0 if access is granted, or non-zero otherwise.
3776 typedef int mpo_system_check_host_priv_t(
3780 @brief Access control check for obtaining system information
3781 @param cred Subject credential
3782 @param info_type A description of the information requested
3784 Determine whether the subject identified by the credential should be
3785 allowed to obtain information about the system.
3787 This is a generic hook that can be used in a variety of situations where
3788 information is being returned that might be considered sensitive.
3789 Rather than adding a new MAC hook for every such interface, this hook can
3790 be called with a string identifying the type of information requested.
3792 @return Return 0 if access is granted, otherwise an appropriate value for
3793 errno should be returned.
3795 typedef int mpo_system_check_info_t(
3797 const char *info_type
3800 @brief Access control check for calling NFS services
3801 @param cred Subject credential
3803 Determine whether the subject identified by the credential should be
3804 allowed to call nfssrv(2).
3806 @return Return 0 if access is granted, otherwise an appropriate value for
3807 errno should be returned.
3809 typedef int mpo_system_check_nfsd_t(
3813 @brief Access control check for reboot
3814 @param cred Subject credential
3815 @param howto howto parameter from reboot(2)
3817 Determine whether the subject identified by the credential should be
3818 allowed to reboot the system in the specified manner.
3820 @return Return 0 if access is granted, otherwise an appropriate value for
3821 errno should be returned.
3823 typedef int mpo_system_check_reboot_t(
3828 @brief Access control check for setting system clock
3829 @param cred Subject credential
3831 Determine whether the subject identified by the credential should be
3832 allowed to set the system clock.
3834 @return Return 0 if access is granted, otherwise an appropriate value for
3835 errno should be returned.
3837 typedef int mpo_system_check_settime_t(
3841 @brief Access control check for removing swap devices
3842 @param cred Subject credential
3843 @param vp Swap device
3844 @param label Label associated with vp
3846 Determine whether the subject identified by the credential should be
3847 allowed to remove vp as a swap device.
3849 @return Return 0 if access is granted, otherwise an appropriate value for
3850 errno should be returned.
3852 typedef int mpo_system_check_swapoff_t(
3858 @brief Access control check for adding swap devices
3859 @param cred Subject credential
3860 @param vp Swap device
3861 @param label Label associated with vp
3863 Determine whether the subject identified by the credential should be
3864 allowed to add vp as a swap device.
3866 @return Return 0 if access is granted, otherwise an appropriate value for
3867 errno should be returned.
3869 typedef int mpo_system_check_swapon_t(
3875 @brief Access control check for sysctl
3876 @param cred Subject credential
3877 @param namestring String representation of sysctl name.
3878 @param name Integer name; see sysctl(3)
3879 @param namelen Length of name array of integers; see sysctl(3)
3880 @param old 0 or address where to store old value; see sysctl(3)
3881 @param oldlen Length of old buffer; see sysctl(3)
3882 @param newvalue 0 or address of new value; see sysctl(3)
3883 @param newlen Length of new buffer; see sysctl(3)
3885 Determine whether the subject identified by the credential should be
3886 allowed to make the specified sysctl(3) transaction.
3888 The sysctl(3) call specifies that if the old value is not desired,
3889 oldp and oldlenp should be set to NULL. Likewise, if a new value is
3890 not to be set, newp should be set to NULL and newlen set to 0.
3892 @return Return 0 if access is granted, otherwise an appropriate value for
3893 errno should be returned.
3895 typedef int mpo_system_check_sysctlbyname_t(
3897 const char *namestring
,
3900 user_addr_t old
, /* NULLOK */
3902 user_addr_t newvalue
, /* NULLOK */
3906 @brief Access control check for kas_info
3907 @param cred Subject credential
3908 @param selector Category of information to return. See kas_info.h
3910 Determine whether the subject identified by the credential can perform
3911 introspection of the kernel address space layout for
3912 debugging/performance analysis.
3914 @return Return 0 if access is granted, otherwise an appropriate value for
3915 errno should be returned.
3917 typedef int mpo_system_check_kas_info_t(
3922 @brief Create a System V message label
3923 @param cred Subject credential
3924 @param msqptr The message queue the message will be placed in
3925 @param msqlabel The label of the message queue
3926 @param msgptr The message
3927 @param msglabel The label of the message
3929 Label the message as its placed in the message queue.
3931 typedef void mpo_sysvmsg_label_associate_t(
3933 struct msqid_kernel
*msqptr
,
3934 struct label
*msqlabel
,
3936 struct label
*msglabel
3939 @brief Destroy System V message label
3940 @param label The label to be destroyed
3942 Destroy a System V message label. Since the object is
3943 going out of scope, policy modules should free any internal storage
3944 associated with the label so that it may be destroyed.
3946 typedef void mpo_sysvmsg_label_destroy_t(
3950 @brief Initialize System V message label
3951 @param label New label to initialize
3953 Initialize the label for a newly instantiated System V message.
3955 typedef void mpo_sysvmsg_label_init_t(
3959 @brief Clean up a System V message label
3960 @param label The label to be destroyed
3962 Clean up a System V message label. Darwin pre-allocates
3963 messages at system boot time and re-uses them rather than
3964 allocating new ones. Before messages are returned to the "free
3965 pool", policies can cleanup or overwrite any information present in
3968 typedef void mpo_sysvmsg_label_recycle_t(
3972 @brief Access control check for System V message enqueuing
3973 @param cred Subject credential
3974 @param msgptr The message
3975 @param msglabel The message's label
3976 @param msqptr The message queue
3977 @param msqlabel The message queue's label
3979 Determine whether the subject identified by the credential can add the
3980 given message to the given message queue.
3982 @return Return 0 if access is granted, otherwise an appropriate value for
3983 errno should be returned.
3985 typedef int mpo_sysvmsq_check_enqueue_t(
3988 struct label
*msglabel
,
3989 struct msqid_kernel
*msqptr
,
3990 struct label
*msqlabel
3993 @brief Access control check for System V message reception
3994 @param cred The credential of the intended recipient
3995 @param msgptr The message
3996 @param msglabel The message's label
3998 Determine whether the subject identified by the credential can receive
4001 @return Return 0 if access is granted, otherwise an appropriate value for
4002 errno should be returned.
4004 typedef int mpo_sysvmsq_check_msgrcv_t(
4007 struct label
*msglabel
4010 @brief Access control check for System V message queue removal
4011 @param cred The credential of the caller
4012 @param msgptr The message
4013 @param msglabel The message's label
4015 System V message queues are removed using the msgctl() system call.
4016 The system will iterate over each messsage in the queue, calling this
4017 function for each, to determine whether the caller has the appropriate
4020 @return Return 0 if access is granted, otherwise an appropriate value for
4021 errno should be returned.
4023 typedef int mpo_sysvmsq_check_msgrmid_t(
4026 struct label
*msglabel
4029 @brief Access control check for msgctl()
4030 @param cred The credential of the caller
4031 @param msqptr The message queue
4032 @param msqlabel The message queue's label
4034 This access check is performed to validate calls to msgctl().
4036 @return Return 0 if access is granted, otherwise an appropriate value for
4037 errno should be returned.
4039 typedef int mpo_sysvmsq_check_msqctl_t(
4041 struct msqid_kernel
*msqptr
,
4042 struct label
*msqlabel
,
4046 @brief Access control check to get a System V message queue
4047 @param cred The credential of the caller
4048 @param msqptr The message queue requested
4049 @param msqlabel The message queue's label
4051 On a call to msgget(), if the queue requested already exists,
4052 and it is a public queue, this check will be performed before the
4053 queue's ID is returned to the user.
4055 @return Return 0 if access is granted, otherwise an appropriate value for
4056 errno should be returned.
4058 typedef int mpo_sysvmsq_check_msqget_t(
4060 struct msqid_kernel
*msqptr
,
4061 struct label
*msqlabel
4064 @brief Access control check to receive a System V message from the given queue
4065 @param cred The credential of the caller
4066 @param msqptr The message queue to receive from
4067 @param msqlabel The message queue's label
4069 On a call to msgrcv(), this check is performed to determine whether the
4070 caller has receive rights on the given queue.
4072 @return Return 0 if access is granted, otherwise an appropriate value for
4073 errno should be returned.
4075 typedef int mpo_sysvmsq_check_msqrcv_t(
4077 struct msqid_kernel
*msqptr
,
4078 struct label
*msqlabel
4081 @brief Access control check to send a System V message to the given queue
4082 @param cred The credential of the caller
4083 @param msqptr The message queue to send to
4084 @param msqlabel The message queue's label
4086 On a call to msgsnd(), this check is performed to determine whether the
4087 caller has send rights on the given queue.
4089 @return Return 0 if access is granted, otherwise an appropriate value for
4090 errno should be returned.
4092 typedef int mpo_sysvmsq_check_msqsnd_t(
4094 struct msqid_kernel
*msqptr
,
4095 struct label
*msqlabel
4098 @brief Create a System V message queue label
4099 @param cred Subject credential
4100 @param msqptr The message queue
4101 @param msqlabel The label of the message queue
4104 typedef void mpo_sysvmsq_label_associate_t(
4106 struct msqid_kernel
*msqptr
,
4107 struct label
*msqlabel
4110 @brief Destroy System V message queue label
4111 @param label The label to be destroyed
4113 Destroy a System V message queue label. Since the object is
4114 going out of scope, policy modules should free any internal storage
4115 associated with the label so that it may be destroyed.
4117 typedef void mpo_sysvmsq_label_destroy_t(
4121 @brief Initialize System V message queue label
4122 @param label New label to initialize
4124 Initialize the label for a newly instantiated System V message queue.
4126 typedef void mpo_sysvmsq_label_init_t(
4130 @brief Clean up a System V message queue label
4131 @param label The label to be destroyed
4133 Clean up a System V message queue label. Darwin pre-allocates
4134 message queues at system boot time and re-uses them rather than
4135 allocating new ones. Before message queues are returned to the "free
4136 pool", policies can cleanup or overwrite any information present in
4139 typedef void mpo_sysvmsq_label_recycle_t(
4143 @brief Access control check for System V semaphore control operation
4144 @param cred Subject credential
4145 @param semakptr Pointer to semaphore identifier
4146 @param semaklabel Label associated with semaphore
4147 @param cmd Control operation to be performed; see semctl(2)
4149 Determine whether the subject identified by the credential can perform
4150 the operation indicated by cmd on the System V semaphore semakptr.
4152 @return Return 0 if access is granted, otherwise an appropriate value for
4153 errno should be returned.
4155 typedef int mpo_sysvsem_check_semctl_t(
4157 struct semid_kernel
*semakptr
,
4158 struct label
*semaklabel
,
4162 @brief Access control check for obtaining a System V semaphore
4163 @param cred Subject credential
4164 @param semakptr Pointer to semaphore identifier
4165 @param semaklabel Label to associate with the semaphore
4167 Determine whether the subject identified by the credential can
4168 obtain a System V semaphore.
4170 @return Return 0 if access is granted, otherwise an appropriate value for
4171 errno should be returned.
4173 typedef int mpo_sysvsem_check_semget_t(
4175 struct semid_kernel
*semakptr
,
4176 struct label
*semaklabel
4179 @brief Access control check for System V semaphore operations
4180 @param cred Subject credential
4181 @param semakptr Pointer to semaphore identifier
4182 @param semaklabel Label associated with the semaphore
4183 @param accesstype Flags to indicate access (read and/or write)
4185 Determine whether the subject identified by the credential can
4186 perform the operations on the System V semaphore indicated by
4187 semakptr. The accesstype flags hold the maximum set of permissions
4188 from the sem_op array passed to the semop system call. It may
4189 contain SEM_R for read-only operations or SEM_A for read/write
4192 @return Return 0 if access is granted, otherwise an appropriate value for
4193 errno should be returned.
4195 typedef int mpo_sysvsem_check_semop_t(
4197 struct semid_kernel
*semakptr
,
4198 struct label
*semaklabel
,
4202 @brief Create a System V semaphore label
4203 @param cred Subject credential
4204 @param semakptr The semaphore being created
4205 @param semalabel Label to associate with the new semaphore
4207 Label a new System V semaphore. The label was previously
4208 initialized and associated with the semaphore. At this time, an
4209 appropriate initial label value should be assigned to the object and
4210 stored in semalabel.
4212 typedef void mpo_sysvsem_label_associate_t(
4214 struct semid_kernel
*semakptr
,
4215 struct label
*semalabel
4218 @brief Destroy System V semaphore label
4219 @param label The label to be destroyed
4221 Destroy a System V semaphore label. Since the object is
4222 going out of scope, policy modules should free any internal storage
4223 associated with the label so that it may be destroyed.
4225 typedef void mpo_sysvsem_label_destroy_t(
4229 @brief Initialize System V semaphore label
4230 @param label New label to initialize
4232 Initialize the label for a newly instantiated System V semaphore. Sleeping
4235 typedef void mpo_sysvsem_label_init_t(
4239 @brief Clean up a System V semaphore label
4240 @param label The label to be cleaned
4242 Clean up a System V semaphore label. Darwin pre-allocates
4243 semaphores at system boot time and re-uses them rather than
4244 allocating new ones. Before semaphores are returned to the "free
4245 pool", policies can cleanup or overwrite any information present in
4248 typedef void mpo_sysvsem_label_recycle_t(
4252 @brief Access control check for mapping System V shared memory
4253 @param cred Subject credential
4254 @param shmsegptr Pointer to shared memory segment identifier
4255 @param shmseglabel Label associated with the shared memory segment
4256 @param shmflg shmat flags; see shmat(2)
4258 Determine whether the subject identified by the credential can map
4259 the System V shared memory segment associated with shmsegptr.
4261 @return Return 0 if access is granted, otherwise an appropriate value for
4262 errno should be returned.
4264 typedef int mpo_sysvshm_check_shmat_t(
4266 struct shmid_kernel
*shmsegptr
,
4267 struct label
*shmseglabel
,
4271 @brief Access control check for System V shared memory control operation
4272 @param cred Subject credential
4273 @param shmsegptr Pointer to shared memory segment identifier
4274 @param shmseglabel Label associated with the shared memory segment
4275 @param cmd Control operation to be performed; see shmctl(2)
4277 Determine whether the subject identified by the credential can perform
4278 the operation indicated by cmd on the System V shared memory segment
4281 @return Return 0 if access is granted, otherwise an appropriate value for
4282 errno should be returned.
4284 typedef int mpo_sysvshm_check_shmctl_t(
4286 struct shmid_kernel
*shmsegptr
,
4287 struct label
*shmseglabel
,
4291 @brief Access control check for unmapping System V shared memory
4292 @param cred Subject credential
4293 @param shmsegptr Pointer to shared memory segment identifier
4294 @param shmseglabel Label associated with the shared memory segment
4296 Determine whether the subject identified by the credential can unmap
4297 the System V shared memory segment associated with shmsegptr.
4299 @return Return 0 if access is granted, otherwise an appropriate value for
4300 errno should be returned.
4302 typedef int mpo_sysvshm_check_shmdt_t(
4304 struct shmid_kernel
*shmsegptr
,
4305 struct label
*shmseglabel
4308 @brief Access control check obtaining System V shared memory identifier
4309 @param cred Subject credential
4310 @param shmsegptr Pointer to shared memory segment identifier
4311 @param shmseglabel Label associated with the shared memory segment
4312 @param shmflg shmget flags; see shmget(2)
4314 Determine whether the subject identified by the credential can get
4315 the System V shared memory segment address.
4317 @return Return 0 if access is granted, otherwise an appropriate value for
4318 errno should be returned.
4320 typedef int mpo_sysvshm_check_shmget_t(
4322 struct shmid_kernel
*shmsegptr
,
4323 struct label
*shmseglabel
,
4327 @brief Create a System V shared memory region label
4328 @param cred Subject credential
4329 @param shmsegptr The shared memory region being created
4330 @param shmlabel Label to associate with the new shared memory region
4332 Label a new System V shared memory region. The label was previously
4333 initialized and associated with the shared memory region. At this
4334 time, an appropriate initial label value should be assigned to the
4335 object and stored in shmlabel.
4337 typedef void mpo_sysvshm_label_associate_t(
4339 struct shmid_kernel
*shmsegptr
,
4340 struct label
*shmlabel
4343 @brief Destroy System V shared memory label
4344 @param label The label to be destroyed
4346 Destroy a System V shared memory region label. Since the
4347 object is going out of scope, policy modules should free any
4348 internal storage associated with the label so that it may be
4351 typedef void mpo_sysvshm_label_destroy_t(
4355 @brief Initialize System V Shared Memory region label
4356 @param label New label to initialize
4358 Initialize the label for a newly instantiated System V Shared Memory
4359 region. Sleeping is permitted.
4361 typedef void mpo_sysvshm_label_init_t(
4365 @brief Clean up a System V Share Memory Region label
4366 @param shmlabel The label to be cleaned
4368 Clean up a System V Shared Memory Region label. Darwin
4369 pre-allocates these objects at system boot time and re-uses them
4370 rather than allocating new ones. Before the memory regions are
4371 returned to the "free pool", policies can cleanup or overwrite any
4372 information present in the label.
4374 typedef void mpo_sysvshm_label_recycle_t(
4375 struct label
*shmlabel
4378 @brief Access control check for getting a process's task name
4379 @param cred Subject credential
4380 @param p Object process
4382 Determine whether the subject identified by the credential can get
4383 the passed process's task name port.
4384 This call is used by the task_name_for_pid(2) API.
4386 @return Return 0 if access is granted, otherwise an appropriate value for
4387 errno should be returned. Suggested failure: EACCES for label mismatch,
4388 EPERM for lack of privilege, or ESRCH to hide visibility of the target.
4390 typedef int mpo_proc_check_get_task_name_t(
4395 @brief Access control check for getting a process's task port
4396 @param cred Subject credential
4397 @param p Object process
4399 Determine whether the subject identified by the credential can get
4400 the passed process's task control port.
4401 This call is used by the task_for_pid(2) API.
4403 @return Return 0 if access is granted, otherwise an appropriate value for
4404 errno should be returned. Suggested failure: EACCES for label mismatch,
4405 EPERM for lack of privilege, or ESRCH to hide visibility of the target.
4407 typedef int mpo_proc_check_get_task_t(
4413 @brief Access control check for exposing a process's task port
4414 @param cred Subject credential
4415 @param p Object process
4417 Determine whether the subject identified by the credential can expose
4418 the passed process's task control port.
4419 This call is used by the accessor APIs like processor_set_tasks() and
4420 processor_set_threads().
4422 @return Return 0 if access is granted, otherwise an appropriate value for
4423 errno should be returned. Suggested failure: EACCES for label mismatch,
4424 EPERM for lack of privilege, or ESRCH to hide visibility of the target.
4426 typedef int mpo_proc_check_expose_task_t(
4432 @brief Check whether task's IPC may inherit across process exec
4433 @param p current process instance
4434 @param cur_vp vnode pointer to current instance
4435 @param cur_offset offset of binary of currently executing image
4436 @param img_vp vnode pointer to to be exec'ed image
4437 @param img_offset offset into file which is selected for execution
4438 @param scriptvp vnode pointer of script file if any.
4439 @return Return 0 if access is granted.
4440 EPERM if parent does not have any entitlements.
4441 EACCESS if mismatch in entitlements
4443 typedef int mpo_proc_check_inherit_ipc_ports_t(
4445 struct vnode
*cur_vp
,
4447 struct vnode
*img_vp
,
4449 struct vnode
*scriptvp
4453 @brief Privilege check for a process to run invalid
4454 @param p Object process
4456 Determine whether the process may execute even though the system determined
4457 that it is untrusted (eg unidentified / modified code).
4459 @return Return 0 if access is granted, otherwise an appropriate value for
4460 errno should be returned.
4462 typedef int mpo_proc_check_run_cs_invalid_t(
4467 @brief Perform MAC-related events when a thread returns to user space
4468 @param thread Mach (not BSD) thread that is returning
4470 This entry point permits policy modules to perform MAC-related
4471 events when a thread returns to user space, via a system call
4472 return or trap return.
4474 typedef void mpo_thread_userret_t(
4475 struct thread
*thread
4479 @brief Check vnode access
4480 @param cred Subject credential
4481 @param vp Object vnode
4482 @param label Label for vp
4483 @param acc_mode access(2) flags
4485 Determine how invocations of access(2) and related calls by the
4486 subject identified by the credential should return when performed
4487 on the passed vnode using the passed access flags. This should
4488 generally be implemented using the same semantics used in
4489 mpo_vnode_check_open.
4491 @return Return 0 if access is granted, otherwise an appropriate value for
4492 errno should be returned. Suggested failure: EACCES for label mismatch or
4493 EPERM for lack of privilege.
4495 typedef int mpo_vnode_check_access_t(
4498 struct label
*label
,
4502 @brief Access control check for changing working directory
4503 @param cred Subject credential
4504 @param dvp Object; vnode to chdir(2) into
4505 @param dlabel Policy label for dvp
4507 Determine whether the subject identified by the credential can change
4508 the process working directory to the passed vnode.
4510 @return Return 0 if access is granted, otherwise an appropriate value for
4511 errno should be returned. Suggested failure: EACCES for label mismatch or
4512 EPERM for lack of privilege.
4514 typedef int mpo_vnode_check_chdir_t(
4517 struct label
*dlabel
4520 @brief Access control check for changing root directory
4521 @param cred Subject credential
4522 @param dvp Directory vnode
4523 @param dlabel Policy label associated with dvp
4524 @param cnp Component name for dvp
4526 Determine whether the subject identified by the credential should be
4527 allowed to chroot(2) into the specified directory (dvp).
4529 @return In the event of an error, an appropriate value for errno
4530 should be returned, otherwise return 0 upon success.
4532 typedef int mpo_vnode_check_chroot_t(
4535 struct label
*dlabel
,
4536 struct componentname
*cnp
4539 @brief Access control check for creating clone
4540 @param cred Subject credential
4541 @param dvp Vnode of directory to create the clone in
4542 @param dlabel Policy label associated with dvp
4543 @param vp Vnode of the file to clone from
4544 @param label Policy label associated with vp
4545 @param cnp Component name for the clone being created
4547 Determine whether the subject identified by the credential should be
4548 allowed to create a clone of the vnode vp with the name specified by cnp.
4550 @return Return 0 if access is granted, otherwise an appropriate value for
4551 errno should be returned.
4553 typedef int mpo_vnode_check_clone_t(
4556 struct label
*dlabel
,
4558 struct label
*label
,
4559 struct componentname
*cnp
4562 @brief Access control check for creating vnode
4563 @param cred Subject credential
4564 @param dvp Directory vnode
4565 @param dlabel Policy label for dvp
4566 @param cnp Component name for dvp
4567 @param vap vnode attributes for vap
4569 Determine whether the subject identified by the credential can create
4570 a vnode with the passed parent directory, passed name information,
4571 and passed attribute information. This call may be made in a number of
4572 situations, including as a result of calls to open(2) with O_CREAT,
4573 mknod(2), mkfifo(2), and others.
4575 @return Return 0 if access is granted, otherwise an appropriate value for
4576 errno should be returned. Suggested failure: EACCES for label mismatch or
4577 EPERM for lack of privilege.
4579 typedef int mpo_vnode_check_create_t(
4582 struct label
*dlabel
,
4583 struct componentname
*cnp
,
4584 struct vnode_attr
*vap
4587 @brief Access control check for deleting extended attribute
4588 @param cred Subject credential
4589 @param vp Object vnode
4590 @param vlabel Label associated with vp
4591 @param name Extended attribute name
4593 Determine whether the subject identified by the credential can delete
4594 the extended attribute from the passed vnode.
4596 @return Return 0 if access is granted, otherwise an appropriate value for
4597 errno should be returned. Suggested failure: EACCES for label mismatch or
4598 EPERM for lack of privilege.
4600 typedef int mpo_vnode_check_deleteextattr_t(
4603 struct label
*vlabel
,
4607 @brief Access control check for exchanging file data
4608 @param cred Subject credential
4609 @param v1 vnode 1 to swap
4610 @param vl1 Policy label for v1
4611 @param v2 vnode 2 to swap
4612 @param vl2 Policy label for v2
4614 Determine whether the subject identified by the credential can swap the data
4615 in the two supplied vnodes.
4617 @return Return 0 if access is granted, otherwise an appropriate value for
4618 errno should be returned. Suggested failure: EACCES for label mismatch or
4619 EPERM for lack of privilege.
4621 typedef int mpo_vnode_check_exchangedata_t(
4629 @brief Access control check for executing the vnode
4630 @param cred Subject credential
4631 @param vp Object vnode to execute
4632 @param scriptvp Script being executed by interpreter, if any.
4633 @param vnodelabel Label corresponding to vp
4634 @param scriptlabel Script vnode label
4635 @param execlabel Userspace provided execution label
4636 @param cnp Component name for file being executed
4637 @param macpolicyattr MAC policy-specific spawn attribute data.
4638 @param macpolicyattrlen Length of policy-specific spawn attribute data.
4640 Determine whether the subject identified by the credential can execute
4641 the passed vnode. Determination of execute privilege is made separately
4642 from decisions about any process label transitioning event.
4644 The final label, execlabel, corresponds to a label supplied by a
4645 user space application through the use of the mac_execve system call.
4646 This label will be NULL if the user application uses the the vendor
4647 execve(2) call instead of the MAC Framework mac_execve() call.
4649 @return Return 0 if access is granted, otherwise an appropriate value for
4650 errno should be returned. Suggested failure: EACCES for label mismatch or
4651 EPERM for lack of privilege.
4653 typedef int mpo_vnode_check_exec_t(
4656 struct vnode
*scriptvp
,
4657 struct label
*vnodelabel
,
4658 struct label
*scriptlabel
,
4659 struct label
*execlabel
, /* NULLOK */
4660 struct componentname
*cnp
,
4662 void *macpolicyattr
,
4663 size_t macpolicyattrlen
4666 @brief Access control check for fsgetpath
4667 @param cred Subject credential
4668 @param vp Vnode for which a path will be returned
4669 @param label Label associated with the vnode
4671 Determine whether the subject identified by the credential can get the path
4672 of the given vnode with fsgetpath.
4674 @return Return 0 if access is granted, otherwise an appropriate value for
4675 errno should be returned.
4677 typedef int mpo_vnode_check_fsgetpath_t(
4683 @brief Access control check for retrieving file attributes
4684 @param active_cred Subject credential
4685 @param file_cred Credential associated with the struct fileproc
4686 @param vp Object vnode
4687 @param vlabel Policy label for vp
4688 @param va Vnode attributes to retrieve
4690 Determine whether the subject identified by the credential can
4691 get information about the passed vnode. The active_cred hold
4692 the credentials of the subject performing the operation, and
4693 file_cred holds the credentials of the subject that originally
4694 opened the file. This check happens during stat(), lstat(),
4695 fstat(), and getattrlist() syscalls. See <sys/vnode.h> for
4696 definitions of the attributes.
4698 @return Return 0 if access is granted, otherwise an appropriate value for
4699 errno should be returned.
4701 @note Policies may change the contents of va to alter the list of
4702 file attributes returned.
4704 typedef int mpo_vnode_check_getattr_t(
4705 kauth_cred_t active_cred
,
4706 kauth_cred_t file_cred
, /* NULLOK */
4708 struct label
*vlabel
,
4709 struct vnode_attr
*va
4712 @brief Access control check for retrieving file attributes
4713 @param cred Subject credential
4714 @param vp Object vnode
4715 @param vlabel Policy label for vp
4716 @param alist List of attributes to retrieve
4718 Determine whether the subject identified by the credential can read
4719 various attributes of the specified vnode, or the filesystem or volume on
4720 which that vnode resides. See <sys/attr.h> for definitions of the
4723 @return Return 0 if access is granted, otherwise an appropriate value for
4724 errno should be returned. Suggested failure: EACCES for label mismatch or
4725 EPERM for lack of privilege. Access control covers all attributes requested
4726 with this call; the security policy is not permitted to change the set of
4727 attributes requested.
4729 typedef int mpo_vnode_check_getattrlist_t(
4732 struct label
*vlabel
,
4733 struct attrlist
*alist
4736 @brief Access control check for retrieving an extended attribute
4737 @param cred Subject credential
4738 @param vp Object vnode
4739 @param label Policy label for vp
4740 @param name Extended attribute name
4741 @param uio I/O structure pointer
4743 Determine whether the subject identified by the credential can retrieve
4744 the extended attribute from the passed vnode. The uio parameter
4745 will be NULL when the getxattr(2) call has been made with a NULL data
4746 value; this is done to request the size of the data only.
4748 @return Return 0 if access is granted, otherwise an appropriate value for
4749 errno should be returned. Suggested failure: EACCES for label mismatch or
4750 EPERM for lack of privilege.
4752 typedef int mpo_vnode_check_getextattr_t(
4755 struct label
*label
, /* NULLOK */
4757 struct uio
*uio
/* NULLOK */
4760 @brief Access control check for ioctl
4761 @param cred Subject credential
4762 @param vp Object vnode
4763 @param label Policy label for vp
4764 @param cmd Device-dependent request code; see ioctl(2)
4766 Determine whether the subject identified by the credential can perform
4767 the ioctl operation indicated by com.
4769 @warning Since ioctl data is opaque from the standpoint of the MAC
4770 framework, and since ioctls can affect many aspects of system
4771 operation, policies must exercise extreme care when implementing
4772 access control checks.
4774 @return Return 0 if access is granted, otherwise an appropriate value for
4775 errno should be returned.
4777 typedef int mpo_vnode_check_ioctl_t(
4780 struct label
*label
,
4784 @brief Access control check for vnode kqfilter
4785 @param active_cred Subject credential
4786 @param kn Object knote
4787 @param vp Object vnode
4788 @param label Policy label for vp
4790 Determine whether the subject identified by the credential can
4791 receive the knote on the passed vnode.
4793 @return Return 0 if access if granted, otherwise an appropriate
4794 value for errno should be returned.
4796 typedef int mpo_vnode_check_kqfilter_t(
4797 kauth_cred_t active_cred
,
4798 kauth_cred_t file_cred
, /* NULLOK */
4804 @brief Access control check for relabel
4805 @param cred Subject credential
4806 @param vp Object vnode
4807 @param vnodelabel Existing policy label for vp
4808 @param newlabel Policy label update to later be applied to vp
4809 @see mpo_relable_vnode_t
4811 Determine whether the subject identified by the credential can relabel
4812 the passed vnode to the passed label update. If all policies permit
4813 the label change, the actual relabel entry point (mpo_vnode_label_update)
4816 @return Return 0 if access is granted, otherwise an appropriate value for
4817 errno should be returned.
4819 typedef int mpo_vnode_check_label_update_t(
4822 struct label
*vnodelabel
,
4823 struct label
*newlabel
4826 @brief Access control check for creating link
4827 @param cred Subject credential
4828 @param dvp Directory vnode
4829 @param dlabel Policy label associated with dvp
4830 @param vp Link destination vnode
4831 @param label Policy label associated with vp
4832 @param cnp Component name for the link being created
4834 Determine whether the subject identified by the credential should be
4835 allowed to create a link to the vnode vp with the name specified by cnp.
4837 @return Return 0 if access is granted, otherwise an appropriate value for
4838 errno should be returned.
4840 typedef int mpo_vnode_check_link_t(
4843 struct label
*dlabel
,
4845 struct label
*label
,
4846 struct componentname
*cnp
4849 @brief Access control check for listing extended attributes
4850 @param cred Subject credential
4851 @param vp Object vnode
4852 @param vlabel Policy label associated with vp
4854 Determine whether the subject identified by the credential can retrieve
4855 a list of named extended attributes from a vnode.
4857 @return Return 0 if access is granted, otherwise an appropriate value for
4858 errno should be returned.
4860 typedef int mpo_vnode_check_listextattr_t(
4863 struct label
*vlabel
4866 @brief Access control check for lookup
4867 @param cred Subject credential
4868 @param dvp Object vnode
4869 @param dlabel Policy label for dvp
4870 @param cnp Component name being looked up
4872 Determine whether the subject identified by the credential can perform
4873 a lookup in the passed directory vnode for the passed name (cnp).
4875 @return Return 0 if access is granted, otherwise an appropriate value for
4876 errno should be returned. Suggested failure: EACCES for label mismatch or
4877 EPERM for lack of privilege.
4879 typedef int mpo_vnode_check_lookup_t(
4882 struct label
*dlabel
,
4883 struct componentname
*cnp
4886 @brief Access control check for open
4887 @param cred Subject credential
4888 @param vp Object vnode
4889 @param label Policy label associated with vp
4890 @param acc_mode open(2) access mode
4892 Determine whether the subject identified by the credential can perform
4893 an open operation on the passed vnode with the passed access mode.
4895 @return Return 0 if access is granted, otherwise an appropriate value for
4896 errno should be returned. Suggested failure: EACCES for label mismatch or
4897 EPERM for lack of privilege.
4899 typedef int mpo_vnode_check_open_t(
4902 struct label
*label
,
4906 @brief Access control check for read
4907 @param active_cred Subject credential
4908 @param file_cred Credential associated with the struct fileproc
4909 @param vp Object vnode
4910 @param label Policy label for vp
4912 Determine whether the subject identified by the credential can perform
4913 a read operation on the passed vnode. The active_cred hold the credentials
4914 of the subject performing the operation, and file_cred holds the
4915 credentials of the subject that originally opened the file.
4917 @return Return 0 if access is granted, otherwise an appropriate value for
4918 errno should be returned. Suggested failure: EACCES for label mismatch or
4919 EPERM for lack of privilege.
4921 typedef int mpo_vnode_check_read_t(
4922 kauth_cred_t active_cred
, /* SUBJECT */
4923 kauth_cred_t file_cred
, /* NULLOK */
4924 struct vnode
*vp
, /* OBJECT */
4925 struct label
*label
/* LABEL */
4928 @brief Access control check for read directory
4929 @param cred Subject credential
4930 @param dvp Object directory vnode
4931 @param dlabel Policy label for dvp
4933 Determine whether the subject identified by the credential can
4934 perform a readdir operation on the passed directory vnode.
4936 @return Return 0 if access is granted, otherwise an appropriate value for
4937 errno should be returned. Suggested failure: EACCES for label mismatch or
4938 EPERM for lack of privilege.
4940 typedef int mpo_vnode_check_readdir_t(
4941 kauth_cred_t cred
, /* SUBJECT */
4942 struct vnode
*dvp
, /* OBJECT */
4943 struct label
*dlabel
/* LABEL */
4946 @brief Access control check for read link
4947 @param cred Subject credential
4948 @param vp Object vnode
4949 @param label Policy label for vp
4951 Determine whether the subject identified by the credential can perform
4952 a readlink operation on the passed symlink vnode. This call can be made
4953 in a number of situations, including an explicit readlink call by the
4954 user process, or as a result of an implicit readlink during a name
4955 lookup by the process.
4957 @return Return 0 if access is granted, otherwise an appropriate value for
4958 errno should be returned. Suggested failure: EACCES for label mismatch or
4959 EPERM for lack of privilege.
4961 typedef int mpo_vnode_check_readlink_t(
4967 @brief Access control check for rename
4968 @param cred Subject credential
4969 @param dvp Directory vnode
4970 @param dlabel Policy label associated with dvp
4971 @param vp vnode to be renamed
4972 @param label Policy label associated with vp
4973 @param cnp Component name for vp
4974 @param tdvp Destination directory vnode
4975 @param tdlabel Policy label associated with tdvp
4976 @param tvp Overwritten vnode
4977 @param tlabel Policy label associated with tvp
4978 @param tcnp Destination component name
4980 Determine whether the subject identified by the credential should be allowed
4981 to rename the vnode vp to something else.
4983 @return Return 0 if access is granted, otherwise an appropriate value for
4984 errno should be returned.
4986 typedef int mpo_vnode_check_rename_t(
4989 struct label
*dlabel
,
4991 struct label
*label
,
4992 struct componentname
*cnp
,
4994 struct label
*tdlabel
,
4996 struct label
*tlabel
,
4997 struct componentname
*tcnp
5000 @brief Access control check for rename from
5001 @param cred Subject credential
5002 @param dvp Directory vnode
5003 @param dlabel Policy label associated with dvp
5004 @param vp vnode to be renamed
5005 @param label Policy label associated with vp
5006 @param cnp Component name for vp
5007 @see mpo_vnode_check_rename_t
5008 @see mpo_vnode_check_rename_to_t
5010 Determine whether the subject identified by the credential should be
5011 allowed to rename the vnode vp to something else.
5013 Due to VFS locking constraints (to make sure proper vnode locks are
5014 held during this entry point), the vnode relabel checks had to be
5015 split into two parts: relabel_from and relabel to.
5017 This hook is deprecated, mpo_vnode_check_rename_t should be used instead.
5019 @return Return 0 if access is granted, otherwise an appropriate value for
5020 errno should be returned.
5022 typedef int mpo_vnode_check_rename_from_t(
5025 struct label
*dlabel
,
5027 struct label
*label
,
5028 struct componentname
*cnp
5031 @brief Access control check for rename to
5032 @param cred Subject credential
5033 @param dvp Directory vnode
5034 @param dlabel Policy label associated with dvp
5035 @param vp Overwritten vnode
5036 @param label Policy label associated with vp
5037 @param samedir Boolean; 1 if the source and destination directories are the same
5038 @param cnp Destination component name
5039 @see mpo_vnode_check_rename_t
5040 @see mpo_vnode_check_rename_from_t
5042 Determine whether the subject identified by the credential should be
5043 allowed to rename to the vnode vp, into the directory dvp, or to the
5044 name represented by cnp. If there is no existing file to overwrite,
5045 vp and label will be NULL.
5047 Due to VFS locking constraints (to make sure proper vnode locks are
5048 held during this entry point), the vnode relabel checks had to be
5049 split into two parts: relabel_from and relabel to.
5051 This hook is deprecated, mpo_vnode_check_rename_t should be used instead.
5053 @return Return 0 if access is granted, otherwise an appropriate value for
5054 errno should be returned.
5056 typedef int mpo_vnode_check_rename_to_t(
5059 struct label
*dlabel
,
5060 struct vnode
*vp
, /* NULLOK */
5061 struct label
*label
, /* NULLOK */
5063 struct componentname
*cnp
5066 @brief Access control check for revoke
5067 @param cred Subject credential
5068 @param vp Object vnode
5069 @param label Policy label for vp
5071 Determine whether the subject identified by the credential can revoke
5072 access to the passed vnode.
5074 @return Return 0 if access is granted, otherwise an appropriate value for
5075 errno should be returned. Suggested failure: EACCES for label mismatch or
5076 EPERM for lack of privilege.
5078 typedef int mpo_vnode_check_revoke_t(
5084 @brief Access control check for searchfs
5085 @param cred Subject credential
5086 @param vp Object vnode
5087 @param vlabel Policy label for vp
5088 @param alist List of attributes used as search criteria
5090 Determine whether the subject identified by the credential can search the
5091 vnode using the searchfs system call.
5093 @return Return 0 if access is granted, otherwise an appropriate value for
5094 errno should be returned.
5096 typedef int mpo_vnode_check_searchfs_t(
5099 struct label
*vlabel
,
5100 struct attrlist
*alist
5103 @brief Access control check for select
5104 @param cred Subject credential
5105 @param vp Object vnode
5106 @param label Policy label for vp
5107 @param which The operation selected on: FREAD or FWRITE
5109 Determine whether the subject identified by the credential can select
5112 @return Return 0 if access is granted, otherwise an appropriate value for
5113 errno should be returned.
5115 typedef int mpo_vnode_check_select_t(
5118 struct label
*label
,
5122 @brief Access control check for setting ACL
5123 @param cred Subject credential
5124 @param vp Object node
5125 @param label Policy label for vp
5126 @param acl ACL structure pointer
5128 Determine whether the subject identified by the credential can set an ACL
5129 on the specified vnode. The ACL pointer will be NULL when removing an ACL.
5131 @return Return 0 if access is granted, otherwise an appropriate value for
5132 errno should be returned. Suggested failure: EACCES for label mismatch or
5133 EPERM for lack of privilege.
5135 typedef int mpo_vnode_check_setacl_t(
5138 struct label
*label
,
5139 struct kauth_acl
*acl
5142 @brief Access control check for setting file attributes
5143 @param cred Subject credential
5144 @param vp Object vnode
5145 @param vlabel Policy label for vp
5146 @param alist List of attributes to set
5148 Determine whether the subject identified by the credential can set
5149 various attributes of the specified vnode, or the filesystem or volume on
5150 which that vnode resides. See <sys/attr.h> for definitions of the
5153 @return Return 0 if access is granted, otherwise an appropriate value for
5154 errno should be returned. Suggested failure: EACCES for label mismatch or
5155 EPERM for lack of privilege. Access control covers all attributes requested
5158 typedef int mpo_vnode_check_setattrlist_t(
5161 struct label
*vlabel
,
5162 struct attrlist
*alist
5165 @brief Access control check for setting extended attribute
5166 @param cred Subject credential
5167 @param vp Object vnode
5168 @param label Policy label for vp
5169 @param name Extended attribute name
5170 @param uio I/O structure pointer
5172 Determine whether the subject identified by the credential can set the
5173 extended attribute of passed name and passed namespace on the passed
5174 vnode. Policies implementing security labels backed into extended
5175 attributes may want to provide additional protections for those
5176 attributes. Additionally, policies should avoid making decisions based
5177 on the data referenced from uio, as there is a potential race condition
5178 between this check and the actual operation. The uio may also be NULL
5179 if a delete operation is being performed.
5181 @return Return 0 if access is granted, otherwise an appropriate value for
5182 errno should be returned. Suggested failure: EACCES for label mismatch or
5183 EPERM for lack of privilege.
5185 typedef int mpo_vnode_check_setextattr_t(
5188 struct label
*label
,
5193 @brief Access control check for setting flags
5194 @param cred Subject credential
5195 @param vp Object vnode
5196 @param label Policy label for vp
5197 @param flags File flags; see chflags(2)
5199 Determine whether the subject identified by the credential can set
5200 the passed flags on the passed vnode.
5202 @return Return 0 if access is granted, otherwise an appropriate value for
5203 errno should be returned. Suggested failure: EACCES for label mismatch or
5204 EPERM for lack of privilege.
5206 typedef int mpo_vnode_check_setflags_t(
5209 struct label
*label
,
5213 @brief Access control check for setting mode
5214 @param cred Subject credential
5215 @param vp Object vnode
5216 @param label Policy label for vp
5217 @param mode File mode; see chmod(2)
5219 Determine whether the subject identified by the credential can set
5220 the passed mode on the passed vnode.
5222 @return Return 0 if access is granted, otherwise an appropriate value for
5223 errno should be returned. Suggested failure: EACCES for label mismatch or
5224 EPERM for lack of privilege.
5226 typedef int mpo_vnode_check_setmode_t(
5229 struct label
*label
,
5233 @brief Access control check for setting uid and gid
5234 @param cred Subject credential
5235 @param vp Object vnode
5236 @param label Policy label for vp
5240 Determine whether the subject identified by the credential can set
5241 the passed uid and passed gid as file uid and file gid on the passed
5242 vnode. The IDs may be set to (-1) to request no update.
5244 @return Return 0 if access is granted, otherwise an appropriate value for
5245 errno should be returned. Suggested failure: EACCES for label mismatch or
5246 EPERM for lack of privilege.
5248 typedef int mpo_vnode_check_setowner_t(
5251 struct label
*label
,
5256 @brief Access control check for setting timestamps
5257 @param cred Subject credential
5258 @param vp Object vnode
5259 @param label Policy label for vp
5260 @param atime Access time; see utimes(2)
5261 @param mtime Modification time; see utimes(2)
5263 Determine whether the subject identified by the credential can set
5264 the passed access timestamps on the passed vnode.
5266 @return Return 0 if access is granted, otherwise an appropriate value for
5267 errno should be returned. Suggested failure: EACCES for label mismatch or
5268 EPERM for lack of privilege.
5270 typedef int mpo_vnode_check_setutimes_t(
5273 struct label
*label
,
5274 struct timespec atime
,
5275 struct timespec mtime
5278 @brief Access control check after determining the code directory hash
5279 @param vp vnode vnode to combine into proc
5280 @param label label associated with the vnode
5281 @param cs_blob the code signature to check
5282 @param cs_flags update code signing flags if needed
5283 @param flags operational flag to mpo_vnode_check_signature
5284 @param fatal_failure_desc description of fatal failure
5285 @param fatal_failure_desc_len failure description len, failure is fatal if non-0
5287 @return Return 0 if access is granted, otherwise an appropriate value for
5288 errno should be returned.
5290 typedef int mpo_vnode_check_signature_t(
5292 struct label
*label
,
5293 struct cs_blob
*cs_blob
,
5294 unsigned int *cs_flags
,
5296 char **fatal_failure_desc
, size_t *fatal_failure_desc_len
5299 @brief Access control check for stat
5300 @param active_cred Subject credential
5301 @param file_cred Credential associated with the struct fileproc
5302 @param vp Object vnode
5303 @param label Policy label for vp
5305 Determine whether the subject identified by the credential can stat
5306 the passed vnode. See stat(2) for more information. The active_cred
5307 hold the credentials of the subject performing the operation, and
5308 file_cred holds the credentials of the subject that originally
5311 @return Return 0 if access is granted, otherwise an appropriate value for
5312 errno should be returned. Suggested failure: EACCES for label mismatch or
5313 EPERM for lack of privilege.
5315 typedef int mpo_vnode_check_stat_t(
5316 struct ucred
*active_cred
,
5317 struct ucred
*file_cred
, /* NULLOK */
5322 @brief Access control check for truncate/ftruncate
5323 @param active_cred Subject credential
5324 @param file_cred Credential associated with the struct fileproc
5325 @param vp Object vnode
5326 @param label Policy label for vp
5328 Determine whether the subject identified by the credential can
5329 perform a truncate operation on the passed vnode. The active_cred hold
5330 the credentials of the subject performing the operation, and
5331 file_cred holds the credentials of the subject that originally
5334 @return Return 0 if access is granted, otherwise an appropriate value for
5335 errno should be returned. Suggested failure: EACCES for label mismatch or
5336 EPERM for lack of privilege.
5338 typedef int mpo_vnode_check_truncate_t(
5339 kauth_cred_t active_cred
,
5340 kauth_cred_t file_cred
, /* NULLOK */
5345 @brief Access control check for binding UNIX domain socket
5346 @param cred Subject credential
5347 @param dvp Directory vnode
5348 @param dlabel Policy label for dvp
5349 @param cnp Component name for dvp
5350 @param vap vnode attributes for vap
5352 Determine whether the subject identified by the credential can perform a
5353 bind operation on a UNIX domain socket with the passed parent directory,
5354 passed name information, and passed attribute information.
5356 @return Return 0 if access is granted, otherwise an appropriate value for
5357 errno should be returned. Suggested failure: EACCES for label mismatch or
5358 EPERM for lack of privilege.
5360 typedef int mpo_vnode_check_uipc_bind_t(
5363 struct label
*dlabel
,
5364 struct componentname
*cnp
,
5365 struct vnode_attr
*vap
5368 @brief Access control check for connecting UNIX domain socket
5369 @param cred Subject credential
5370 @param vp Object vnode
5371 @param label Policy label associated with vp
5374 Determine whether the subject identified by the credential can perform a
5375 connect operation on the passed UNIX domain socket vnode.
5377 @return Return 0 if access is granted, otherwise an appropriate value for
5378 errno should be returned. Suggested failure: EACCES for label mismatch or
5379 EPERM for lack of privilege.
5381 typedef int mpo_vnode_check_uipc_connect_t(
5384 struct label
*label
,
5388 @brief Access control check for deleting vnode
5389 @param cred Subject credential
5390 @param dvp Parent directory vnode
5391 @param dlabel Policy label for dvp
5392 @param vp Object vnode to delete
5393 @param label Policy label for vp
5394 @param cnp Component name for vp
5395 @see mpo_check_rename_to_t
5397 Determine whether the subject identified by the credential can delete
5398 a vnode from the passed parent directory and passed name information.
5399 This call may be made in a number of situations, including as a
5400 results of calls to unlink(2) and rmdir(2). Policies implementing
5401 this entry point should also implement mpo_check_rename_to to
5402 authorize deletion of objects as a result of being the target of a rename.
5404 @return Return 0 if access is granted, otherwise an appropriate value for
5405 errno should be returned. Suggested failure: EACCES for label mismatch or
5406 EPERM for lack of privilege.
5408 typedef int mpo_vnode_check_unlink_t(
5411 struct label
*dlabel
,
5413 struct label
*label
,
5414 struct componentname
*cnp
5417 @brief Access control check for write
5418 @param active_cred Subject credential
5419 @param file_cred Credential associated with the struct fileproc
5420 @param vp Object vnode
5421 @param label Policy label for vp
5423 Determine whether the subject identified by the credential can
5424 perform a write operation on the passed vnode. The active_cred hold
5425 the credentials of the subject performing the operation, and
5426 file_cred holds the credentials of the subject that originally
5429 @return Return 0 if access is granted, otherwise an appropriate value for
5430 errno should be returned. Suggested failure: EACCES for label mismatch or
5431 EPERM for lack of privilege.
5433 typedef int mpo_vnode_check_write_t(
5434 kauth_cred_t active_cred
,
5435 kauth_cred_t file_cred
, /* NULLOK */
5440 @brief Associate a vnode with a devfs entry
5441 @param mp Devfs mount point
5442 @param mntlabel Devfs mount point label
5443 @param de Devfs directory entry
5444 @param delabel Label associated with de
5445 @param vp vnode associated with de
5446 @param vlabel Label associated with vp
5448 Fill in the label (vlabel) for a newly created devfs vnode. The
5449 label is typically derived from the label on the devfs directory
5450 entry or the label on the filesystem, supplied as parameters.
5452 typedef void mpo_vnode_label_associate_devfs_t(
5454 struct label
*mntlabel
,
5456 struct label
*delabel
,
5458 struct label
*vlabel
5461 @brief Associate a label with a vnode
5462 @param mp File system mount point
5463 @param mntlabel File system mount point label
5464 @param vp Vnode to label
5465 @param vlabel Label associated with vp
5467 Attempt to retrieve label information for the vnode, vp, from the
5468 file system extended attribute store. The label should be stored in
5469 the supplied vlabel parameter. If a policy cannot retrieve an
5470 extended attribute, sometimes it is acceptible to fallback to using
5473 If the policy requires vnodes to have a valid label elsewhere it
5474 MUST NOT return other than temporary errors, and must always provide
5475 a valid label of some sort. Returning an error will cause vnode
5476 labeling to be retried at a later access. Failure to handle policy
5477 centric errors internally (corrupt labels etc.) will result in
5480 @return In the event of an error, an appropriate value for errno
5481 should be returned, otherwise return 0 upon success.
5483 typedef int mpo_vnode_label_associate_extattr_t(
5485 struct label
*mntlabel
,
5487 struct label
*vlabel
5490 @brief Associate a file label with a vnode
5491 @param cred User credential
5492 @param mp Fdesc mount point
5493 @param mntlabel Fdesc mount point label
5494 @param fg Fileglob structure
5495 @param label Policy label for fg
5496 @param vp Vnode to label
5497 @param vlabel Label associated with vp
5499 Associate label information for the vnode, vp, with the label of
5500 the open file descriptor described by fg.
5501 The label should be stored in the supplied vlabel parameter.
5503 typedef void mpo_vnode_label_associate_file_t(
5506 struct label
*mntlabel
,
5507 struct fileglob
*fg
,
5508 struct label
*label
,
5510 struct label
*vlabel
5513 @brief Associate a pipe label with a vnode
5514 @param cred User credential for the process that opened the pipe
5515 @param cpipe Pipe structure
5516 @param pipelabel Label associated with pipe
5517 @param vp Vnode to label
5518 @param vlabel Label associated with vp
5520 Associate label information for the vnode, vp, with the label of
5521 the pipe described by the pipe structure cpipe.
5522 The label should be stored in the supplied vlabel parameter.
5524 typedef void mpo_vnode_label_associate_pipe_t(
5527 struct label
*pipelabel
,
5529 struct label
*vlabel
5532 @brief Associate a POSIX semaphore label with a vnode
5533 @param cred User credential for the process that create psem
5534 @param psem POSIX semaphore structure
5535 @param psemlabel Label associated with psem
5536 @param vp Vnode to label
5537 @param vlabel Label associated with vp
5539 Associate label information for the vnode, vp, with the label of
5540 the POSIX semaphore described by psem.
5541 The label should be stored in the supplied vlabel parameter.
5543 typedef void mpo_vnode_label_associate_posixsem_t(
5545 struct pseminfo
*psem
,
5546 struct label
*psemlabel
,
5548 struct label
*vlabel
5551 @brief Associate a POSIX shared memory label with a vnode
5552 @param cred User credential for the process that created pshm
5553 @param pshm POSIX shared memory structure
5554 @param pshmlabel Label associated with pshm
5555 @param vp Vnode to label
5556 @param vlabel Label associated with vp
5558 Associate label information for the vnode, vp, with the label of
5559 the POSIX shared memory region described by pshm.
5560 The label should be stored in the supplied vlabel parameter.
5562 typedef void mpo_vnode_label_associate_posixshm_t(
5564 struct pshminfo
*pshm
,
5565 struct label
*pshmlabel
,
5567 struct label
*vlabel
5570 @brief Associate a label with a vnode
5571 @param mp File system mount point
5572 @param mntlabel File system mount point label
5573 @param vp Vnode to label
5574 @param vlabel Label associated with vp
5576 On non-multilabel file systems, set the label for a vnode. The
5577 label will most likely be based on the file system label.
5579 typedef void mpo_vnode_label_associate_singlelabel_t(
5581 struct label
*mntlabel
,
5583 struct label
*vlabel
5586 @brief Associate a socket label with a vnode
5587 @param cred User credential for the process that opened the socket
5588 @param so Socket structure
5589 @param solabel Label associated with so
5590 @param vp Vnode to label
5591 @param vlabel Label associated with vp
5593 Associate label information for the vnode, vp, with the label of
5594 the open socket described by the socket structure so.
5595 The label should be stored in the supplied vlabel parameter.
5597 typedef void mpo_vnode_label_associate_socket_t(
5600 struct label
*solabel
,
5602 struct label
*vlabel
5605 @brief Copy a vnode label
5606 @param src Source vnode label
5607 @param dest Destination vnode label
5609 Copy the vnode label information from src to dest. On Darwin, this
5610 is currently only necessary when executing interpreted scripts, but
5611 will later be used if vnode label externalization cannot be an
5614 typedef void mpo_vnode_label_copy_t(
5619 @brief Destroy vnode label
5620 @param label The label to be destroyed
5622 Destroy a vnode label. Since the object is going out of scope,
5623 policy modules should free any internal storage associated with the
5624 label so that it may be destroyed.
5626 typedef void mpo_vnode_label_destroy_t(
5630 @brief Externalize a vnode label for auditing
5631 @param label Label to be externalized
5632 @param element_name Name of the label namespace for which labels should be
5634 @param sb String buffer to be filled with a text representation of the label
5636 Produce an external representation of the label on a vnode suitable for
5637 inclusion in an audit record. An externalized label consists of a text
5638 representation of the label contents that will be added to the audit record
5639 as part of a text token. Policy-agnostic user space tools will display
5640 this externalized version.
5642 @return 0 on success, return non-zero if an error occurs while
5643 externalizing the label data.
5646 typedef int mpo_vnode_label_externalize_audit_t(
5647 struct label
*label
,
5652 @brief Externalize a vnode label
5653 @param label Label to be externalized
5654 @param element_name Name of the label namespace for which labels should be
5656 @param sb String buffer to be filled with a text representation of the label
5658 Produce an external representation of the label on a vnode. An
5659 externalized label consists of a text representation of the label
5660 contents that can be used with user applications. Policy-agnostic
5661 user space tools will display this externalized version.
5663 @return 0 on success, return non-zero if an error occurs while
5664 externalizing the label data.
5667 typedef int mpo_vnode_label_externalize_t(
5668 struct label
*label
,
5673 @brief Initialize vnode label
5674 @param label New label to initialize
5676 Initialize label storage for use with a newly instantiated vnode, or
5677 for temporary storage associated with the copying in or out of a
5678 vnode label. While it is necessary to allocate space for a
5679 kernel-resident vnode label, it is not yet necessary to link this vnode
5680 with persistent label storage facilities, such as extended attributes.
5681 Sleeping is permitted.
5683 typedef void mpo_vnode_label_init_t(
5687 @brief Internalize a vnode label
5688 @param label Label to be internalized
5689 @param element_name Name of the label namespace for which the label should
5691 @param element_data Text data to be internalized
5693 Produce a vnode label from an external representation. An
5694 externalized label consists of a text representation of the label
5695 contents that can be used with user applications. Policy-agnostic
5696 user space tools will forward text version to the kernel for
5697 processing by individual policy modules.
5699 The policy's internalize entry points will be called only if the
5700 policy has registered interest in the label namespace.
5702 @return 0 on success, Otherwise, return non-zero if an error occurs
5703 while internalizing the label data.
5705 typedef int mpo_vnode_label_internalize_t(
5706 struct label
*label
,
5711 @brief Clean up a vnode label
5712 @param label The label to be cleaned for re-use
5714 Clean up a vnode label. Darwin (Tiger, 8.x) allocates vnodes on demand, but
5715 typically never frees them. Before vnodes are placed back on free lists for
5716 re-use, policies can cleanup or overwrite any information present in the label.
5718 typedef void mpo_vnode_label_recycle_t(
5722 @brief Write a label to a extended attribute
5723 @param cred Subject credential
5724 @param vp The vnode for which the label is being stored
5725 @param vlabel Label associated with vp
5726 @param intlabel The new label to store
5728 Store a new label in the extended attribute corresponding to the
5729 supplied vnode. The policy has already authorized the operation;
5730 this call must be implemented in order to perform the actual
5733 @return In the event of an error, an appropriate value for errno
5734 should be returned, otherwise return 0 upon success.
5736 @warning XXX After examining the extended attribute implementation on
5737 Apple's future release, this entry point may be changed.
5739 typedef int mpo_vnode_label_store_t(
5742 struct label
*vlabel
,
5743 struct label
*intlabel
5746 @brief Update vnode label from extended attributes
5747 @param mp File system mount point
5748 @param mntlabel Mount point label
5749 @param vp Vnode to label
5750 @param vlabel Label associated with vp
5751 @param name Name of the xattr
5752 @see mpo_vnode_check_setextattr_t
5754 When an extended attribute is updated via the Vendor attribute management
5755 functions, the MAC vnode label might also require an update.
5756 Policies should first determine if 'name' matches their xattr label
5757 name. If it does, the kernel is has either replaced or removed the
5758 named extended attribute that was previously associated with the
5759 vnode. Normally labels should only be modified via MAC Framework label
5760 management calls, but sometimes the user space components will directly
5761 modify extended attributes. For example, 'cp', 'tar', etc. manage
5762 extended attributes in userspace, not the kernel.
5764 This entry point is called after the label update has occurred, so
5765 it cannot return a failure. However, the operation is preceded by
5766 the mpo_vnode_check_setextattr() access control check.
5768 If the vnode label needs to be updated the policy should return
5769 a non-zero value. The vnode label will be marked for re-association
5772 typedef int mpo_vnode_label_update_extattr_t(
5774 struct label
*mntlabel
,
5776 struct label
*vlabel
,
5780 @brief Update a vnode label
5781 @param cred Subject credential
5782 @param vp The vnode to relabel
5783 @param vnodelabel Existing vnode label
5784 @param label New label to replace existing label
5785 @see mpo_vnode_check_label_update_t
5787 The subject identified by the credential has previously requested
5788 and was authorized to relabel the vnode; this entry point allows
5789 policies to perform the actual relabel operation. Policies should
5790 update vnodelabel using the label stored in the label parameter.
5792 typedef void mpo_vnode_label_update_t(
5795 struct label
*vnodelabel
,
5799 @brief Find deatched signatures for a shared library
5800 @param p file trying to find the signature
5801 @param vp The vnode to relabel
5802 @param offset offset in the macho that the signature is requested for (for fat binaries)
5803 @param label Existing vnode label
5806 typedef int mpo_vnode_find_sigs_t(
5813 @brief Create a new vnode, backed by extended attributes
5814 @param cred User credential for the creating process
5815 @param mp File system mount point
5816 @param mntlabel File system mount point label
5817 @param dvp Parent directory vnode
5818 @param dlabel Parent directory vnode label
5819 @param vp Newly created vnode
5820 @param vlabel Label to associate with the new vnode
5821 @param cnp Component name for vp
5823 Write out the label for the newly created vnode, most likely storing
5824 the results in a file system extended attribute. Most policies will
5825 derive the new vnode label using information from a combination
5826 of the subject (user) credential, the file system label, the parent
5827 directory label, and potentially the path name component.
5829 @return If the operation succeeds, store the new label in vlabel and
5830 return 0. Otherwise, return an appropriate errno value.
5832 typedef int mpo_vnode_notify_create_t(
5835 struct label
*mntlabel
,
5837 struct label
*dlabel
,
5839 struct label
*vlabel
,
5840 struct componentname
*cnp
5844 @brief Inform MAC policies that a vnode has been opened
5845 @param cred User credential for the creating process
5846 @param vp vnode opened
5847 @param label Policy label for the vp
5848 @param acc_mode open(2) access mode used
5850 Inform Mac policies that a vnode have been successfully opened
5851 (passing all MAC polices and DAC).
5853 typedef void mpo_vnode_notify_open_t(
5856 struct label
*label
,
5861 @brief Inform MAC policies that a vnode has been renamed
5862 @param cred User credential for the renaming process
5863 @param vp Vnode that's being renamed
5864 @param label Policy label for vp
5865 @param dvp Parent directory for the destination
5866 @param dlabel Policy label for dvp
5867 @param cnp Component name for the destination
5869 Inform MAC policies that a vnode has been renamed.
5871 typedef void mpo_vnode_notify_rename_t(
5874 struct label
*label
,
5876 struct label
*dlabel
,
5877 struct componentname
*cnp
5881 @brief Inform MAC policies that a vnode has been linked
5882 @param cred User credential for the renaming process
5883 @param dvp Parent directory for the destination
5884 @param dlabel Policy label for dvp
5885 @param vp Vnode that's being linked
5886 @param vlabel Policy label for vp
5887 @param cnp Component name for the destination
5889 Inform MAC policies that a vnode has been linked.
5891 typedef void mpo_vnode_notify_link_t(
5894 struct label
*dlabel
,
5896 struct label
*vlabel
,
5897 struct componentname
*cnp
5901 @brief Inform MAC policies that an extended attribute has been removed from a vnode
5902 @param cred Subject credential
5903 @param vp Object node
5904 @param label Policy label for vp
5905 @param name Extended attribute name
5907 Inform MAC policies that an extended attribute has been removed from a vnode.
5909 typedef void mpo_vnode_notify_deleteextattr_t(
5912 struct label
*label
,
5918 @brief Inform MAC policies that an ACL has been set on a vnode
5919 @param cred Subject credential
5920 @param vp Object node
5921 @param label Policy label for vp
5922 @param acl ACL structure pointer
5924 Inform MAC policies that an ACL has been set on a vnode.
5926 typedef void mpo_vnode_notify_setacl_t(
5929 struct label
*label
,
5930 struct kauth_acl
*acl
5934 @brief Inform MAC policies that an attributes have been set on a vnode
5935 @param cred Subject credential
5936 @param vp Object vnode
5937 @param label Policy label for vp
5938 @param alist List of attributes to set
5940 Inform MAC policies that an attributes have been set on a vnode.
5942 typedef void mpo_vnode_notify_setattrlist_t(
5945 struct label
*label
,
5946 struct attrlist
*alist
5950 @brief Inform MAC policies that an extended attribute has been set on a vnode
5951 @param cred Subject credential
5952 @param vp Object vnode
5953 @param label Policy label for vp
5954 @param name Extended attribute name
5955 @param uio I/O structure pointer
5957 Inform MAC policies that an extended attribute has been set on a vnode.
5959 typedef void mpo_vnode_notify_setextattr_t(
5962 struct label
*label
,
5968 @brief Inform MAC policies that flags 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 flags File flags; see chflags(2)
5974 Inform MAC policies that flags have been set on a vnode.
5976 typedef void mpo_vnode_notify_setflags_t(
5979 struct label
*label
,
5984 @brief Inform MAC policies that a new mode has been set on a vnode
5985 @param cred Subject credential
5986 @param vp Object vnode
5987 @param label Policy label for vp
5988 @param mode File mode; see chmod(2)
5990 Inform MAC policies that a new mode has been set on a vnode.
5992 typedef void mpo_vnode_notify_setmode_t(
5995 struct label
*label
,
6000 @brief Inform MAC policies that new uid/gid have been set on a vnode
6001 @param cred Subject credential
6002 @param vp Object vnode
6003 @param label Policy label for vp
6007 Inform MAC policies that new uid/gid have been set on a vnode.
6009 typedef void mpo_vnode_notify_setowner_t(
6012 struct label
*label
,
6018 @brief Inform MAC policies that new timestamps have been set on a vnode
6019 @param cred Subject credential
6020 @param vp Object vnode
6021 @param label Policy label for vp
6022 @param atime Access time; see utimes(2)
6023 @param mtime Modification time; see utimes(2)
6025 Inform MAC policies that new timestamps have been set on a vnode.
6027 typedef void mpo_vnode_notify_setutimes_t(
6030 struct label
*label
,
6031 struct timespec atime
,
6032 struct timespec mtime
6036 @brief Inform MAC policies that a vnode has been truncated
6037 @param cred Subject credential
6038 @param file_cred Credential associated with the struct fileproc
6039 @param vp Object vnode
6040 @param label Policy label for vp
6042 Inform MAC policies that a vnode has been truncated.
6044 typedef void mpo_vnode_notify_truncate_t(
6046 kauth_cred_t file_cred
,
6053 @brief Inform MAC policies that a pty slave has been granted
6054 @param p Responsible process
6055 @param tp tty data structure
6056 @param dev Major and minor numbers of device
6057 @param label Policy label for tp
6059 Inform MAC policies that a pty slave has been granted.
6061 typedef void mpo_pty_notify_grant_t(
6069 @brief Inform MAC policies that a pty master has been closed
6070 @param p Responsible process
6071 @param tp tty data structure
6072 @param dev Major and minor numbers of device
6073 @param label Policy label for tp
6075 Inform MAC policies that a pty master has been closed.
6077 typedef void mpo_pty_notify_close_t(
6085 @brief Access control check for kext loading
6086 @param cred Subject credential
6087 @param identifier Kext identifier
6089 Determine whether the subject identified by the credential can load the
6092 @return Return 0 if access is granted, otherwise an appropriate value for
6093 errno should be returned. Suggested failure: EPERM for lack of privilege.
6095 typedef int mpo_kext_check_load_t(
6097 const char *identifier
6101 @brief Access control check for kext unloading
6102 @param cred Subject credential
6103 @param identifier Kext identifier
6105 Determine whether the subject identified by the credential can unload the
6108 @return Return 0 if access is granted, otherwise an appropriate value for
6109 errno should be returned. Suggested failure: EPERM for lack of privilege.
6111 typedef int mpo_kext_check_unload_t(
6113 const char *identifier
6117 @brief Access control check for querying information about loaded kexts
6118 @param cred Subject credential
6120 Determine whether the subject identified by the credential can query
6121 information about loaded kexts.
6123 @return Return 0 if access is granted, otherwise an appropriate value for
6124 errno should be returned. Suggested failure: EPERM for lack of privilege.
6126 typedef int mpo_kext_check_query_t(
6131 @brief Access control check for getting NVRAM variables.
6132 @param cred Subject credential
6133 @param name NVRAM variable to get
6135 Determine whether the subject identifier by the credential can get the
6136 value of the named NVRAM variable.
6138 @return Return 0 if access is granted, otherwise an appropriate value for
6139 errno should be returned. Suggested failure: EPERM for lack of privilege.
6141 typedef int mpo_iokit_check_nvram_get_t(
6147 @brief Access control check for setting NVRAM variables.
6148 @param cred Subject credential
6149 @param name NVRAM variable to set
6150 @param value The new value for the NVRAM variable
6152 Determine whether the subject identifier by the credential can set the
6153 value of the named NVRAM variable.
6155 @return Return 0 if access is granted, otherwise an appropriate value for
6156 errno should be returned. Suggested failure: EPERM for lack of privilege.
6158 typedef int mpo_iokit_check_nvram_set_t(
6165 @brief Access control check for deleting NVRAM variables.
6166 @param cred Subject credential
6167 @param name NVRAM variable to delete
6169 Determine whether the subject identifier by the credential can delete the
6170 named NVRAM variable.
6172 @return Return 0 if access is granted, otherwise an appropriate value for
6173 errno should be returned. Suggested failure: EPERM for lack of privilege.
6175 typedef int mpo_iokit_check_nvram_delete_t(
6181 * Placeholder for future events that may need mac hooks.
6183 typedef void mpo_reserved_hook_t(void);
6186 * Policy module operations.
6188 * Please note that this should be kept in sync with the check assumptions
6189 * policy in bsd/kern/policy_check.c (policy_ops struct).
6191 #define MAC_POLICY_OPS_VERSION 47 /* inc when new reserved slots are taken */
6192 struct mac_policy_ops
{
6193 mpo_audit_check_postselect_t
*mpo_audit_check_postselect
;
6194 mpo_audit_check_preselect_t
*mpo_audit_check_preselect
;
6196 mpo_bpfdesc_label_associate_t
*mpo_bpfdesc_label_associate
;
6197 mpo_bpfdesc_label_destroy_t
*mpo_bpfdesc_label_destroy
;
6198 mpo_bpfdesc_label_init_t
*mpo_bpfdesc_label_init
;
6199 mpo_bpfdesc_check_receive_t
*mpo_bpfdesc_check_receive
;
6201 mpo_cred_check_label_update_execve_t
*mpo_cred_check_label_update_execve
;
6202 mpo_cred_check_label_update_t
*mpo_cred_check_label_update
;
6203 mpo_cred_check_visible_t
*mpo_cred_check_visible
;
6204 mpo_cred_label_associate_fork_t
*mpo_cred_label_associate_fork
;
6205 mpo_cred_label_associate_kernel_t
*mpo_cred_label_associate_kernel
;
6206 mpo_cred_label_associate_t
*mpo_cred_label_associate
;
6207 mpo_cred_label_associate_user_t
*mpo_cred_label_associate_user
;
6208 mpo_cred_label_destroy_t
*mpo_cred_label_destroy
;
6209 mpo_cred_label_externalize_audit_t
*mpo_cred_label_externalize_audit
;
6210 mpo_cred_label_externalize_t
*mpo_cred_label_externalize
;
6211 mpo_cred_label_init_t
*mpo_cred_label_init
;
6212 mpo_cred_label_internalize_t
*mpo_cred_label_internalize
;
6213 mpo_cred_label_update_execve_t
*mpo_cred_label_update_execve
;
6214 mpo_cred_label_update_t
*mpo_cred_label_update
;
6216 mpo_devfs_label_associate_device_t
*mpo_devfs_label_associate_device
;
6217 mpo_devfs_label_associate_directory_t
*mpo_devfs_label_associate_directory
;
6218 mpo_devfs_label_copy_t
*mpo_devfs_label_copy
;
6219 mpo_devfs_label_destroy_t
*mpo_devfs_label_destroy
;
6220 mpo_devfs_label_init_t
*mpo_devfs_label_init
;
6221 mpo_devfs_label_update_t
*mpo_devfs_label_update
;
6223 mpo_file_check_change_offset_t
*mpo_file_check_change_offset
;
6224 mpo_file_check_create_t
*mpo_file_check_create
;
6225 mpo_file_check_dup_t
*mpo_file_check_dup
;
6226 mpo_file_check_fcntl_t
*mpo_file_check_fcntl
;
6227 mpo_file_check_get_offset_t
*mpo_file_check_get_offset
;
6228 mpo_file_check_get_t
*mpo_file_check_get
;
6229 mpo_file_check_inherit_t
*mpo_file_check_inherit
;
6230 mpo_file_check_ioctl_t
*mpo_file_check_ioctl
;
6231 mpo_file_check_lock_t
*mpo_file_check_lock
;
6232 mpo_file_check_mmap_downgrade_t
*mpo_file_check_mmap_downgrade
;
6233 mpo_file_check_mmap_t
*mpo_file_check_mmap
;
6234 mpo_file_check_receive_t
*mpo_file_check_receive
;
6235 mpo_file_check_set_t
*mpo_file_check_set
;
6236 mpo_file_label_init_t
*mpo_file_label_init
;
6237 mpo_file_label_destroy_t
*mpo_file_label_destroy
;
6238 mpo_file_label_associate_t
*mpo_file_label_associate
;
6240 mpo_ifnet_check_label_update_t
*mpo_ifnet_check_label_update
;
6241 mpo_ifnet_check_transmit_t
*mpo_ifnet_check_transmit
;
6242 mpo_ifnet_label_associate_t
*mpo_ifnet_label_associate
;
6243 mpo_ifnet_label_copy_t
*mpo_ifnet_label_copy
;
6244 mpo_ifnet_label_destroy_t
*mpo_ifnet_label_destroy
;
6245 mpo_ifnet_label_externalize_t
*mpo_ifnet_label_externalize
;
6246 mpo_ifnet_label_init_t
*mpo_ifnet_label_init
;
6247 mpo_ifnet_label_internalize_t
*mpo_ifnet_label_internalize
;
6248 mpo_ifnet_label_update_t
*mpo_ifnet_label_update
;
6249 mpo_ifnet_label_recycle_t
*mpo_ifnet_label_recycle
;
6251 mpo_inpcb_check_deliver_t
*mpo_inpcb_check_deliver
;
6252 mpo_inpcb_label_associate_t
*mpo_inpcb_label_associate
;
6253 mpo_inpcb_label_destroy_t
*mpo_inpcb_label_destroy
;
6254 mpo_inpcb_label_init_t
*mpo_inpcb_label_init
;
6255 mpo_inpcb_label_recycle_t
*mpo_inpcb_label_recycle
;
6256 mpo_inpcb_label_update_t
*mpo_inpcb_label_update
;
6258 mpo_iokit_check_device_t
*mpo_iokit_check_device
;
6260 mpo_ipq_label_associate_t
*mpo_ipq_label_associate
;
6261 mpo_ipq_label_compare_t
*mpo_ipq_label_compare
;
6262 mpo_ipq_label_destroy_t
*mpo_ipq_label_destroy
;
6263 mpo_ipq_label_init_t
*mpo_ipq_label_init
;
6264 mpo_ipq_label_update_t
*mpo_ipq_label_update
;
6266 mpo_file_check_library_validation_t
*mpo_file_check_library_validation
;
6267 mpo_vnode_notify_setacl_t
*mpo_vnode_notify_setacl
;
6268 mpo_vnode_notify_setattrlist_t
*mpo_vnode_notify_setattrlist
;
6269 mpo_vnode_notify_setextattr_t
*mpo_vnode_notify_setextattr
;
6270 mpo_vnode_notify_setflags_t
*mpo_vnode_notify_setflags
;
6271 mpo_vnode_notify_setmode_t
*mpo_vnode_notify_setmode
;
6272 mpo_vnode_notify_setowner_t
*mpo_vnode_notify_setowner
;
6273 mpo_vnode_notify_setutimes_t
*mpo_vnode_notify_setutimes
;
6274 mpo_vnode_notify_truncate_t
*mpo_vnode_notify_truncate
;
6276 mpo_mbuf_label_associate_bpfdesc_t
*mpo_mbuf_label_associate_bpfdesc
;
6277 mpo_mbuf_label_associate_ifnet_t
*mpo_mbuf_label_associate_ifnet
;
6278 mpo_mbuf_label_associate_inpcb_t
*mpo_mbuf_label_associate_inpcb
;
6279 mpo_mbuf_label_associate_ipq_t
*mpo_mbuf_label_associate_ipq
;
6280 mpo_mbuf_label_associate_linklayer_t
*mpo_mbuf_label_associate_linklayer
;
6281 mpo_mbuf_label_associate_multicast_encap_t
*mpo_mbuf_label_associate_multicast_encap
;
6282 mpo_mbuf_label_associate_netlayer_t
*mpo_mbuf_label_associate_netlayer
;
6283 mpo_mbuf_label_associate_socket_t
*mpo_mbuf_label_associate_socket
;
6284 mpo_mbuf_label_copy_t
*mpo_mbuf_label_copy
;
6285 mpo_mbuf_label_destroy_t
*mpo_mbuf_label_destroy
;
6286 mpo_mbuf_label_init_t
*mpo_mbuf_label_init
;
6288 mpo_mount_check_fsctl_t
*mpo_mount_check_fsctl
;
6289 mpo_mount_check_getattr_t
*mpo_mount_check_getattr
;
6290 mpo_mount_check_label_update_t
*mpo_mount_check_label_update
;
6291 mpo_mount_check_mount_t
*mpo_mount_check_mount
;
6292 mpo_mount_check_remount_t
*mpo_mount_check_remount
;
6293 mpo_mount_check_setattr_t
*mpo_mount_check_setattr
;
6294 mpo_mount_check_stat_t
*mpo_mount_check_stat
;
6295 mpo_mount_check_umount_t
*mpo_mount_check_umount
;
6296 mpo_mount_label_associate_t
*mpo_mount_label_associate
;
6297 mpo_mount_label_destroy_t
*mpo_mount_label_destroy
;
6298 mpo_mount_label_externalize_t
*mpo_mount_label_externalize
;
6299 mpo_mount_label_init_t
*mpo_mount_label_init
;
6300 mpo_mount_label_internalize_t
*mpo_mount_label_internalize
;
6302 mpo_netinet_fragment_t
*mpo_netinet_fragment
;
6303 mpo_netinet_icmp_reply_t
*mpo_netinet_icmp_reply
;
6304 mpo_netinet_tcp_reply_t
*mpo_netinet_tcp_reply
;
6306 mpo_pipe_check_ioctl_t
*mpo_pipe_check_ioctl
;
6307 mpo_pipe_check_kqfilter_t
*mpo_pipe_check_kqfilter
;
6308 mpo_pipe_check_label_update_t
*mpo_pipe_check_label_update
;
6309 mpo_pipe_check_read_t
*mpo_pipe_check_read
;
6310 mpo_pipe_check_select_t
*mpo_pipe_check_select
;
6311 mpo_pipe_check_stat_t
*mpo_pipe_check_stat
;
6312 mpo_pipe_check_write_t
*mpo_pipe_check_write
;
6313 mpo_pipe_label_associate_t
*mpo_pipe_label_associate
;
6314 mpo_pipe_label_copy_t
*mpo_pipe_label_copy
;
6315 mpo_pipe_label_destroy_t
*mpo_pipe_label_destroy
;
6316 mpo_pipe_label_externalize_t
*mpo_pipe_label_externalize
;
6317 mpo_pipe_label_init_t
*mpo_pipe_label_init
;
6318 mpo_pipe_label_internalize_t
*mpo_pipe_label_internalize
;
6319 mpo_pipe_label_update_t
*mpo_pipe_label_update
;
6321 mpo_policy_destroy_t
*mpo_policy_destroy
;
6322 mpo_policy_init_t
*mpo_policy_init
;
6323 mpo_policy_initbsd_t
*mpo_policy_initbsd
;
6324 mpo_policy_syscall_t
*mpo_policy_syscall
;
6326 mpo_system_check_sysctlbyname_t
*mpo_system_check_sysctlbyname
;
6327 mpo_proc_check_inherit_ipc_ports_t
*mpo_proc_check_inherit_ipc_ports
;
6328 mpo_vnode_check_rename_t
*mpo_vnode_check_rename
;
6329 mpo_kext_check_query_t
*mpo_kext_check_query
;
6330 mpo_iokit_check_nvram_get_t
*mpo_iokit_check_nvram_get
;
6331 mpo_iokit_check_nvram_set_t
*mpo_iokit_check_nvram_set
;
6332 mpo_iokit_check_nvram_delete_t
*mpo_iokit_check_nvram_delete
;
6333 mpo_proc_check_expose_task_t
*mpo_proc_check_expose_task
;
6334 mpo_proc_check_set_host_special_port_t
*mpo_proc_check_set_host_special_port
;
6335 mpo_proc_check_set_host_exception_port_t
*mpo_proc_check_set_host_exception_port
;
6336 mpo_exc_action_check_exception_send_t
*mpo_exc_action_check_exception_send
;
6337 mpo_exc_action_label_associate_t
*mpo_exc_action_label_associate
;
6338 mpo_exc_action_label_copy_t
*mpo_exc_action_label_copy
;
6339 mpo_exc_action_label_destroy_t
*mpo_exc_action_label_destroy
;
6340 mpo_exc_action_label_init_t
*mpo_exc_action_label_init
;
6341 mpo_exc_action_label_update_t
*mpo_exc_action_label_update
;
6343 mpo_reserved_hook_t
*mpo_reserved1
;
6344 mpo_reserved_hook_t
*mpo_reserved2
;
6345 mpo_reserved_hook_t
*mpo_reserved3
;
6346 mpo_reserved_hook_t
*mpo_reserved4
;
6347 mpo_reserved_hook_t
*mpo_reserved5
;
6348 mpo_reserved_hook_t
*mpo_reserved6
;
6350 mpo_posixsem_check_create_t
*mpo_posixsem_check_create
;
6351 mpo_posixsem_check_open_t
*mpo_posixsem_check_open
;
6352 mpo_posixsem_check_post_t
*mpo_posixsem_check_post
;
6353 mpo_posixsem_check_unlink_t
*mpo_posixsem_check_unlink
;
6354 mpo_posixsem_check_wait_t
*mpo_posixsem_check_wait
;
6355 mpo_posixsem_label_associate_t
*mpo_posixsem_label_associate
;
6356 mpo_posixsem_label_destroy_t
*mpo_posixsem_label_destroy
;
6357 mpo_posixsem_label_init_t
*mpo_posixsem_label_init
;
6358 mpo_posixshm_check_create_t
*mpo_posixshm_check_create
;
6359 mpo_posixshm_check_mmap_t
*mpo_posixshm_check_mmap
;
6360 mpo_posixshm_check_open_t
*mpo_posixshm_check_open
;
6361 mpo_posixshm_check_stat_t
*mpo_posixshm_check_stat
;
6362 mpo_posixshm_check_truncate_t
*mpo_posixshm_check_truncate
;
6363 mpo_posixshm_check_unlink_t
*mpo_posixshm_check_unlink
;
6364 mpo_posixshm_label_associate_t
*mpo_posixshm_label_associate
;
6365 mpo_posixshm_label_destroy_t
*mpo_posixshm_label_destroy
;
6366 mpo_posixshm_label_init_t
*mpo_posixshm_label_init
;
6368 mpo_proc_check_debug_t
*mpo_proc_check_debug
;
6369 mpo_proc_check_fork_t
*mpo_proc_check_fork
;
6370 mpo_proc_check_get_task_name_t
*mpo_proc_check_get_task_name
;
6371 mpo_proc_check_get_task_t
*mpo_proc_check_get_task
;
6372 mpo_proc_check_getaudit_t
*mpo_proc_check_getaudit
;
6373 mpo_proc_check_getauid_t
*mpo_proc_check_getauid
;
6374 mpo_proc_check_getlcid_t
*mpo_proc_check_getlcid
;
6375 mpo_proc_check_mprotect_t
*mpo_proc_check_mprotect
;
6376 mpo_proc_check_sched_t
*mpo_proc_check_sched
;
6377 mpo_proc_check_setaudit_t
*mpo_proc_check_setaudit
;
6378 mpo_proc_check_setauid_t
*mpo_proc_check_setauid
;
6379 mpo_proc_check_setlcid_t
*mpo_proc_check_setlcid
;
6380 mpo_proc_check_signal_t
*mpo_proc_check_signal
;
6381 mpo_proc_check_wait_t
*mpo_proc_check_wait
;
6382 mpo_proc_label_destroy_t
*mpo_proc_label_destroy
;
6383 mpo_proc_label_init_t
*mpo_proc_label_init
;
6385 mpo_socket_check_accept_t
*mpo_socket_check_accept
;
6386 mpo_socket_check_accepted_t
*mpo_socket_check_accepted
;
6387 mpo_socket_check_bind_t
*mpo_socket_check_bind
;
6388 mpo_socket_check_connect_t
*mpo_socket_check_connect
;
6389 mpo_socket_check_create_t
*mpo_socket_check_create
;
6390 mpo_socket_check_deliver_t
*mpo_socket_check_deliver
;
6391 mpo_socket_check_kqfilter_t
*mpo_socket_check_kqfilter
;
6392 mpo_socket_check_label_update_t
*mpo_socket_check_label_update
;
6393 mpo_socket_check_listen_t
*mpo_socket_check_listen
;
6394 mpo_socket_check_receive_t
*mpo_socket_check_receive
;
6395 mpo_socket_check_received_t
*mpo_socket_check_received
;
6396 mpo_socket_check_select_t
*mpo_socket_check_select
;
6397 mpo_socket_check_send_t
*mpo_socket_check_send
;
6398 mpo_socket_check_stat_t
*mpo_socket_check_stat
;
6399 mpo_socket_check_setsockopt_t
*mpo_socket_check_setsockopt
;
6400 mpo_socket_check_getsockopt_t
*mpo_socket_check_getsockopt
;
6401 mpo_socket_label_associate_accept_t
*mpo_socket_label_associate_accept
;
6402 mpo_socket_label_associate_t
*mpo_socket_label_associate
;
6403 mpo_socket_label_copy_t
*mpo_socket_label_copy
;
6404 mpo_socket_label_destroy_t
*mpo_socket_label_destroy
;
6405 mpo_socket_label_externalize_t
*mpo_socket_label_externalize
;
6406 mpo_socket_label_init_t
*mpo_socket_label_init
;
6407 mpo_socket_label_internalize_t
*mpo_socket_label_internalize
;
6408 mpo_socket_label_update_t
*mpo_socket_label_update
;
6410 mpo_socketpeer_label_associate_mbuf_t
*mpo_socketpeer_label_associate_mbuf
;
6411 mpo_socketpeer_label_associate_socket_t
*mpo_socketpeer_label_associate_socket
;
6412 mpo_socketpeer_label_destroy_t
*mpo_socketpeer_label_destroy
;
6413 mpo_socketpeer_label_externalize_t
*mpo_socketpeer_label_externalize
;
6414 mpo_socketpeer_label_init_t
*mpo_socketpeer_label_init
;
6416 mpo_system_check_acct_t
*mpo_system_check_acct
;
6417 mpo_system_check_audit_t
*mpo_system_check_audit
;
6418 mpo_system_check_auditctl_t
*mpo_system_check_auditctl
;
6419 mpo_system_check_auditon_t
*mpo_system_check_auditon
;
6420 mpo_system_check_host_priv_t
*mpo_system_check_host_priv
;
6421 mpo_system_check_nfsd_t
*mpo_system_check_nfsd
;
6422 mpo_system_check_reboot_t
*mpo_system_check_reboot
;
6423 mpo_system_check_settime_t
*mpo_system_check_settime
;
6424 mpo_system_check_swapoff_t
*mpo_system_check_swapoff
;
6425 mpo_system_check_swapon_t
*mpo_system_check_swapon
;
6426 mpo_reserved_hook_t
*mpo_reserved7
;
6428 mpo_sysvmsg_label_associate_t
*mpo_sysvmsg_label_associate
;
6429 mpo_sysvmsg_label_destroy_t
*mpo_sysvmsg_label_destroy
;
6430 mpo_sysvmsg_label_init_t
*mpo_sysvmsg_label_init
;
6431 mpo_sysvmsg_label_recycle_t
*mpo_sysvmsg_label_recycle
;
6432 mpo_sysvmsq_check_enqueue_t
*mpo_sysvmsq_check_enqueue
;
6433 mpo_sysvmsq_check_msgrcv_t
*mpo_sysvmsq_check_msgrcv
;
6434 mpo_sysvmsq_check_msgrmid_t
*mpo_sysvmsq_check_msgrmid
;
6435 mpo_sysvmsq_check_msqctl_t
*mpo_sysvmsq_check_msqctl
;
6436 mpo_sysvmsq_check_msqget_t
*mpo_sysvmsq_check_msqget
;
6437 mpo_sysvmsq_check_msqrcv_t
*mpo_sysvmsq_check_msqrcv
;
6438 mpo_sysvmsq_check_msqsnd_t
*mpo_sysvmsq_check_msqsnd
;
6439 mpo_sysvmsq_label_associate_t
*mpo_sysvmsq_label_associate
;
6440 mpo_sysvmsq_label_destroy_t
*mpo_sysvmsq_label_destroy
;
6441 mpo_sysvmsq_label_init_t
*mpo_sysvmsq_label_init
;
6442 mpo_sysvmsq_label_recycle_t
*mpo_sysvmsq_label_recycle
;
6443 mpo_sysvsem_check_semctl_t
*mpo_sysvsem_check_semctl
;
6444 mpo_sysvsem_check_semget_t
*mpo_sysvsem_check_semget
;
6445 mpo_sysvsem_check_semop_t
*mpo_sysvsem_check_semop
;
6446 mpo_sysvsem_label_associate_t
*mpo_sysvsem_label_associate
;
6447 mpo_sysvsem_label_destroy_t
*mpo_sysvsem_label_destroy
;
6448 mpo_sysvsem_label_init_t
*mpo_sysvsem_label_init
;
6449 mpo_sysvsem_label_recycle_t
*mpo_sysvsem_label_recycle
;
6450 mpo_sysvshm_check_shmat_t
*mpo_sysvshm_check_shmat
;
6451 mpo_sysvshm_check_shmctl_t
*mpo_sysvshm_check_shmctl
;
6452 mpo_sysvshm_check_shmdt_t
*mpo_sysvshm_check_shmdt
;
6453 mpo_sysvshm_check_shmget_t
*mpo_sysvshm_check_shmget
;
6454 mpo_sysvshm_label_associate_t
*mpo_sysvshm_label_associate
;
6455 mpo_sysvshm_label_destroy_t
*mpo_sysvshm_label_destroy
;
6456 mpo_sysvshm_label_init_t
*mpo_sysvshm_label_init
;
6457 mpo_sysvshm_label_recycle_t
*mpo_sysvshm_label_recycle
;
6459 mpo_reserved_hook_t
*mpo_reserved8
;
6460 mpo_mount_check_snapshot_revert_t
*mpo_mount_check_snapshot_revert
;
6461 mpo_vnode_check_getattr_t
*mpo_vnode_check_getattr
;
6462 mpo_mount_check_snapshot_create_t
*mpo_mount_check_snapshot_create
;
6463 mpo_mount_check_snapshot_delete_t
*mpo_mount_check_snapshot_delete
;
6464 mpo_vnode_check_clone_t
*mpo_vnode_check_clone
;
6465 mpo_proc_check_get_cs_info_t
*mpo_proc_check_get_cs_info
;
6466 mpo_proc_check_set_cs_info_t
*mpo_proc_check_set_cs_info
;
6468 mpo_iokit_check_hid_control_t
*mpo_iokit_check_hid_control
;
6470 mpo_vnode_check_access_t
*mpo_vnode_check_access
;
6471 mpo_vnode_check_chdir_t
*mpo_vnode_check_chdir
;
6472 mpo_vnode_check_chroot_t
*mpo_vnode_check_chroot
;
6473 mpo_vnode_check_create_t
*mpo_vnode_check_create
;
6474 mpo_vnode_check_deleteextattr_t
*mpo_vnode_check_deleteextattr
;
6475 mpo_vnode_check_exchangedata_t
*mpo_vnode_check_exchangedata
;
6476 mpo_vnode_check_exec_t
*mpo_vnode_check_exec
;
6477 mpo_vnode_check_getattrlist_t
*mpo_vnode_check_getattrlist
;
6478 mpo_vnode_check_getextattr_t
*mpo_vnode_check_getextattr
;
6479 mpo_vnode_check_ioctl_t
*mpo_vnode_check_ioctl
;
6480 mpo_vnode_check_kqfilter_t
*mpo_vnode_check_kqfilter
;
6481 mpo_vnode_check_label_update_t
*mpo_vnode_check_label_update
;
6482 mpo_vnode_check_link_t
*mpo_vnode_check_link
;
6483 mpo_vnode_check_listextattr_t
*mpo_vnode_check_listextattr
;
6484 mpo_vnode_check_lookup_t
*mpo_vnode_check_lookup
;
6485 mpo_vnode_check_open_t
*mpo_vnode_check_open
;
6486 mpo_vnode_check_read_t
*mpo_vnode_check_read
;
6487 mpo_vnode_check_readdir_t
*mpo_vnode_check_readdir
;
6488 mpo_vnode_check_readlink_t
*mpo_vnode_check_readlink
;
6489 mpo_vnode_check_rename_from_t
*mpo_vnode_check_rename_from
;
6490 mpo_vnode_check_rename_to_t
*mpo_vnode_check_rename_to
;
6491 mpo_vnode_check_revoke_t
*mpo_vnode_check_revoke
;
6492 mpo_vnode_check_select_t
*mpo_vnode_check_select
;
6493 mpo_vnode_check_setattrlist_t
*mpo_vnode_check_setattrlist
;
6494 mpo_vnode_check_setextattr_t
*mpo_vnode_check_setextattr
;
6495 mpo_vnode_check_setflags_t
*mpo_vnode_check_setflags
;
6496 mpo_vnode_check_setmode_t
*mpo_vnode_check_setmode
;
6497 mpo_vnode_check_setowner_t
*mpo_vnode_check_setowner
;
6498 mpo_vnode_check_setutimes_t
*mpo_vnode_check_setutimes
;
6499 mpo_vnode_check_stat_t
*mpo_vnode_check_stat
;
6500 mpo_vnode_check_truncate_t
*mpo_vnode_check_truncate
;
6501 mpo_vnode_check_unlink_t
*mpo_vnode_check_unlink
;
6502 mpo_vnode_check_write_t
*mpo_vnode_check_write
;
6503 mpo_vnode_label_associate_devfs_t
*mpo_vnode_label_associate_devfs
;
6504 mpo_vnode_label_associate_extattr_t
*mpo_vnode_label_associate_extattr
;
6505 mpo_vnode_label_associate_file_t
*mpo_vnode_label_associate_file
;
6506 mpo_vnode_label_associate_pipe_t
*mpo_vnode_label_associate_pipe
;
6507 mpo_vnode_label_associate_posixsem_t
*mpo_vnode_label_associate_posixsem
;
6508 mpo_vnode_label_associate_posixshm_t
*mpo_vnode_label_associate_posixshm
;
6509 mpo_vnode_label_associate_singlelabel_t
*mpo_vnode_label_associate_singlelabel
;
6510 mpo_vnode_label_associate_socket_t
*mpo_vnode_label_associate_socket
;
6511 mpo_vnode_label_copy_t
*mpo_vnode_label_copy
;
6512 mpo_vnode_label_destroy_t
*mpo_vnode_label_destroy
;
6513 mpo_vnode_label_externalize_audit_t
*mpo_vnode_label_externalize_audit
;
6514 mpo_vnode_label_externalize_t
*mpo_vnode_label_externalize
;
6515 mpo_vnode_label_init_t
*mpo_vnode_label_init
;
6516 mpo_vnode_label_internalize_t
*mpo_vnode_label_internalize
;
6517 mpo_vnode_label_recycle_t
*mpo_vnode_label_recycle
;
6518 mpo_vnode_label_store_t
*mpo_vnode_label_store
;
6519 mpo_vnode_label_update_extattr_t
*mpo_vnode_label_update_extattr
;
6520 mpo_vnode_label_update_t
*mpo_vnode_label_update
;
6521 mpo_vnode_notify_create_t
*mpo_vnode_notify_create
;
6522 mpo_vnode_check_signature_t
*mpo_vnode_check_signature
;
6523 mpo_vnode_check_uipc_bind_t
*mpo_vnode_check_uipc_bind
;
6524 mpo_vnode_check_uipc_connect_t
*mpo_vnode_check_uipc_connect
;
6526 mpo_proc_check_run_cs_invalid_t
*mpo_proc_check_run_cs_invalid
;
6527 mpo_proc_check_suspend_resume_t
*mpo_proc_check_suspend_resume
;
6529 mpo_thread_userret_t
*mpo_thread_userret
;
6531 mpo_iokit_check_set_properties_t
*mpo_iokit_check_set_properties
;
6533 mpo_system_check_chud_t
*mpo_system_check_chud
;
6535 mpo_vnode_check_searchfs_t
*mpo_vnode_check_searchfs
;
6537 mpo_priv_check_t
*mpo_priv_check
;
6538 mpo_priv_grant_t
*mpo_priv_grant
;
6540 mpo_proc_check_map_anon_t
*mpo_proc_check_map_anon
;
6542 mpo_vnode_check_fsgetpath_t
*mpo_vnode_check_fsgetpath
;
6544 mpo_iokit_check_open_t
*mpo_iokit_check_open
;
6546 mpo_proc_check_ledger_t
*mpo_proc_check_ledger
;
6548 mpo_vnode_notify_rename_t
*mpo_vnode_notify_rename
;
6550 mpo_vnode_check_setacl_t
*mpo_vnode_check_setacl
;
6552 mpo_vnode_notify_deleteextattr_t
*mpo_vnode_notify_deleteextattr
;
6554 mpo_system_check_kas_info_t
*mpo_system_check_kas_info
;
6556 mpo_proc_check_cpumon_t
*mpo_proc_check_cpumon
;
6558 mpo_vnode_notify_open_t
*mpo_vnode_notify_open
;
6560 mpo_system_check_info_t
*mpo_system_check_info
;
6562 mpo_pty_notify_grant_t
*mpo_pty_notify_grant
;
6563 mpo_pty_notify_close_t
*mpo_pty_notify_close
;
6565 mpo_vnode_find_sigs_t
*mpo_vnode_find_sigs
;
6567 mpo_kext_check_load_t
*mpo_kext_check_load
;
6568 mpo_kext_check_unload_t
*mpo_kext_check_unload
;
6570 mpo_proc_check_proc_info_t
*mpo_proc_check_proc_info
;
6571 mpo_vnode_notify_link_t
*mpo_vnode_notify_link
;
6572 mpo_iokit_check_filter_properties_t
*mpo_iokit_check_filter_properties
;
6573 mpo_iokit_check_get_property_t
*mpo_iokit_check_get_property
;
6577 @brief MAC policy handle type
6579 The MAC handle is used to uniquely identify a loaded policy within
6582 A variable of this type is set by mac_policy_register().
6584 typedef unsigned int mac_policy_handle_t
;
6586 #define mpc_t struct mac_policy_conf *
6589 @brief Mac policy configuration
6591 This structure specifies the configuration information for a
6592 MAC policy module. A policy module developer must supply
6593 a short unique policy name, a more descriptive full name, a list of label
6594 namespaces and count, a pointer to the registered enty point operations,
6595 any load time flags, and optionally, a pointer to a label slot identifier.
6597 The Framework will update the runtime flags (mpc_runtime_flags) to
6598 indicate that the module has been registered.
6600 If the label slot identifier (mpc_field_off) is NULL, the Framework
6601 will not provide label storage for the policy. Otherwise, the
6602 Framework will store the label location (slot) in this field.
6604 The mpc_list field is used by the Framework and should not be
6605 modified by policies.
6607 /* XXX - reorder these for better aligment on 64bit platforms */
6608 struct mac_policy_conf
{
6609 const char *mpc_name
; /** policy name */
6610 const char *mpc_fullname
; /** full name */
6611 char const * const *mpc_labelnames
; /** managed label namespaces */
6612 unsigned int mpc_labelname_count
; /** number of managed label namespaces */
6613 struct mac_policy_ops
*mpc_ops
; /** operation vector */
6614 int mpc_loadtime_flags
; /** load time flags */
6615 int *mpc_field_off
; /** label slot */
6616 int mpc_runtime_flags
; /** run time flags */
6617 mpc_t mpc_list
; /** List reference */
6618 void *mpc_data
; /** module data */
6622 @brief MAC policy module registration routine
6624 This function is called to register a policy with the
6625 MAC framework. A policy module will typically call this from the
6626 Darwin KEXT registration routine.
6628 int mac_policy_register(struct mac_policy_conf
*mpc
,
6629 mac_policy_handle_t
*handlep
, void *xd
);
6632 @brief MAC policy module de-registration routine
6634 This function is called to de-register a policy with theD
6635 MAC framework. A policy module will typically call this from the
6636 Darwin KEXT de-registration routine.
6638 int mac_policy_unregister(mac_policy_handle_t handle
);
6641 * Framework entry points for the policies to add audit data.
6643 int mac_audit_text(char *text
, mac_policy_handle_t handle
);
6646 * Calls to assist with use of Apple XATTRs within policy modules.
6648 int mac_vnop_setxattr(struct vnode
*, const char *, char *, size_t);
6649 int mac_vnop_getxattr(struct vnode
*, const char *, char *, size_t,
6651 int mac_vnop_removexattr(struct vnode
*, const char *);
6654 @brief Set an extended attribute on a vnode-based fileglob.
6655 @param fg fileglob representing file to attach the extended attribute
6656 @param name extended attribute name
6657 @param buf buffer of data to use as the extended attribute value
6658 @param len size of buffer
6660 Sets the value of an extended attribute on a file.
6662 Caller must hold an iocount on the vnode represented by the fileglob.
6664 int mac_file_setxattr(struct fileglob
*fg
, const char *name
, char *buf
, size_t len
);
6667 @brief Get an extended attribute from a vnode-based fileglob.
6668 @param fg fileglob representing file to read the extended attribute
6669 @param name extended attribute name
6670 @param buf buffer of data to hold the extended attribute value
6671 @param len size of buffer
6672 @param attrlen size of full extended attribute value
6674 Gets the value of an extended attribute on a file.
6676 Caller must hold an iocount on the vnode represented by the fileglob.
6678 int mac_file_getxattr(struct fileglob
*fg
, const char *name
, char *buf
, size_t len
,
6682 @brief Remove an extended attribute from a vnode-based fileglob.
6683 @param fg fileglob representing file to remove the extended attribute
6684 @param name extended attribute name
6686 Removes the named extended attribute from the file.
6688 Caller must hold an iocount on the vnode represented by the fileglob.
6690 int mac_file_removexattr(struct fileglob
*fg
, const char *name
);
6694 * Arbitrary limit on how much data will be logged by the audit
6695 * entry points above.
6697 #define MAC_AUDIT_DATA_LIMIT 1024
6700 * Values returned by mac_audit_{pre,post}select. To combine the responses
6701 * of the security policies into a single decision,
6702 * mac_audit_{pre,post}select() choose the greatest value returned.
6704 #define MAC_AUDIT_DEFAULT 0 /* use system behavior */
6705 #define MAC_AUDIT_NO 1 /* force not auditing this event */
6706 #define MAC_AUDIT_YES 2 /* force auditing this event */
6708 // \defgroup mpc_loadtime_flags Flags for the mpc_loadtime_flags field
6711 @name Flags for the mpc_loadtime_flags field
6712 @see mac_policy_conf
6714 This is the complete list of flags that are supported by the
6715 mpc_loadtime_flags field of the mac_policy_conf structure. These
6716 flags specify the load time behavior of MAC Framework policy
6723 @brief Flag to indicate registration preference
6725 This flag indicates that the policy module must be loaded and
6726 initialized early in the boot process. If the flag is specified,
6727 attempts to register the module following boot will be rejected. The
6728 flag may be used by policies that require pervasive labeling of all
6729 system objects, and cannot handle objects that have not been
6730 properly initialized by the policy.
6732 #define MPC_LOADTIME_FLAG_NOTLATE 0x00000001
6735 @brief Flag to indicate unload preference
6737 This flag indicates that the policy module may be unloaded. If this
6738 flag is not set, then the policy framework will reject requests to
6739 unload the module. This flag might be used by modules that allocate
6740 label state and are unable to free that state at runtime, or for
6741 modules that simply do not want to permit unload operations.
6743 #define MPC_LOADTIME_FLAG_UNLOADOK 0x00000002
6748 XXX This flag is not yet supported.
6750 #define MPC_LOADTIME_FLAG_LABELMBUFS 0x00000004
6753 @brief Flag to indicate a base policy
6755 This flag indicates that the policy module is a base policy. Only
6756 one module can declare itself as base, otherwise the boot process
6759 #define MPC_LOADTIME_BASE_POLICY 0x00000008
6764 @brief Policy registration flag
6765 @see mac_policy_conf
6767 This flag indicates that the policy module has been successfully
6768 registered with the TrustedBSD MAC Framework. The Framework will
6769 set this flag in the mpc_runtime_flags field of the policy's
6770 mac_policy_conf structure after registering the policy.
6772 #define MPC_RUNTIME_FLAG_REGISTERED 0x00000001
6775 * Depends on POLICY_VER
6779 #define POLICY_VER 1.0
6782 #define MAC_POLICY_SET(handle, mpops, mpname, mpfullname, lnames, lcount, slot, lflags, rflags) \
6783 static struct mac_policy_conf mpname##_mac_policy_conf = { \
6784 .mpc_name = #mpname, \
6785 .mpc_fullname = mpfullname, \
6786 .mpc_labelnames = lnames, \
6787 .mpc_labelname_count = lcount, \
6789 .mpc_loadtime_flags = lflags, \
6790 .mpc_field_off = slot, \
6791 .mpc_runtime_flags = rflags \
6794 static kern_return_t \
6795 kmod_start(kmod_info_t *ki, void *xd) \
6797 return mac_policy_register(&mpname##_mac_policy_conf, \
6801 static kern_return_t \
6802 kmod_stop(kmod_info_t *ki, void *xd) \
6804 return mac_policy_unregister(handle); \
6807 extern kern_return_t _start(kmod_info_t *ki, void *data); \
6808 extern kern_return_t _stop(kmod_info_t *ki, void *data); \
6810 KMOD_EXPLICIT_DECL(security.mpname, POLICY_VER, _start, _stop) \
6811 kmod_start_func_t *_realmain = kmod_start; \
6812 kmod_stop_func_t *_antimain = kmod_stop; \
6813 int _kext_apple_cc = __APPLE_CC__
6816 #define LABEL_TO_SLOT(l, s) (l)->l_perpolicy[s]
6819 * Policy interface to map a struct label pointer to per-policy data.
6820 * Typically, policies wrap this in their own accessor macro that casts an
6821 * intptr_t to a policy-specific data type.
6823 intptr_t mac_label_get(struct label
*l
, int slot
);
6824 void mac_label_set(struct label
*l
, int slot
, intptr_t v
);
6826 #define mac_get_mpc(h) (mac_policy_list.entries[h].mpc)
6829 @name Flags for MAC allocator interfaces
6831 These flags are passed to the Darwin kernel allocator routines to
6832 indicate whether the allocation is permitted to block or not.
6833 Caution should be taken; some operations are not permitted to sleep,
6834 and some types of locks cannot be held when sleeping.
6840 @brief Allocation operations may block
6842 If memory is not immediately available, the allocation routine
6843 will block (typically sleeping) until memory is available.
6845 @warning Inappropriate use of this flag may cause kernel panics.
6847 #define MAC_WAITOK 0
6850 @brief Allocation operations may not block
6852 Rather than blocking, the allocator may return an error if memory
6853 is not immediately available. This type of allocation will not
6854 sleep, preserving locking semantics.
6856 #define MAC_NOWAIT 1
6860 #endif /* !_SECURITY_MAC_POLICY_H_ */