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_policy_conf
;
123 * proc_ident_t support, see: rdar://problem/58928152
124 * Should be removed once all dependent parties adopt
127 #define MAC_PROC_IDENT_SUPPORT
129 #ifndef _KAUTH_CRED_T
130 #define _KAUTH_CRED_T
131 typedef struct ucred
*kauth_cred_t
;
132 #endif /* !_KAUTH_CRED_T */
134 #ifndef __IOKIT_PORTS_DEFINED__
135 #define __IOKIT_PORTS_DEFINED__
138 typedef OSObject
*io_object_t
;
141 typedef struct OSObject
*io_object_t
;
143 #endif /* __IOKIT_PORTS_DEFINED__ */
146 * MAC entry points are generally named using the following template:
148 * mpo_<object>_<operation>()
152 * mpo_<object>_check_<operation>()
154 * Entry points are sorted by object type.
156 * It may be desirable also to consider some subsystems as "objects", such
157 * as system, iokit, etc.
161 * @name Entry Points for Label Management
163 * These are the entry points corresponding to the life cycle events for
164 * kernel objects, such as initialization, creation, and destruction.
166 * Most policies (that use labels) will initialize labels by allocating
167 * space for policy-specific data. In most cases, it is permitted to
168 * sleep during label initialization operations; it will be noted when
169 * it is not permitted.
171 * Initialization usually will not require doing more than allocating a
172 * generic label for the given object. What follows initialization is
173 * creation, where a label is made specific to the object it is associated
174 * with. Destruction occurs when the label is no longer needed, such as
175 * when the corresponding object is destroyed. All necessary cleanup should
176 * be performed in label destroy operations.
178 * Where possible, the label entry points have identical parameters. If
179 * the policy module does not require structure-specific label
180 * information, the same function may be registered in the policy
181 * operation vector. Many policies will implement two such generic
182 * allocation calls: one to handle sleepable requests, and one to handle
183 * potentially non-sleepable requests.
188 * @brief Audit event postselection
189 * @param cred Subject credential
190 * @param syscode Syscall number
191 * @param args Syscall arguments
192 * @param error Syscall errno
193 * @param retval Syscall return value
195 * This is the MAC Framework audit postselect, which is called before
196 * exiting a syscall to determine if an audit event should be committed.
197 * A return value of MAC_AUDIT_NO forces the audit record to be suppressed.
198 * Any other return value results in the audit record being committed.
200 * @warning The suppression behavior will probably go away in Apple's
201 * future version of the audit implementation.
203 * @return Return MAC_AUDIT_NO to force suppression of the audit record.
204 * Any other value results in the audit record being committed.
207 typedef int mpo_audit_check_postselect_t(
209 unsigned short syscode
,
215 * @brief Audit event preselection
216 * @param cred Subject credential
217 * @param syscode Syscall number
218 * @param args Syscall arguments
220 * This is the MAC Framework audit preselect, which is called before a
221 * syscall is entered to determine if an audit event should be created.
222 * If the MAC policy forces the syscall to be audited, MAC_AUDIT_YES should be
223 * returned. A return value of MAC_AUDIT_NO causes the audit record to
224 * be suppressed. Returning MAC_POLICY_DEFAULT indicates that the policy wants
225 * to defer to the system's existing preselection mechanism.
227 * When policies return different preferences, the Framework decides what action
228 * to take based on the following policy. If any policy returns MAC_AUDIT_YES,
229 * then create an audit record, else if any policy returns MAC_AUDIT_NO, then
230 * suppress the creations of an audit record, else defer to the system's
231 * existing preselection mechanism.
233 * @warning The audit implementation in Apple's current version is
234 * incomplete, so the MAC policies have priority over the system's existing
235 * mechanisms. This will probably change in the future version where
236 * the audit implementation is more complete.
238 * @return Return MAC_AUDIT_YES to force auditing of the syscall,
239 * MAC_AUDIT_NO to force no auditing of the syscall, MAC_AUDIT_DEFAULT
240 * to allow auditing mechanisms to determine if the syscall is audited.
243 typedef int mpo_audit_check_preselect_t(
245 unsigned short syscode
,
249 * @brief Indicate desire to change the process label at exec time
250 * @param old Existing subject credential
251 * @param vp File being executed
252 * @param offset Offset of binary within file being executed
253 * @param scriptvp Script being executed by interpreter, if any.
254 * @param vnodelabel Label corresponding to vp
255 * @param scriptvnodelabel Script vnode label
256 * @param execlabel Userspace provided execution label
257 * @param p Object process
258 * @param macpolicyattr MAC policy-specific spawn attribute data
259 * @param macpolicyattrlen Length of policy-specific spawn attribute data
261 * @see mpo_cred_label_update_execve_t
262 * @see mpo_vnode_check_exec_t
264 * Indicate whether this policy intends to update the label of a newly
265 * created credential from the existing subject credential (old). This
266 * call occurs when a process executes the passed vnode. If a policy
267 * returns success from this entry point, the mpo_cred_label_update_execve
268 * entry point will later be called with the same parameters. Access
269 * has already been checked via the mpo_vnode_check_exec entry point,
270 * this entry point is necessary to preserve kernel locking constraints
271 * during program execution.
273 * The supplied vnode and vnodelabel correspond with the file actually
274 * being executed; in the case that the file is interpreted (for
275 * example, a script), the label of the original exec-time vnode has
276 * been preserved in scriptvnodelabel.
278 * The final label, execlabel, corresponds to a label supplied by a
279 * user space application through the use of the mac_execve system call.
281 * The vnode lock is held during this operation. No changes should be
282 * made to the old credential structure.
284 * @warning Even if a policy returns 0, it should behave correctly in
285 * the presence of an invocation of mpo_cred_label_update_execve, as that
286 * call may happen as a result of another policy requesting a transition.
288 * @return Non-zero if a transition is required, 0 otherwise.
290 typedef int mpo_cred_check_label_update_execve_t(
294 struct vnode
*scriptvp
,
295 struct label
*vnodelabel
,
296 struct label
*scriptvnodelabel
,
297 struct label
*execlabel
,
300 size_t macpolicyattrlen
303 * @brief Access control check for relabelling processes
304 * @param cred Subject credential
305 * @param newlabel New label to apply to the user credential
306 * @see mpo_cred_label_update_t
309 * Determine whether the subject identified by the credential can relabel
310 * itself to the supplied new label (newlabel). This access control check
311 * is called when the mac_set_proc system call is invoked. A user space
312 * application will supply a new value, the value will be internalized
313 * and provided in newlabel.
315 * @return Return 0 if access is granted, otherwise an appropriate value for
316 * errno should be returned.
318 typedef int mpo_cred_check_label_update_t(
320 struct label
*newlabel
323 * @brief Access control check for visibility of other subjects
324 * @param u1 Subject credential
325 * @param u2 Object credential
327 * Determine whether the subject identified by the credential u1 can
328 * "see" other subjects with the passed subject credential u2. This call
329 * may be made in a number of situations, including inter-process status
330 * sysctls used by ps, and in procfs lookups.
332 * @return Return 0 if access is granted, otherwise an appropriate value for
333 * errno should be returned. Suggested failure: EACCES for label mismatch,
334 * EPERM for lack of privilege, or ESRCH to hide visibility.
336 typedef int mpo_cred_check_visible_t(
341 * @brief Associate a credential with a new process at fork
342 * @param cred credential to inherited by new process
343 * @param proc the new process
345 * Allow a process to associate the credential with a new
346 * process for reference countng purposes.
347 * NOTE: the credential can be dis-associated in ways other
348 * than exit - so this strategy is flawed - should just
349 * catch label destroy callback.
351 typedef void mpo_cred_label_associate_fork_t(
356 * @brief Create the first process
357 * @param cred Subject credential to be labeled
359 * Create the subject credential of process 0, the parent of all BSD
360 * kernel processes. Policies should update the label in the
361 * previously initialized credential structure.
363 typedef void mpo_cred_label_associate_kernel_t(
367 * @brief Create a credential label
368 * @param parent_cred Parent credential
369 * @param child_cred Child credential
371 * Set the label of a newly created credential, most likely using the
372 * information in the supplied parent credential.
374 * @warning This call is made when crcopy or crdup is invoked on a
375 * newly created struct ucred, and should not be confused with a
376 * process fork or creation event.
378 typedef void mpo_cred_label_associate_t(
379 kauth_cred_t parent_cred
,
380 kauth_cred_t child_cred
383 * @brief Create the first process
384 * @param cred Subject credential to be labeled
386 * Create the subject credential of process 1, the parent of all BSD
387 * user processes. Policies should update the label in the previously
388 * initialized credential structure. This is the 'init' process.
390 typedef void mpo_cred_label_associate_user_t(
394 * @brief Destroy credential label
395 * @param label The label to be destroyed
397 * Destroy a user credential label. Since the user credential
398 * is going out of scope, policy modules should free any internal
399 * storage associated with the label so that it may be destroyed.
401 typedef void mpo_cred_label_destroy_t(
405 * @brief Externalize a user credential label for auditing
406 * @param label Label to be externalized
407 * @param element_name Name of the label namespace for which labels should be
409 * @param sb String buffer to be filled with a text representation of the label
411 * Produce an external representation of the label on a user credential for
412 * inclusion in an audit record. An externalized label consists of a text
413 * representation of the label contents that will be added to the audit record
414 * as part of a text token. Policy-agnostic user space tools will display
415 * this externalized version.
417 * @return 0 on success, return non-zero if an error occurs while
418 * externalizing the label data.
421 typedef int mpo_cred_label_externalize_audit_t(
427 * @brief Externalize a user credential label
428 * @param label Label to be externalized
429 * @param element_name Name of the label namespace for which labels should be
431 * @param sb String buffer to be filled with a text representation of the label
433 * Produce an external representation of the label on a user
434 * credential. An externalized label consists of a text representation
435 * of the label contents that can be used with user applications.
436 * Policy-agnostic user space tools will display this externalized
439 * @return 0 on success, return non-zero if an error occurs while
440 * externalizing the label data.
443 typedef int mpo_cred_label_externalize_t(
449 * @brief Initialize user credential label
450 * @param label New label to initialize
452 * Initialize the label for a newly instantiated user credential.
453 * Sleeping is permitted.
455 typedef void mpo_cred_label_init_t(
459 * @brief Internalize a user credential label
460 * @param label Label to be internalized
461 * @param element_name Name of the label namespace for which the label should
463 * @param element_data Text data to be internalized
465 * Produce a user credential label from an external representation. An
466 * externalized label consists of a text representation of the label
467 * contents that can be used with user applications. Policy-agnostic
468 * user space tools will forward text version to the kernel for
469 * processing by individual policy modules.
471 * The policy's internalize entry points will be called only if the
472 * policy has registered interest in the label namespace.
474 * @return 0 on success, Otherwise, return non-zero if an error occurs
475 * while internalizing the label data.
478 typedef int mpo_cred_label_internalize_t(
484 * @brief Update credential at exec time
485 * @param old_cred Existing subject credential
486 * @param new_cred New subject credential to be labeled
487 * @param p Object process.
488 * @param vp File being executed
489 * @param offset Offset of binary within file being executed
490 * @param scriptvp Script being executed by interpreter, if any.
491 * @param vnodelabel Label corresponding to vp
492 * @param scriptvnodelabel Script vnode label
493 * @param execlabel Userspace provided execution label
494 * @param csflags Code signing flags to be set after exec
495 * @param macpolicyattr MAC policy-specific spawn attribute data.
496 * @param macpolicyattrlen Length of policy-specific spawn attribute data.
498 * @see mpo_cred_check_label_update_execve_t
499 * @see mpo_vnode_check_exec_t
501 * Update the label of a newly created credential (new) from the
502 * existing subject credential (old). This call occurs when a process
503 * executes the passed vnode and one of the loaded policy modules has
504 * returned success from the mpo_cred_check_label_update_execve entry point.
505 * Access has already been checked via the mpo_vnode_check_exec entry
506 * point, this entry point is only used to update any policy state.
508 * The supplied vnode and vnodelabel correspond with the file actually
509 * being executed; in the case that the file is interpreted (for
510 * example, a script), the label of the original exec-time vnode has
511 * been preserved in scriptvnodelabel.
513 * The final label, execlabel, corresponds to a label supplied by a
514 * user space application through the use of the mac_execve system call.
516 * If non-NULL, the value pointed to by disjointp will be set to 0 to
517 * indicate that the old and new credentials are not disjoint, or 1 to
518 * indicate that they are.
520 * The vnode lock is held during this operation. No changes should be
521 * made to the old credential structure.
522 * @return 0 on success, Otherwise, return non-zero if update results in
523 * termination of child.
525 typedef int mpo_cred_label_update_execve_t(
526 kauth_cred_t old_cred
,
527 kauth_cred_t new_cred
,
531 struct vnode
*scriptvp
,
532 struct label
*vnodelabel
,
533 struct label
*scriptvnodelabel
,
534 struct label
*execlabel
,
537 size_t macpolicyattrlen
,
541 * @brief Update a credential label
542 * @param cred The existing credential
543 * @param newlabel A new label to apply to the credential
544 * @see mpo_cred_check_label_update_t
547 * Update the label on a user credential, using the supplied new label.
548 * This is called as a result of a process relabel operation. Access
549 * control was already confirmed by mpo_cred_check_label_update.
551 typedef void mpo_cred_label_update_t(
553 struct label
*newlabel
556 * @brief Create a new devfs device
557 * @param dev Major and minor numbers of special file
558 * @param de "inode" of new device file
559 * @param label Destination label
560 * @param fullpath Path relative to mount (e.g. /dev) of new device file
562 * This entry point labels a new devfs device. The label will likely be based
563 * on the path to the device, or the major and minor numbers.
564 * The policy should store an appropriate label into 'label'.
566 typedef void mpo_devfs_label_associate_device_t(
573 * @brief Create a new devfs directory
574 * @param dirname Name of new directory
575 * @param dirnamelen Length of 'dirname'
576 * @param de "inode" of new directory
577 * @param label Destination label
578 * @param fullpath Path relative to mount (e.g. /dev) of new directory
580 * This entry point labels a new devfs directory. The label will likely be
581 * based on the path of the new directory. The policy should store an appropriate
582 * label into 'label'. The devfs root directory is labelled in this way.
584 typedef void mpo_devfs_label_associate_directory_t(
592 * @brief Copy a devfs label
593 * @param src Source devfs label
594 * @param dest Destination devfs label
596 * Copy the label information from src to dest. The devfs file system
597 * often duplicates (splits) existing device nodes rather than creating
600 typedef void mpo_devfs_label_copy_t(
605 * @brief Destroy devfs label
606 * @param label The label to be destroyed
608 * Destroy a devfs entry label. Since the object is going out
609 * of scope, policy modules should free any internal storage associated
610 * with the label so that it may be destroyed.
612 typedef void mpo_devfs_label_destroy_t(
616 * @brief Initialize devfs label
617 * @param label New label to initialize
619 * Initialize the label for a newly instantiated devfs entry. Sleeping
622 typedef void mpo_devfs_label_init_t(
626 * @brief Update a devfs label after relabelling its vnode
627 * @param mp Devfs mount point
628 * @param de Affected devfs directory entry
629 * @param delabel Label of devfs directory entry
630 * @param vp Vnode associated with de
631 * @param vnodelabel New label of vnode
633 * Update a devfs label when its vnode is manually relabelled,
634 * for example with setfmac(1). Typically, this will simply copy
635 * the vnode label into the devfs label.
637 typedef void mpo_devfs_label_update_t(
640 struct label
*delabel
,
642 struct label
*vnodelabel
645 * @brief Access control for sending an exception to an exception action
646 * @param crashlabel The crashing process's label
647 * @param action Exception action
648 * @param exclabel Policy label for exception action
650 * Determine whether the the exception message caused by the victim
651 * process can be sent to the exception action. The policy may compare
652 * credentials in the crashlabel, which are derived from the process at
653 * the time the exception occurs, with the credentials in the exclabel,
654 * which was set at the time the exception port was set, to determine
655 * its decision. Note that any process from which the policy derived
656 * any credentials may not exist anymore at the time of this policy
657 * operation. Sleeping is permitted.
659 * @return Return 0 if the message can be sent, otherwise an
660 * appropriate value for errno should be returned.
662 typedef int mpo_exc_action_check_exception_send_t(
663 struct label
*crashlabel
,
664 struct exception_action
*action
,
665 struct label
*exclabel
668 * @brief Associate an exception action label
669 * @param action Exception action to label
670 * @param exclabel Policy label to be filled in for exception action
672 * Set the label on an exception action.
674 typedef void mpo_exc_action_label_associate_t(
675 struct exception_action
*action
,
676 struct label
*exclabel
679 * @brief Destroy exception action label
680 * @param label The label to be destroyed
682 * Destroy the label on an exception action. Since the object is going
683 * out of scope, policy modules should free any internal storage
684 * associated with the label so that it may be destroyed. Sleeping is
687 typedef void mpo_exc_action_label_destroy_t(
691 * @brief Populate an exception action label with process credentials
692 * @param label The label to be populated
693 * @param proc Process to derive credentials from
695 * Populate a label with credentials derived from a process. At
696 * exception delivery time, the policy should compare credentials of the
697 * process that set an exception ports with the credentials of the
698 * process or corpse that experienced the exception. Note that the
699 * process that set the port may not exist at that time anymore, so
700 * labels should carry copies of live credentials if necessary.
702 typedef void mpo_exc_action_label_populate_t(
707 * @brief Initialize exception action label
708 * @param label New label to initialize
710 * Initialize a label for an exception action. Usually performs
711 * policy specific allocations. Sleeping is permitted.
713 typedef int mpo_exc_action_label_init_t(
717 * @brief Update the label on an exception action
718 * @param action Exception action that the label belongs to (may be
720 * @param label Policy label to update
721 * @param newlabel New label for update
723 * Update the credentials of an exception action from the given
724 * label. The policy should copy over any credentials (process and
725 * otherwise) from the new label into the label to update. Must not
726 * sleep, must be quick and can be called with locks held.
728 typedef int mpo_exc_action_label_update_t(
729 struct exception_action
*action
,
731 struct label
*newlabel
734 * @brief Access control for changing the offset of a file descriptor
735 * @param cred Subject credential
736 * @param fg Fileglob structure
737 * @param label Policy label for fg
739 * Determine whether the subject identified by the credential can
740 * change the offset of the file represented by fg.
742 * @return Return 0 if access if granted, otherwise an appropriate
743 * value for errno should be returned.
745 typedef int mpo_file_check_change_offset_t(
751 * @brief Access control for creating a file descriptor
752 * @param cred Subject credential
754 * Determine whether the subject identified by the credential can
755 * allocate a new file descriptor.
757 * @return Return 0 if access if granted, otherwise an appropriate
758 * value for errno should be returned.
760 typedef int mpo_file_check_create_t(
764 * @brief Access control for duplicating a file descriptor
765 * @param cred Subject credential
766 * @param fg Fileglob structure
767 * @param label Policy label for fg
768 * @param newfd New file descriptor number
770 * Determine whether the subject identified by the credential can
771 * duplicate the fileglob structure represented by fg and as file
772 * descriptor number newfd.
774 * @return Return 0 if access if granted, otherwise an appropriate
775 * value for errno should be returned.
777 typedef int mpo_file_check_dup_t(
784 * @brief Access control check for fcntl
785 * @param cred Subject credential
786 * @param fg Fileglob structure
787 * @param label Policy label for fg
788 * @param cmd Control operation to be performed; see fcntl(2)
789 * @param arg fcnt arguments; see fcntl(2)
791 * Determine whether the subject identified by the credential can perform
792 * the file control operation indicated by cmd.
794 * @return Return 0 if access is granted, otherwise an appropriate value for
795 * errno should be returned.
797 typedef int mpo_file_check_fcntl_t(
805 * @brief Access control check for mac_get_fd
806 * @param cred Subject credential
807 * @param fg Fileglob structure
808 * @param elements Element buffer
809 * @param len Length of buffer
811 * Determine whether the subject identified by the credential should be allowed
812 * to get an externalized version of the label on the object indicated by fd.
814 * @return Return 0 if access is granted, otherwise an appropriate value for
815 * errno should be returned.
817 typedef int mpo_file_check_get_t(
824 * @brief Access control for getting the offset of a file descriptor
825 * @param cred Subject credential
826 * @param fg Fileglob structure
827 * @param label Policy label for fg
829 * Determine whether the subject identified by the credential can
830 * get the offset of the file represented by fg.
832 * @return Return 0 if access if granted, otherwise an appropriate
833 * value for errno should be returned.
835 typedef int mpo_file_check_get_offset_t(
841 * @brief Access control for inheriting a file descriptor
842 * @param cred Subject credential
843 * @param fg Fileglob structure
844 * @param label Policy label for fg
846 * Determine whether the subject identified by the credential can
847 * inherit the fileglob structure represented by fg.
849 * @return Return 0 if access if granted, otherwise an appropriate
850 * value for errno should be returned.
852 typedef int mpo_file_check_inherit_t(
858 * @brief Access control check for file ioctl
859 * @param cred Subject credential
860 * @param fg Fileglob structure
861 * @param label Policy label for fg
862 * @param cmd The ioctl command; see ioctl(2)
864 * Determine whether the subject identified by the credential can perform
865 * the ioctl operation indicated by cmd.
867 * @warning Since ioctl data is opaque from the standpoint of the MAC
868 * framework, policies must exercise extreme care when implementing
869 * access control checks.
871 * @return Return 0 if access is granted, otherwise an appropriate value for
872 * errno should be returned.
875 typedef int mpo_file_check_ioctl_t(
882 * @brief Access control check for file locking
883 * @param cred Subject credential
884 * @param fg Fileglob structure
885 * @param label Policy label for fg
886 * @param op The lock operation (F_GETLK, F_SETLK, F_UNLK)
887 * @param fl The flock structure
889 * Determine whether the subject identified by the credential can perform
890 * the lock operation indicated by op and fl on the file represented by fg.
892 * @return Return 0 if access is granted, otherwise an appropriate value for
893 * errno should be returned.
896 typedef int mpo_file_check_lock_t(
904 * @brief Check with library validation if a macho slice is allowed to be combined into a proc.
905 * @param p Subject process
906 * @param fg Fileglob structure
907 * @param slice_offset offset of the code slice
908 * @param error_message error message returned to user-space in case of error (userspace pointer)
909 * @param error_message_size error message size
911 * Its a little odd that the MAC/kext writes into userspace since this
912 * implies there is only one MAC module that implements this, however
913 * the alterantive is to allocate memory in xnu, on the hope that
914 * the MAC module will use it, or allocated in the MAC module and then
915 * free it in xnu. Either of these are very appeling, so lets go with
916 * the slightly more hacky way.
918 * @return Return 0 if access is granted, otherwise an appropriate value for
919 * errno should be returned.
921 typedef int mpo_file_check_library_validation_t(
925 user_long_t error_message
,
926 size_t error_message_size
929 * @brief Access control check for mapping a file
930 * @param cred Subject credential
931 * @param fg fileglob representing file to map
932 * @param label Policy label associated with vp
933 * @param prot mmap protections; see mmap(2)
934 * @param flags Type of mapped object; see mmap(2)
935 * @param maxprot Maximum rights
937 * Determine whether the subject identified by the credential should be
938 * allowed to map the file represented by fg with the protections specified
939 * in prot. The maxprot field holds the maximum permissions on the new
940 * mapping, a combination of VM_PROT_READ, VM_PROT_WRITE, and VM_PROT_EXECUTE.
941 * To avoid overriding prior access control checks, a policy should only
942 * remove flags from maxprot.
944 * @return Return 0 if access is granted, otherwise an appropriate value for
945 * errno should be returned. Suggested failure: EACCES for label mismatch or
946 * EPERM for lack of privilege.
948 typedef int mpo_file_check_mmap_t(
958 * @brief Downgrade the mmap protections
959 * @param cred Subject credential
960 * @param fg file to map
961 * @param label Policy label associated with vp
962 * @param prot mmap protections to be downgraded
964 * Downgrade the mmap protections based on the subject and object labels.
966 typedef void mpo_file_check_mmap_downgrade_t(
973 * @brief Access control for receiving a file descriptor
974 * @param cred Subject credential
975 * @param fg Fileglob structure
976 * @param label Policy label for fg
978 * Determine whether the subject identified by the credential can
979 * receive the fileglob structure represented by fg.
981 * @return Return 0 if access if granted, otherwise an appropriate
982 * value for errno should be returned.
984 typedef int mpo_file_check_receive_t(
990 * @brief Access control check for mac_set_fd
991 * @param cred Subject credential
992 * @param fg Fileglob structure
993 * @param elements Elements buffer
994 * @param len Length of elements buffer
996 * Determine whether the subject identified by the credential can
997 * perform the mac_set_fd operation. The mac_set_fd operation is used
998 * to associate a MAC label with a file.
1000 * @return Return 0 if access is granted, otherwise an appropriate value for
1001 * errno should be returned.
1003 typedef int mpo_file_check_set_t(
1005 struct fileglob
*fg
,
1010 * @brief Inform MAC policies that file is being closed
1011 * @param cred Subject credential
1012 * @param fg Fileglob structure
1013 * @param label Policy label for fg
1014 * @param modified Boolean; 1 if file was modified, 0 otherwise
1016 * Called when an open file is being closed, as a result of a call to
1017 * close(2), the process exiting, or exec(2) w/O_CLOEXEC set.
1019 typedef void mpo_file_notify_close_t(
1021 struct fileglob
*fg
,
1022 struct label
*label
,
1026 * @brief Create file label
1027 * @param cred Subject credential
1028 * @param fg Fileglob structure
1029 * @param label Policy label for fg
1031 typedef void mpo_file_label_associate_t(
1033 struct fileglob
*fg
,
1037 * @brief Destroy file label
1038 * @param label The label to be destroyed
1040 * Destroy the label on a file descriptor. In this entry point, a
1041 * policy module should free any internal storage associated with
1042 * label so that it may be destroyed.
1044 typedef void mpo_file_label_destroy_t(
1048 * @brief Initialize file label
1049 * @param label New label to initialize
1051 typedef void mpo_file_label_init_t(
1055 * @brief Access control check for opening an I/O Kit device
1056 * @param cred Subject credential
1057 * @param user_client User client instance
1058 * @param user_client_type User client type
1060 * Determine whether the subject identified by the credential can open an
1061 * I/O Kit device at the passed path of the passed user client class and
1064 * @return Return 0 if access is granted, or an appropriate value for
1065 * errno should be returned.
1067 typedef int mpo_iokit_check_open_t(
1069 io_object_t user_client
,
1070 unsigned int user_client_type
1073 * @brief Access control check for setting I/O Kit device properties
1074 * @param cred Subject credential
1075 * @param entry Target device
1076 * @param properties Property list
1078 * Determine whether the subject identified by the credential can set
1079 * properties on an I/O Kit device.
1081 * @return Return 0 if access is granted, or an appropriate value for
1082 * errno should be returned.
1084 typedef int mpo_iokit_check_set_properties_t(
1087 io_object_t properties
1090 * @brief Indicate desire to filter I/O Kit devices properties
1091 * @param cred Subject credential
1092 * @param entry Target device
1093 * @see mpo_iokit_check_get_property_t
1095 * Indicate whether this policy may restrict the subject credential
1096 * from reading properties of the target device.
1097 * If a policy returns success from this entry point, the
1098 * mpo_iokit_check_get_property entry point will later be called
1099 * for each property that the subject credential tries to read from
1100 * the target device.
1102 * This entry point is primarilly to optimize bulk property reads
1103 * by skipping calls to the mpo_iokit_check_get_property entry point
1104 * for credentials / devices no MAC policy is interested in.
1106 * @warning Even if a policy returns 0, it should behave correctly in
1107 * the presence of an invocation of mpo_iokit_check_get_property, as that
1108 * call may happen as a result of another policy requesting a transition.
1110 * @return Non-zero if a transition is required, 0 otherwise.
1112 typedef int mpo_iokit_check_filter_properties_t(
1117 * @brief Access control check for getting I/O Kit device properties
1118 * @param cred Subject credential
1119 * @param entry Target device
1120 * @param name Property name
1122 * Determine whether the subject identified by the credential can get
1123 * properties on an I/O Kit device.
1125 * @return Return 0 if access is granted, or an appropriate value for
1128 typedef int mpo_iokit_check_get_property_t(
1134 * @brief Access control check for software HID control
1135 * @param cred Subject credential
1137 * Determine whether the subject identified by the credential can
1138 * control the HID (Human Interface Device) subsystem, such as to
1139 * post synthetic keypresses, pointer movement and clicks.
1141 * @return Return 0 if access is granted, or an appropriate value for
1144 typedef int mpo_iokit_check_hid_control_t(
1148 * @brief Access control check for fsctl
1149 * @param cred Subject credential
1150 * @param mp The mount point
1151 * @param label Label associated with the mount point
1152 * @param cmd Filesystem-dependent request code; see fsctl(2)
1154 * Determine whether the subject identified by the credential can perform
1155 * the volume operation indicated by com.
1157 * @warning The fsctl() system call is directly analogous to ioctl(); since
1158 * the associated data is opaque from the standpoint of the MAC framework
1159 * and since these operations can affect many aspects of system operation,
1160 * policies must exercise extreme care when implementing access control checks.
1162 * @return Return 0 if access is granted, otherwise an appropriate value for
1163 * errno should be returned.
1165 typedef int mpo_mount_check_fsctl_t(
1168 struct label
*label
,
1172 * @brief Access control check for the retrieval of file system attributes
1173 * @param cred Subject credential
1174 * @param mp The mount structure of the file system
1175 * @param vfa The attributes requested
1177 * This entry point determines whether given subject can get information
1178 * about the given file system. This check happens during statfs() syscalls,
1179 * but is also used by other parts within the kernel such as the audit system.
1181 * @return Return 0 if access is granted, otherwise an appropriate value for
1182 * errno should be returned.
1184 * @note Policies may change the contents of vfa to alter the list of
1185 * file system attributes returned.
1188 typedef int mpo_mount_check_getattr_t(
1191 struct label
*mp_label
,
1192 struct vfs_attr
*vfa
1195 * @brief Access control check for mount point relabeling
1196 * @param cred Subject credential
1197 * @param mp Object file system mount point
1198 * @param mntlabel Policy label for fle system mount point
1200 * Determine whether the subject identified by the credential can relabel
1201 * the mount point. This call is made when a file system mount is updated.
1203 * @return Return 0 if access is granted, otherwise an appropriate value for
1204 * errno should be returned. Suggested failure: EACCES for label mismatch
1205 * or EPERM for lack of privilege.
1207 typedef int mpo_mount_check_label_update_t(
1210 struct label
*mntlabel
1213 * @brief Access control check for mounting a file system
1214 * @param cred Subject credential
1215 * @param vp Vnode that is to be the mount point
1216 * @param vlabel Label associated with the vnode
1217 * @param cnp Component name for vp
1218 * @param vfc_name Filesystem type name
1220 * Determine whether the subject identified by the credential can perform
1221 * the mount operation on the target vnode.
1223 * @return Return 0 if access is granted, otherwise an appropriate value for
1224 * errno should be returned.
1226 typedef int mpo_mount_check_mount_t(
1229 struct label
*vlabel
,
1230 struct componentname
*cnp
,
1231 const char *vfc_name
1234 * @brief Access control check for mounting a file system (late)
1235 * @param cred Subject credential
1236 * @param mp Mount point
1238 * Similar to mpo_mount_check_mount, but occurs after VFS_MOUNT has been
1239 * called, making it possible to access mnt_vfsstat.f_mntfromname and other
1242 * @return Return 0 if access is granted, otherwise an appropriate value for
1243 * errno should be returned.
1245 typedef int mpo_mount_check_mount_late_t(
1250 * @brief Access control check for fs_snapshot_create
1251 * @param cred Subject credential
1252 * @mp Filesystem mount point to create snapshot of
1253 * @name Name of snapshot to create
1255 * Determine whether the subject identified by the credential can
1256 * create a snapshot of the filesystem at the given mount point.
1258 * @return Return 0 if access is granted, otherwise an appropriate value
1259 * for errno should be returned.
1261 typedef int mpo_mount_check_snapshot_create_t(
1267 * @brief Access control check for fs_snapshot_delete
1268 * @param cred Subject credential
1269 * @mp Filesystem mount point to delete snapshot of
1270 * @name Name of snapshot to delete
1272 * Determine whether the subject identified by the credential can
1273 * delete the named snapshot from the filesystem at the given
1276 * @return Return 0 if access is granted, otherwise an appropriate value
1277 * for errno should be returned.
1279 typedef int mpo_mount_check_snapshot_delete_t(
1285 * @brief Access control check for fs_snapshot_mount
1286 * @param cred Subject credential
1287 * @param rvp Vnode of either the root directory of the
1288 * filesystem to mount snapshot of, or the device from
1289 * which to mount the snapshot.
1290 * @param vp Vnode that is to be the mount point
1291 * @param cnp Component name for vp
1292 * @param name Name of snapshot to mount
1293 * @param vfc_name Filesystem type name
1295 * Determine whether the subject identified by the credential can
1296 * mount the named snapshot from the filesystem at the given
1299 * @return Return 0 if access is granted, otherwise an appropriate value
1300 * for errno should be returned.
1302 typedef int mpo_mount_check_snapshot_mount_t(
1306 struct componentname
*cnp
,
1308 const char *vfc_name
1311 * @brief Access control check for fs_snapshot_revert
1312 * @param cred Subject credential
1313 * @mp Filesystem mount point to revert to snapshot
1314 * @name Name of snapshot to revert to
1316 * Determine whether the subject identified by the credential can
1317 * revert the filesystem at the given mount point to the named snapshot.
1319 * @return Return 0 if access is granted, otherwise an appropriate value
1320 * for errno should be returned.
1322 typedef int mpo_mount_check_snapshot_revert_t(
1328 * @brief Access control check remounting a filesystem
1329 * @param cred Subject credential
1330 * @param mp The mount point
1331 * @param mlabel Label currently associated with the mount point
1333 * Determine whether the subject identified by the credential can perform
1334 * the remount operation on the target vnode.
1336 * @return Return 0 if access is granted, otherwise an appropriate value for
1337 * errno should be returned.
1339 typedef int mpo_mount_check_remount_t(
1342 struct label
*mlabel
1345 * @brief Access control check for the settting of file system attributes
1346 * @param cred Subject credential
1347 * @param mp The mount structure of the file system
1348 * @param vfa The attributes requested
1350 * This entry point determines whether given subject can set information
1351 * about the given file system, for example the volume name.
1353 * @return Return 0 if access is granted, otherwise an appropriate value for
1354 * errno should be returned.
1357 typedef int mpo_mount_check_setattr_t(
1360 struct label
*mp_label
,
1361 struct vfs_attr
*vfa
1364 * @brief Access control check for file system statistics
1365 * @param cred Subject credential
1366 * @param mp Object file system mount
1367 * @param mntlabel Policy label for mp
1369 * Determine whether the subject identified by the credential can see
1370 * the results of a statfs performed on the file system. This call may
1371 * be made in a number of situations, including during invocations of
1372 * statfs(2) and related calls, as well as to determine what file systems
1373 * to exclude from listings of file systems, such as when getfsstat(2)
1376 * @return Return 0 if access is granted, otherwise an appropriate value for
1377 * errno should be returned. Suggested failure: EACCES for label mismatch
1378 * or EPERM for lack of privilege.
1380 typedef int mpo_mount_check_stat_t(
1383 struct label
*mntlabel
1386 * @brief Access control check for unmounting a filesystem
1387 * @param cred Subject credential
1388 * @param mp The mount point
1389 * @param mlabel Label associated with the mount point
1391 * Determine whether the subject identified by the credential can perform
1392 * the unmount operation on the target vnode.
1394 * @return Return 0 if access is granted, otherwise an appropriate value for
1395 * errno should be returned.
1397 typedef int mpo_mount_check_umount_t(
1400 struct label
*mlabel
1403 * @brief Create mount labels
1404 * @param cred Subject credential
1405 * @param mp Mount point of file system being mounted
1406 * @param mntlabel Label to associate with the new mount point
1407 * @see mpo_mount_label_init_t
1409 * Fill out the labels on the mount point being created by the supplied
1410 * user credential. This call is made when file systems are first mounted.
1412 typedef void mpo_mount_label_associate_t(
1415 struct label
*mntlabel
1418 * @brief Destroy mount label
1419 * @param label The label to be destroyed
1421 * Destroy a file system mount label. Since the
1422 * object is going out of scope, policy modules should free any
1423 * internal storage associated with the label so that it may be
1426 typedef void mpo_mount_label_destroy_t(
1430 * @brief Externalize a mount point label
1431 * @param label Label to be externalized
1432 * @param element_name Name of the label namespace for which labels should be
1434 * @param sb String buffer to be filled with a text representation of the label
1436 * Produce an external representation of the mount point label. An
1437 * externalized label consists of a text representation of the label
1438 * contents that can be used with user applications. Policy-agnostic
1439 * user space tools will display this externalized version.
1441 * The policy's externalize entry points will be called only if the
1442 * policy has registered interest in the label namespace.
1444 * @return 0 on success, return non-zero if an error occurs while
1445 * externalizing the label data.
1448 typedef int mpo_mount_label_externalize_t(
1449 struct label
*label
,
1454 * @brief Initialize mount point label
1455 * @param label New label to initialize
1457 * Initialize the label for a newly instantiated mount structure.
1458 * This label is typically used to store a default label in the case
1459 * that the file system has been mounted singlelabel. Since some
1460 * file systems do not support persistent labels (extended attributes)
1461 * or are read-only (such as CD-ROMs), it is often necessary to store
1462 * a default label separately from the label of the mount point
1463 * itself. Sleeping is permitted.
1465 typedef void mpo_mount_label_init_t(
1469 * @brief Internalize a mount point label
1470 * @param label Label to be internalized
1471 * @param element_name Name of the label namespace for which the label should
1473 * @param element_data Text data to be internalized
1475 * Produce a mount point file system label from an external representation.
1476 * An externalized label consists of a text representation of the label
1477 * contents that can be used with user applications. Policy-agnostic
1478 * user space tools will forward text version to the kernel for
1479 * processing by individual policy modules.
1481 * The policy's internalize entry points will be called only if the
1482 * policy has registered interest in the label namespace.
1484 * @return 0 on success, Otherwise, return non-zero if an error occurs
1485 * while internalizing the label data.
1488 typedef int mpo_mount_label_internalize_t(
1489 struct label
*label
,
1494 * @brief Access control check for pipe ioctl
1495 * @param cred Subject credential
1496 * @param cpipe Object to be accessed
1497 * @param pipelabel The label on the pipe
1498 * @param cmd The ioctl command; see ioctl(2)
1500 * Determine whether the subject identified by the credential can perform
1501 * the ioctl operation indicated by cmd.
1503 * @warning Since ioctl data is opaque from the standpoint of the MAC
1504 * framework, policies must exercise extreme care when implementing
1505 * access control checks.
1507 * @return Return 0 if access is granted, otherwise an appropriate value for
1508 * errno should be returned.
1511 typedef int mpo_pipe_check_ioctl_t(
1514 struct label
*pipelabel
,
1518 * @brief Access control check for pipe kqfilter
1519 * @param cred Subject credential
1520 * @param kn Object knote
1521 * @param cpipe Object to be accessed
1522 * @param pipelabel Policy label for the pipe
1524 * Determine whether the subject identified by the credential can
1525 * receive the knote on the passed pipe.
1527 * @return Return 0 if access if granted, otherwise an appropriate
1528 * value for errno should be returned.
1530 typedef int mpo_pipe_check_kqfilter_t(
1534 struct label
*pipelabel
1537 * @brief Access control check for pipe read
1538 * @param cred Subject credential
1539 * @param cpipe Object to be accessed
1540 * @param pipelabel The label on the pipe
1542 * Determine whether the subject identified by the credential can
1543 * perform a read operation on the passed pipe. The cred object holds
1544 * the credentials of the subject performing the operation.
1546 * @return Return 0 if access is granted, otherwise an appropriate value for
1547 * errno should be returned.
1550 typedef int mpo_pipe_check_read_t(
1553 struct label
*pipelabel
1556 * @brief Access control check for pipe select
1557 * @param cred Subject credential
1558 * @param cpipe Object to be accessed
1559 * @param pipelabel The label on the pipe
1560 * @param which The operation selected on: FREAD or FWRITE
1562 * Determine whether the subject identified by the credential can
1563 * perform a select operation on the passed pipe. The cred object holds
1564 * the credentials of the subject performing the operation.
1566 * @return Return 0 if access is granted, otherwise an appropriate value for
1567 * errno should be returned.
1570 typedef int mpo_pipe_check_select_t(
1573 struct label
*pipelabel
,
1577 * @brief Access control check for pipe stat
1578 * @param cred Subject credential
1579 * @param cpipe Object to be accessed
1580 * @param pipelabel The label on the pipe
1582 * Determine whether the subject identified by the credential can
1583 * perform a stat operation on the passed pipe. The cred object holds
1584 * the credentials of the subject performing the operation.
1586 * @return Return 0 if access is granted, otherwise an appropriate value for
1587 * errno should be returned.
1590 typedef int mpo_pipe_check_stat_t(
1593 struct label
*pipelabel
1596 * @brief Access control check for pipe write
1597 * @param cred Subject credential
1598 * @param cpipe Object to be accessed
1599 * @param pipelabel The label on the pipe
1601 * Determine whether the subject identified by the credential can
1602 * perform a write operation on the passed pipe. The cred object holds
1603 * the credentials of the subject performing the operation.
1605 * @return Return 0 if access is granted, otherwise an appropriate value for
1606 * errno should be returned.
1609 typedef int mpo_pipe_check_write_t(
1612 struct label
*pipelabel
1615 * @brief Create a pipe label
1616 * @param cred Subject credential
1617 * @param cpipe object to be labeled
1618 * @param pipelabel Label for the pipe object
1620 * Create a label for the pipe object being created by the supplied
1621 * user credential. This call is made when a pipe pair is being created.
1622 * The label is shared by both ends of the pipe.
1624 typedef void mpo_pipe_label_associate_t(
1627 struct label
*pipelabel
1630 * @brief Destroy pipe label
1631 * @param label The label to be destroyed
1633 * Destroy a pipe label. Since the object is going out of scope,
1634 * policy modules should free any internal storage associated with the
1635 * label so that it may be destroyed.
1637 typedef void mpo_pipe_label_destroy_t(
1641 * @brief Initialize pipe label
1642 * @param label New label to initialize
1644 * Initialize label storage for use with a newly instantiated pipe object.
1645 * Sleeping is permitted.
1647 typedef void mpo_pipe_label_init_t(
1651 * @brief Policy unload event
1652 * @param mpc MAC policy configuration
1654 * This is the MAC Framework policy unload event. This entry point will
1655 * only be called if the module's policy configuration allows unload (if
1656 * the MPC_LOADTIME_FLAG_UNLOADOK is set). Most security policies won't
1657 * want to be unloaded; they should set their flags to prevent this
1658 * entry point from being called.
1660 * @warning During this call, the mac policy list mutex is held, so
1661 * sleep operations cannot be performed, and calls out to other kernel
1662 * subsystems must be made with caution.
1664 * @see MPC_LOADTIME_FLAG_UNLOADOK
1666 typedef void mpo_policy_destroy_t(
1667 struct mac_policy_conf
*mpc
1670 * @brief Policy initialization event
1671 * @param mpc MAC policy configuration
1672 * @see mac_policy_register
1673 * @see mpo_policy_initbsd_t
1675 * This is the MAC Framework policy initialization event. This entry
1676 * point is called during mac_policy_register, when the policy module
1677 * is first registered with the MAC Framework. This is often done very
1678 * early in the boot process, after the kernel Mach subsystem has been
1679 * initialized, but prior to the BSD subsystem being initialized.
1680 * Since the kernel BSD services are not yet available, it is possible
1681 * that some initialization must occur later, possibly in the
1682 * mpo_policy_initbsd_t policy entry point, such as registering BSD system
1683 * controls (sysctls). Policy modules loaded at boot time will be
1684 * registered and initialized before labeled Mach objects are created.
1686 * @warning During this call, the mac policy list mutex is held, so
1687 * sleep operations cannot be performed, and calls out to other kernel
1688 * subsystems must be made with caution.
1690 typedef void mpo_policy_init_t(
1691 struct mac_policy_conf
*mpc
1694 * @brief Policy BSD initialization event
1695 * @param mpc MAC policy configuration
1696 * @see mpo_policy_init_t
1698 * This entry point is called after the kernel BSD subsystem has been
1699 * initialized. By this point, the module should already be loaded,
1700 * registered, and initialized. Since policy modules are initialized
1701 * before kernel BSD services are available, this second initialization
1702 * phase is necessary. At this point, BSD services (memory management,
1703 * synchronization primitives, vfs, etc.) are available, but the first
1704 * process has not yet been created. Mach-related objects and tasks
1705 * will already be fully initialized and may be in use--policies requiring
1706 * ubiquitous labeling may also want to implement mpo_policy_init_t.
1708 * @warning During this call, the mac policy list mutex is held, so
1709 * sleep operations cannot be performed, and calls out to other kernel
1710 * subsystems must be made with caution.
1712 typedef void mpo_policy_initbsd_t(
1713 struct mac_policy_conf
*mpc
1716 * @brief Policy extension service
1717 * @param p Calling process
1718 * @param call Policy-specific syscall number
1719 * @param arg Pointer to syscall arguments
1721 * This entry point provides a policy-multiplexed system call so that
1722 * policies may provide additional services to user processes without
1723 * registering specific system calls. The policy name provided during
1724 * registration is used to demux calls from userland, and the arguments
1725 * will be forwarded to this entry point. When implementing new
1726 * services, security modules should be sure to invoke appropriate
1727 * access control checks from the MAC framework as needed. For
1728 * example, if a policy implements an augmented signal functionality,
1729 * it should call the necessary signal access control checks to invoke
1730 * the MAC framework and other registered policies.
1732 * @warning Since the format and contents of the policy-specific
1733 * arguments are unknown to the MAC Framework, modules must perform the
1734 * required copyin() of the syscall data on their own. No policy
1735 * mediation is performed, so policies must perform any necessary
1736 * access control checks themselves. If multiple policies are loaded,
1737 * they will currently be unable to mediate calls to other policies.
1739 * @return In the event of an error, an appropriate value for errno
1740 * should be returned, otherwise return 0 upon success.
1742 typedef int mpo_policy_syscall_t(
1748 * @brief Access control check for POSIX semaphore create
1749 * @param cred Subject credential
1750 * @param name String name of the semaphore
1752 * Determine whether the subject identified by the credential can create
1753 * a POSIX semaphore specified by name.
1755 * @return Return 0 if access is granted, otherwise an appropriate value for
1756 * errno should be returned.
1758 typedef int mpo_posixsem_check_create_t(
1763 * @brief Access control check for POSIX semaphore open
1764 * @param cred Subject credential
1765 * @param ps Pointer to semaphore information structure
1766 * @param semlabel Label associated with the semaphore
1768 * Determine whether the subject identified by the credential can open
1769 * the named POSIX semaphore with label semlabel.
1771 * @return Return 0 if access is granted, otherwise an appropriate value for
1772 * errno should be returned.
1774 typedef int mpo_posixsem_check_open_t(
1776 struct pseminfo
*ps
,
1777 struct label
*semlabel
1780 * @brief Access control check for POSIX semaphore post
1781 * @param cred Subject credential
1782 * @param ps Pointer to semaphore information structure
1783 * @param semlabel Label associated with the semaphore
1785 * Determine whether the subject identified by the credential can unlock
1786 * the named POSIX semaphore with label semlabel.
1788 * @return Return 0 if access is granted, otherwise an appropriate value for
1789 * errno should be returned.
1791 typedef int mpo_posixsem_check_post_t(
1793 struct pseminfo
*ps
,
1794 struct label
*semlabel
1797 * @brief Access control check for POSIX semaphore unlink
1798 * @param cred Subject credential
1799 * @param ps Pointer to semaphore information structure
1800 * @param semlabel Label associated with the semaphore
1801 * @param name String name of the semaphore
1803 * Determine whether the subject identified by the credential can remove
1804 * the named POSIX semaphore with label semlabel.
1806 * @return Return 0 if access is granted, otherwise an appropriate value for
1807 * errno should be returned.
1809 typedef int mpo_posixsem_check_unlink_t(
1811 struct pseminfo
*ps
,
1812 struct label
*semlabel
,
1816 * @brief Access control check for POSIX semaphore wait
1817 * @param cred Subject credential
1818 * @param ps Pointer to semaphore information structure
1819 * @param semlabel Label associated with the semaphore
1821 * Determine whether the subject identified by the credential can lock
1822 * the named POSIX semaphore with label semlabel.
1824 * @return Return 0 if access is granted, otherwise an appropriate value for
1825 * errno should be returned.
1827 typedef int mpo_posixsem_check_wait_t(
1829 struct pseminfo
*ps
,
1830 struct label
*semlabel
1833 * @brief Create a POSIX semaphore label
1834 * @param cred Subject credential
1835 * @param ps Pointer to semaphore information structure
1836 * @param semlabel Label to associate with the new semaphore
1837 * @param name String name of the semaphore
1839 * Label a new POSIX semaphore. The label was previously
1840 * initialized and associated with the semaphore. At this time, an
1841 * appropriate initial label value should be assigned to the object and
1842 * stored in semalabel.
1844 typedef void mpo_posixsem_label_associate_t(
1846 struct pseminfo
*ps
,
1847 struct label
*semlabel
,
1851 * @brief Destroy POSIX semaphore label
1852 * @param label The label to be destroyed
1854 * Destroy a POSIX semaphore label. Since the object is
1855 * going out of scope, policy modules should free any internal storage
1856 * associated with the label so that it may be destroyed.
1858 typedef void mpo_posixsem_label_destroy_t(
1862 * @brief Initialize POSIX semaphore label
1863 * @param label New label to initialize
1865 * Initialize the label for a newly instantiated POSIX semaphore. Sleeping
1868 typedef void mpo_posixsem_label_init_t(
1872 * @brief Access control check for POSIX shared memory region create
1873 * @param cred Subject credential
1874 * @param name String name of the shared memory region
1876 * Determine whether the subject identified by the credential can create
1877 * the POSIX shared memory region referenced by name.
1879 * @return Return 0 if access is granted, otherwise an appropriate value for
1880 * errno should be returned.
1882 typedef int mpo_posixshm_check_create_t(
1887 * @brief Access control check for mapping POSIX shared memory
1888 * @param cred Subject credential
1889 * @param ps Pointer to shared memory information structure
1890 * @param shmlabel Label associated with the shared memory region
1891 * @param prot mmap protections; see mmap(2)
1892 * @param flags shmat flags; see shmat(2)
1894 * Determine whether the subject identified by the credential can map
1895 * the POSIX shared memory segment associated with shmlabel.
1897 * @return Return 0 if access is granted, otherwise an appropriate value for
1898 * errno should be returned.
1900 typedef int mpo_posixshm_check_mmap_t(
1902 struct pshminfo
*ps
,
1903 struct label
*shmlabel
,
1908 * @brief Access control check for POSIX shared memory region open
1909 * @param cred Subject credential
1910 * @param ps Pointer to shared memory information structure
1911 * @param shmlabel Label associated with the shared memory region
1912 * @param fflags shm_open(2) open flags ('fflags' encoded)
1914 * Determine whether the subject identified by the credential can open
1915 * the POSIX shared memory region.
1917 * @return Return 0 if access is granted, otherwise an appropriate value for
1918 * errno should be returned.
1920 typedef int mpo_posixshm_check_open_t(
1922 struct pshminfo
*ps
,
1923 struct label
*shmlabel
,
1927 * @brief Access control check for POSIX shared memory stat
1928 * @param cred Subject credential
1929 * @param ps Pointer to shared memory information structure
1930 * @param shmlabel Label associated with the shared memory region
1932 * Determine whether the subject identified by the credential can obtain
1933 * status for the POSIX shared memory segment associated with shmlabel.
1935 * @return Return 0 if access is granted, otherwise an appropriate value for
1936 * errno should be returned.
1938 typedef int mpo_posixshm_check_stat_t(
1940 struct pshminfo
*ps
,
1941 struct label
*shmlabel
1944 * @brief Access control check for POSIX shared memory truncate
1945 * @param cred Subject credential
1946 * @param ps Pointer to shared memory information structure
1947 * @param shmlabel Label associated with the shared memory region
1948 * @param len Length to truncate or extend shared memory segment
1950 * Determine whether the subject identified by the credential can truncate
1951 * or extend (to len) the POSIX shared memory segment associated with shmlabel.
1953 * @return Return 0 if access is granted, otherwise an appropriate value for
1954 * errno should be returned.
1956 typedef int mpo_posixshm_check_truncate_t(
1958 struct pshminfo
*ps
,
1959 struct label
*shmlabel
,
1963 * @brief Access control check for POSIX shared memory unlink
1964 * @param cred Subject credential
1965 * @param ps Pointer to shared memory information structure
1966 * @param shmlabel Label associated with the shared memory region
1967 * @param name String name of the shared memory region
1969 * Determine whether the subject identified by the credential can delete
1970 * the POSIX shared memory segment associated with shmlabel.
1972 * @return Return 0 if access is granted, otherwise an appropriate value for
1973 * errno should be returned.
1975 typedef int mpo_posixshm_check_unlink_t(
1977 struct pshminfo
*ps
,
1978 struct label
*shmlabel
,
1982 * @brief Create a POSIX shared memory region label
1983 * @param cred Subject credential
1984 * @param ps Pointer to shared memory information structure
1985 * @param shmlabel Label to associate with the new shared memory region
1986 * @param name String name of the shared memory region
1988 * Label a new POSIX shared memory region. The label was previously
1989 * initialized and associated with the shared memory region. At this
1990 * time, an appropriate initial label value should be assigned to the
1991 * object and stored in shmlabel.
1993 typedef void mpo_posixshm_label_associate_t(
1995 struct pshminfo
*ps
,
1996 struct label
*shmlabel
,
2000 * @brief Destroy POSIX shared memory label
2001 * @param label The label to be destroyed
2003 * Destroy a POSIX shared memory region label. Since the
2004 * object is going out of scope, policy modules should free any
2005 * internal storage associated with the label so that it may be
2008 typedef void mpo_posixshm_label_destroy_t(
2012 * @brief Initialize POSIX Shared Memory region label
2013 * @param label New label to initialize
2015 * Initialize the label for newly a instantiated POSIX Shared Memory
2016 * region. Sleeping is permitted.
2018 typedef void mpo_posixshm_label_init_t(
2022 * @brief Access control check for privileged operations
2023 * @param cred Subject credential
2024 * @param priv Requested privilege (see sys/priv.h)
2026 * Determine whether the subject identified by the credential can perform
2027 * a privileged operation. Privileged operations are allowed if the cred
2028 * is the superuser or any policy returns zero for mpo_priv_grant, unless
2029 * any policy returns nonzero for mpo_priv_check.
2031 * @return Return 0 if access is granted, otherwise EPERM should be returned.
2033 typedef int mpo_priv_check_t(
2038 * @brief Grant regular users the ability to perform privileged operations
2039 * @param cred Subject credential
2040 * @param priv Requested privilege (see sys/priv.h)
2042 * Determine whether the subject identified by the credential should be
2043 * allowed to perform a privileged operation that in the absense of any
2044 * MAC policy it would not be able to perform. Privileged operations are
2045 * allowed if the cred is the superuser or any policy returns zero for
2046 * mpo_priv_grant, unless any policy returns nonzero for mpo_priv_check.
2048 * Unlike other MAC hooks which can only reduce the privilege of a
2049 * credential, this hook raises the privilege of a credential when it
2050 * returns 0. Extreme care must be taken when implementing this hook to
2051 * avoid undermining the security of the system.
2053 * @return Return 0 if additional privilege is granted, otherwise EPERM
2054 * should be returned.
2056 typedef int mpo_priv_grant_t(
2061 * @brief Access control over process core dumps
2062 * @param proc Subject process
2064 * Determine whether a core dump may be written to disk for the subject
2067 * @return Return 0 if access is granted, otherwise an appropriate value for
2068 * errno should be returned.
2070 typedef int mpo_proc_check_dump_core_t(
2074 * @brief Access control over remote thread creation
2075 * @param cred Subject credential
2076 * @param proc Object process
2077 * @param flavor Flavor of thread state passed in new_state, or -1
2078 * @param new_state Thread state to be set on the created thread, or NULL
2079 * @param new_state_count Size of thread state, in natural_t units, or 0
2081 * Determine whether the subject can create a thread in the object process
2082 * by calling the thread_create or thread_create_running MIG routines on
2083 * another process' task port. For thread_create_running, the flavor,
2084 * new_state and new_state_count arguments are passed here before they are
2085 * converted and checked by machine-dependent code.
2087 * @return Return 0 if access is granted, otherwise an appropriate value for
2088 * errno should be returned.
2090 typedef int mpo_proc_check_remote_thread_create_t(
2094 thread_state_t new_state
,
2095 mach_msg_type_number_t new_state_count
2098 * @brief Access control check for debugging process
2099 * @param cred Subject credential
2100 * @param pident Object unique process identifier
2102 * Determine whether the subject identified by the credential can debug
2103 * the passed process. This call may be made in a number of situations,
2104 * including use of the ptrace(2) and ktrace(2) APIs, as well as for some
2105 * types of procfs operations.
2107 * @return Return 0 if access is granted, otherwise an appropriate value for
2108 * errno should be returned. Suggested failure: EACCES for label mismatch,
2109 * EPERM for lack of privilege, or ESRCH to hide visibility of the target.
2111 typedef int mpo_proc_check_debug_t(
2113 struct proc_ident
*pident
2116 * @brief Access control over fork
2117 * @param cred Subject credential
2118 * @param proc Subject process trying to fork
2120 * Determine whether the subject identified is allowed to fork.
2122 * @return Return 0 if access is granted, otherwise an appropriate value for
2123 * errno should be returned.
2125 typedef int mpo_proc_check_fork_t(
2130 * @brief Access control check for setting host special ports.
2131 * @param cred Subject credential
2132 * @param id The host special port to set
2133 * @param port The new value to set for the special port
2135 * @return Return 0 if access is granted, otherwise an appropriate value for
2136 * errno should be returned.
2138 typedef int mpo_proc_check_set_host_special_port_t(
2141 struct ipc_port
*port
2144 * @brief Access control check for setting host exception ports.
2145 * @param cred Subject credential
2146 * @param exception Exception port to set
2148 * @return Return 0 if access is granted, otherwise an appropriate value for
2149 * errno should be returned.
2151 typedef int mpo_proc_check_set_host_exception_port_t(
2153 unsigned int exception
2156 * @brief Access control over pid_suspend, pid_resume and family
2157 * @param cred Subject credential
2158 * @param proc Object process
2159 * @param sr Type of call; one of MAC_PROC_CHECK_SUSPEND,
2160 * MAC_PROC_CHECK_RESUME, MAC_PROC_CHECK_HIBERNATE,
2161 * MAC_PROC_CHECK_SHUTDOWN_SOCKETS or MAC_PROC_CHECK_PIDBIND.
2163 * Determine whether the subject identified is allowed to call pid_suspend,
2164 * pid_resume, pid_hibernate, pid_shutdown_sockets,
2165 * process_policy(PROC_POLICY_APP_LIFECYCLE, PROC_POLICY_APPLIFE_DEVSTATUS) or
2166 * process_policy(PROC_POLICY_APP_LIFECYCLE, PROC_POLICY_APPLIFE_PIDBIND) on
2167 * the object process.
2169 * @return Return 0 if access is granted, otherwise an appropriate value for
2170 * errno should be returned.
2172 typedef int mpo_proc_check_suspend_resume_t(
2178 * @brief Access control check for retrieving audit information
2179 * @param cred Subject credential
2181 * Determine whether the subject identified by the credential can get
2182 * audit information such as the audit user ID, the preselection mask,
2183 * the terminal ID and the audit session ID, using the getaudit() system call.
2185 * @return Return 0 if access is granted, otherwise an appropriate value for
2186 * errno should be returned.
2188 typedef int mpo_proc_check_getaudit_t(
2192 * @brief Access control check for retrieving audit user ID
2193 * @param cred Subject credential
2195 * Determine whether the subject identified by the credential can get
2196 * the user identity being used by the auditing system, using the getauid()
2199 * @return Return 0 if access is granted, otherwise an appropriate value for
2200 * errno should be returned.
2202 typedef int mpo_proc_check_getauid_t(
2206 * @brief Access control check for retrieving Login Context ID
2207 * @param p0 Calling process
2208 * @param p Effected process
2209 * @param pid syscall PID argument
2211 * Determine if getlcid(2) system call is permitted.
2213 * Information returned by this system call is similar to that returned via
2214 * process listings etc.
2216 * @return Return 0 if access is granted, otherwise an appropriate value for
2217 * errno should be returned.
2219 typedef int mpo_proc_check_getlcid_t(
2225 * @brief Access control check for retrieving ledger information
2226 * @param cred Subject credential
2227 * @param target Object process
2228 * @param op ledger operation
2230 * Determine if ledger(2) system call is permitted.
2232 * Information returned by this system call is similar to that returned via
2233 * process listings etc.
2235 * @return Return 0 if access is granted, otherwise an appropriate value for
2236 * errno should be returned.
2238 typedef int mpo_proc_check_ledger_t(
2240 struct proc
*target
,
2244 * @brief Access control check for retrieving process information.
2245 * @param cred Subject credential
2246 * @param target Target process (may be null, may be zombie)
2248 * Determine if a credential has permission to access process information as defined
2249 * by call number and flavor on target process
2251 * @return Return 0 if access is granted, otherwise an appropriate value for
2252 * errno should be returned.
2254 typedef int mpo_proc_check_proc_info_t(
2256 struct proc
*target
,
2261 * @brief Access control check for retrieving code signing information.
2262 * @param cred Subject credential
2263 * @param target Target process
2264 * @param op Code signing operation being performed
2266 * Determine whether the subject identified by the credential should be
2267 * allowed to get code signing information about the target process.
2269 * @return Return 0 if access is granted, otherwise an appropriate value for
2270 * errno should be returned.
2272 typedef int mpo_proc_check_get_cs_info_t(
2274 struct proc
*target
,
2278 * @brief Access control check for setting code signing information.
2279 * @param cred Subject credential
2280 * @param target Target process
2281 * @param op Code signing operation being performed.
2283 * Determine whether the subject identified by the credential should be
2284 * allowed to set code signing information about the target process.
2286 * @return Return 0 if permission is granted, otherwise an appropriate
2287 * value of errno should be returned.
2289 typedef int mpo_proc_check_set_cs_info_t(
2291 struct proc
*target
,
2295 * @brief Access control check for mmap MAP_ANON
2296 * @param proc User process requesting the memory
2297 * @param cred Subject credential
2298 * @param u_addr Start address of the memory range
2299 * @param u_size Length address of the memory range
2300 * @param prot mmap protections; see mmap(2)
2301 * @param flags Type of mapped object; see mmap(2)
2302 * @param maxprot Maximum rights
2304 * Determine whether the subject identified by the credential should be
2305 * allowed to obtain anonymous memory using the specified flags and
2306 * protections on the new mapping. MAP_ANON will always be present in the
2307 * flags. Certain combinations of flags with a non-NULL addr may
2308 * cause a mapping to be rejected before this hook is called. The maxprot field
2309 * holds the maximum permissions on the new mapping, a combination of
2310 * VM_PROT_READ, VM_PROT_WRITE and VM_PROT_EXECUTE. To avoid overriding prior
2311 * access control checks, a policy should only remove flags from maxprot.
2313 * @return Return 0 if access is granted, otherwise an appropriate value for
2314 * errno should be returned. Suggested failure: EPERM for lack of privilege.
2316 typedef int mpo_proc_check_map_anon_t(
2326 * @brief Access control check for setting memory protections
2327 * @param cred Subject credential
2328 * @param proc User process requesting the change
2329 * @param addr Start address of the memory range
2330 * @param size Length address of the memory range
2331 * @param prot Memory protections, see mmap(2)
2333 * Determine whether the subject identified by the credential should
2334 * be allowed to set the specified memory protections on memory mapped
2335 * in the process proc.
2337 * @return Return 0 if access is granted, otherwise an appropriate value for
2338 * errno should be returned.
2340 typedef int mpo_proc_check_mprotect_t(
2348 * @brief Access control check for changing scheduling parameters
2349 * @param cred Subject credential
2350 * @param proc Object process
2352 * Determine whether the subject identified by the credential can change
2353 * the scheduling parameters of the passed process.
2355 * @return Return 0 if access is granted, otherwise an appropriate value for
2356 * errno should be returned. Suggested failure: EACCES for label mismatch,
2357 * EPERM for lack of privilege, or ESRCH to limit visibility.
2359 typedef int mpo_proc_check_sched_t(
2364 * @brief Access control check for setting audit information
2365 * @param cred Subject credential
2366 * @param ai Audit information
2368 * Determine whether the subject identified by the credential can set
2369 * audit information such as the the preselection mask, the terminal ID
2370 * and the audit session ID, using the setaudit() system call.
2372 * @return Return 0 if access is granted, otherwise an appropriate value for
2373 * errno should be returned.
2375 typedef int mpo_proc_check_setaudit_t(
2377 struct auditinfo_addr
*ai
2380 * @brief Access control check for setting audit user ID
2381 * @param cred Subject credential
2382 * @param auid Audit user ID
2384 * Determine whether the subject identified by the credential can set
2385 * the user identity used by the auditing system, using the setauid()
2388 * @return Return 0 if access is granted, otherwise an appropriate value for
2389 * errno should be returned.
2391 typedef int mpo_proc_check_setauid_t(
2396 * @brief Access control check for setting the Login Context
2397 * @param p0 Calling process
2398 * @param p Effected process
2399 * @param pid syscall PID argument
2400 * @param lcid syscall LCID argument
2402 * Determine if setlcid(2) system call is permitted.
2404 * See xnu/bsd/kern/kern_prot.c:setlcid() implementation for example of
2405 * decoding syscall arguments to determine action desired by caller.
2407 * Five distinct actions are possible: CREATE JOIN LEAVE ADOPT ORPHAN
2409 * @return Return 0 if access is granted, otherwise an appropriate value for
2410 * errno should be returned.
2412 typedef int mpo_proc_check_setlcid_t(
2419 * @brief Access control check for delivering signal
2420 * @param cred Subject credential
2421 * @param proc Object process
2422 * @param signum Signal number; see kill(2)
2424 * Determine whether the subject identified by the credential can deliver
2425 * the passed signal to the passed process.
2427 * @warning Programs typically expect to be able to send and receive
2428 * signals as part or their normal process lifecycle; caution should be
2429 * exercised when implementing access controls over signal events.
2431 * @return Return 0 if access is granted, otherwise an appropriate value for
2432 * errno should be returned. Suggested failure: EACCES for label mismatch,
2433 * EPERM for lack of privilege, or ESRCH to limit visibility.
2435 typedef int mpo_proc_check_signal_t(
2441 * @brief Access control check for Unix syscalls.
2442 * @param proc Subject process
2443 * @param scnum Syscall number; see bsd/kern/syscalls.master.
2445 * Determine whether the subject process can perform the passed syscall (number).
2447 * @warning Programs typically expect to be able to make syscalls as part of
2448 * their normal process lifecycle; caution should be exercised when restricting
2449 * which syscalls a process can perform.
2451 * @return Return 0 if access is granted, otherwise an appropriate value for
2452 * errno should be returned. Suggested failure: EPERM for lack of privilege.
2454 typedef int mpo_proc_check_syscall_unix_t(
2459 * @brief Access control check for wait
2460 * @param cred Subject credential
2461 * @param proc Object process
2463 * Determine whether the subject identified by the credential can wait
2464 * for process termination.
2466 * @warning Caution should be exercised when implementing access
2467 * controls for wait, since programs often wait for child processes to
2468 * exit. Failure to be notified of a child process terminating may
2469 * cause the parent process to hang, or may produce zombie processes.
2471 * @return Return 0 if access is granted, otherwise an appropriate value for
2472 * errno should be returned.
2474 typedef int mpo_proc_check_wait_t(
2479 * @brief Inform MAC policies that a process has exited.
2480 * @param proc Object process
2482 * Called after all of the process's threads have terminated and
2483 * it has been removed from the process list. KPI that identifies
2484 * the process by pid will fail to find the process; KPI that
2485 * identifies the process by the object process pointer functions
2486 * normally. proc_exiting() returns true for the object process.
2488 typedef void mpo_proc_notify_exit_t(
2492 * @brief Access control check for skywalk flow connect
2493 * @param cred Subject credential
2494 * @param flow Flow object
2495 * @param addr Remote address for flow to send data to
2496 * @param type Flow type (e.g. SOCK_STREAM or SOCK_DGRAM)
2497 * @param protocol Network protocol (e.g. IPPROTO_TCP)
2499 * Determine whether the subject identified by the credential can
2500 * create a flow for sending data to the remote host specified by
2503 * @return Return 0 if access if granted, otherwise an appropriate
2504 * value for errno should be returned.
2506 typedef int mpo_skywalk_flow_check_connect_t(
2509 const struct sockaddr
*addr
,
2514 * @brief Access control check for skywalk flow listen
2515 * @param cred Subject credential
2516 * @param flow Flow object
2517 * @param addr Local address for flow to listen on
2518 * @param type Flow type (e.g. SOCK_STREAM or SOCK_DGRAM)
2519 * @param protocol Network protocol (e.g. IPPROTO_TCP)
2521 * Determine whether the subject identified by the credential can
2522 * create a flow for receiving data on the local address specified
2525 * @return Return 0 if access if granted, otherwise an appropriate
2526 * value for errno should be returned.
2528 typedef int mpo_skywalk_flow_check_listen_t(
2531 const struct sockaddr
*addr
,
2536 * @brief Access control check for socket accept
2537 * @param cred Subject credential
2538 * @param so Object socket
2539 * @param socklabel Policy label for socket
2541 * Determine whether the subject identified by the credential can accept()
2542 * a new connection on the socket from the host specified by addr.
2544 * @return Return 0 if access if granted, otherwise an appropriate
2545 * value for errno should be returned.
2547 typedef int mpo_socket_check_accept_t(
2550 struct label
*socklabel
2553 * @brief Access control check for a pending socket accept
2554 * @param cred Subject credential
2555 * @param so Object socket
2556 * @param socklabel Policy label for socket
2557 * @param addr Address of the listening socket (coming soon)
2559 * Determine whether the subject identified by the credential can accept()
2560 * a pending connection on the socket from the host specified by addr.
2562 * @return Return 0 if access if granted, otherwise an appropriate
2563 * value for errno should be returned.
2565 typedef int mpo_socket_check_accepted_t(
2568 struct label
*socklabel
,
2569 struct sockaddr
*addr
2572 * @brief Access control check for socket bind
2573 * @param cred Subject credential
2574 * @param so Object socket
2575 * @param socklabel Policy label for socket
2576 * @param addr Name to assign to the socket
2578 * Determine whether the subject identified by the credential can bind()
2579 * the name (addr) to the socket.
2581 * @return Return 0 if access if granted, otherwise an appropriate
2582 * value for errno should be returned.
2584 typedef int mpo_socket_check_bind_t(
2587 struct label
*socklabel
,
2588 struct sockaddr
*addr
2591 * @brief Access control check for socket connect
2592 * @param cred Subject credential
2593 * @param so Object socket
2594 * @param socklabel Policy label for socket
2595 * @param addr Name to assign to the socket
2597 * Determine whether the subject identified by the credential can
2598 * connect() the passed socket to the remote host specified by addr.
2600 * @return Return 0 if access if granted, otherwise an appropriate
2601 * value for errno should be returned.
2603 typedef int mpo_socket_check_connect_t(
2606 struct label
*socklabel
,
2607 struct sockaddr
*addr
2610 * @brief Access control check for socket() system call.
2611 * @param cred Subject credential
2612 * @param domain communication domain
2613 * @param type socket type
2614 * @param protocol socket protocol
2616 * Determine whether the subject identified by the credential can
2617 * make the socket() call.
2619 * @return Return 0 if access if granted, otherwise an appropriate
2620 * value for errno should be returned.
2622 typedef int mpo_socket_check_create_t(
2629 * @brief Access control check for socket ioctl.
2630 * @param cred Subject credential
2631 * @param so Object socket
2632 * @param cmd The ioctl command; see ioctl(2)
2633 * @param socklabel Policy label for socket
2635 * Determine whether the subject identified by the credential can perform
2636 * the ioctl operation indicated by cmd on the given socket.
2638 * @warning Since ioctl data is opaque from the standpoint of the MAC
2639 * framework, and since ioctls can affect many aspects of system
2640 * operation, policies must exercise extreme care when implementing
2641 * access control checks.
2643 * @return Return 0 if access is granted, otherwise an appropriate value for
2644 * errno should be returned.
2646 typedef int mpo_socket_check_ioctl_t(
2650 struct label
*socklabel
2653 * @brief Access control check for socket listen
2654 * @param cred Subject credential
2655 * @param so Object socket
2656 * @param socklabel Policy label for socket
2658 * Determine whether the subject identified by the credential can
2659 * listen() on the passed socket.
2661 * @return Return 0 if access if granted, otherwise an appropriate
2662 * value for errno should be returned.
2664 typedef int mpo_socket_check_listen_t(
2667 struct label
*socklabel
2670 * @brief Access control check for socket receive
2671 * @param cred Subject credential
2672 * @param so Object socket
2673 * @param socklabel Policy label for socket
2675 * Determine whether the subject identified by the credential can
2676 * receive data from the socket.
2678 * @return Return 0 if access if granted, otherwise an appropriate
2679 * value for errno should be returned.
2681 typedef int mpo_socket_check_receive_t(
2684 struct label
*socklabel
2688 * @brief Access control check for socket receive
2689 * @param cred Subject credential
2690 * @param sock Object socket
2691 * @param socklabel Policy label for socket
2692 * @param saddr Name of the remote socket
2694 * Determine whether the subject identified by the credential can
2695 * receive data from the remote host specified by addr.
2697 * @return Return 0 if access if granted, otherwise an appropriate
2698 * value for errno should be returned.
2700 typedef int mpo_socket_check_received_t(
2702 struct socket
*sock
,
2703 struct label
*socklabel
,
2704 struct sockaddr
*saddr
2708 * @brief Access control check for socket send
2709 * @param cred Subject credential
2710 * @param so Object socket
2711 * @param socklabel Policy label for socket
2712 * @param addr Address being sent to
2714 * Determine whether the subject identified by the credential can send
2715 * data to the socket.
2717 * @return Return 0 if access if granted, otherwise an appropriate
2718 * value for errno should be returned.
2720 typedef int mpo_socket_check_send_t(
2723 struct label
*socklabel
,
2724 struct sockaddr
*addr
2727 * @brief Access control check for retrieving socket status
2728 * @param cred Subject credential
2729 * @param so Object socket
2730 * @param socklabel Policy label for so
2732 * Determine whether the subject identified by the credential can
2733 * execute the stat() system call on the given socket.
2735 * @return Return 0 if access if granted, otherwise an appropriate
2736 * value for errno should be returned.
2738 typedef int mpo_socket_check_stat_t(
2741 struct label
*socklabel
2744 * @brief Access control check for setting socket options
2745 * @param cred Subject credential
2746 * @param so Object socket
2747 * @param socklabel Policy label for so
2748 * @param sopt The options being set
2750 * Determine whether the subject identified by the credential can
2751 * execute the setsockopt system call on the given socket.
2753 * @return Return 0 if access if granted, otherwise an appropriate
2754 * value for errno should be returned.
2756 typedef int mpo_socket_check_setsockopt_t(
2759 struct label
*socklabel
,
2760 struct sockopt
*sopt
2763 * @brief Access control check for getting socket options
2764 * @param cred Subject credential
2765 * @param so Object socket
2766 * @param socklabel Policy label for so
2767 * @param sopt The options to get
2769 * Determine whether the subject identified by the credential can
2770 * execute the getsockopt system call on the given socket.
2772 * @return Return 0 if access if granted, otherwise an appropriate
2773 * value for errno should be returned.
2775 typedef int mpo_socket_check_getsockopt_t(
2778 struct label
*socklabel
,
2779 struct sockopt
*sopt
2782 * @brief Access control check for enabling accounting
2783 * @param cred Subject credential
2784 * @param vp Accounting file
2785 * @param vlabel Label associated with vp
2787 * Determine whether the subject should be allowed to enable accounting,
2788 * based on its label and the label of the accounting log file. See
2789 * acct(5) for more information.
2791 * As accounting is disabled by passing NULL to the acct(2) system call,
2792 * the policy should be prepared for both 'vp' and 'vlabel' to be NULL.
2794 * @return Return 0 if access is granted, otherwise an appropriate value for
2795 * errno should be returned.
2797 typedef int mpo_system_check_acct_t(
2800 struct label
*vlabel
2803 * @brief Access control check for audit
2804 * @param cred Subject credential
2805 * @param record Audit record
2806 * @param length Audit record length
2808 * Determine whether the subject identified by the credential can submit
2809 * an audit record for inclusion in the audit log via the audit() system call.
2811 * @return Return 0 if access is granted, otherwise an appropriate value for
2812 * errno should be returned.
2814 typedef int mpo_system_check_audit_t(
2820 * @brief Access control check for controlling audit
2821 * @param cred Subject credential
2822 * @param vp Audit file
2823 * @param vl Label associated with vp
2825 * Determine whether the subject should be allowed to enable auditing using
2826 * the auditctl() system call, based on its label and the label of the proposed
2829 * @return Return 0 if access is granted, otherwise an appropriate value for
2830 * errno should be returned.
2832 typedef int mpo_system_check_auditctl_t(
2838 * @brief Access control check for manipulating auditing
2839 * @param cred Subject credential
2840 * @param cmd Audit control command
2842 * Determine whether the subject identified by the credential can perform
2843 * the audit subsystem control operation cmd via the auditon() system call.
2845 * @return Return 0 if access is granted, otherwise an appropriate value for
2846 * errno should be returned.
2848 typedef int mpo_system_check_auditon_t(
2853 * @brief Access control check for obtaining the host control port
2854 * @param cred Subject credential
2856 * Determine whether the subject identified by the credential can
2857 * obtain the host control port.
2859 * @return Return 0 if access is granted, or non-zero otherwise.
2861 typedef int mpo_system_check_host_priv_t(
2865 * @brief Access control check for obtaining system information
2866 * @param cred Subject credential
2867 * @param info_type A description of the information requested
2869 * Determine whether the subject identified by the credential should be
2870 * allowed to obtain information about the system.
2872 * This is a generic hook that can be used in a variety of situations where
2873 * information is being returned that might be considered sensitive.
2874 * Rather than adding a new MAC hook for every such interface, this hook can
2875 * be called with a string identifying the type of information requested.
2877 * @return Return 0 if access is granted, otherwise an appropriate value for
2878 * errno should be returned.
2880 typedef int mpo_system_check_info_t(
2882 const char *info_type
2885 * @brief Access control check for calling NFS services
2886 * @param cred Subject credential
2888 * Determine whether the subject identified by the credential should be
2889 * allowed to call nfssrv(2).
2891 * @return Return 0 if access is granted, otherwise an appropriate value for
2892 * errno should be returned.
2894 typedef int mpo_system_check_nfsd_t(
2898 * @brief Access control check for reboot
2899 * @param cred Subject credential
2900 * @param howto howto parameter from reboot(2)
2902 * Determine whether the subject identified by the credential should be
2903 * allowed to reboot the system in the specified manner.
2905 * @return Return 0 if access is granted, otherwise an appropriate value for
2906 * errno should be returned.
2908 typedef int mpo_system_check_reboot_t(
2913 * @brief Access control check for setting system clock
2914 * @param cred Subject credential
2916 * Determine whether the subject identified by the credential should be
2917 * allowed to set the system clock.
2919 * @return Return 0 if access is granted, otherwise an appropriate value for
2920 * errno should be returned.
2922 typedef int mpo_system_check_settime_t(
2926 * @brief Access control check for removing swap devices
2927 * @param cred Subject credential
2928 * @param vp Swap device
2929 * @param label Label associated with vp
2931 * Determine whether the subject identified by the credential should be
2932 * allowed to remove vp as a swap device.
2934 * @return Return 0 if access is granted, otherwise an appropriate value for
2935 * errno should be returned.
2937 typedef int mpo_system_check_swapoff_t(
2943 * @brief Access control check for adding swap devices
2944 * @param cred Subject credential
2945 * @param vp Swap device
2946 * @param label Label associated with vp
2948 * Determine whether the subject identified by the credential should be
2949 * allowed to add vp as a swap device.
2951 * @return Return 0 if access is granted, otherwise an appropriate value for
2952 * errno should be returned.
2954 typedef int mpo_system_check_swapon_t(
2960 * @brief Access control check for sysctl
2961 * @param cred Subject credential
2962 * @param namestring String representation of sysctl name.
2963 * @param name Integer name; see sysctl(3)
2964 * @param namelen Length of name array of integers; see sysctl(3)
2965 * @param old 0 or address where to store old value; see sysctl(3)
2966 * @param oldlen Length of old buffer; see sysctl(3)
2967 * @param newvalue 0 or address of new value; see sysctl(3)
2968 * @param newlen Length of new buffer; see sysctl(3)
2970 * Determine whether the subject identified by the credential should be
2971 * allowed to make the specified sysctl(3) transaction.
2973 * The sysctl(3) call specifies that if the old value is not desired,
2974 * oldp and oldlenp should be set to NULL. Likewise, if a new value is
2975 * not to be set, newp should be set to NULL and newlen set to 0.
2977 * @return Return 0 if access is granted, otherwise an appropriate value for
2978 * errno should be returned.
2980 typedef int mpo_system_check_sysctlbyname_t(
2982 const char *namestring
,
2985 user_addr_t old
, /* NULLOK */
2987 user_addr_t newvalue
, /* NULLOK */
2991 * @brief Access control check for kas_info
2992 * @param cred Subject credential
2993 * @param selector Category of information to return. See kas_info.h
2995 * Determine whether the subject identified by the credential can perform
2996 * introspection of the kernel address space layout for
2997 * debugging/performance analysis.
2999 * @return Return 0 if access is granted, otherwise an appropriate value for
3000 * errno should be returned.
3002 typedef int mpo_system_check_kas_info_t(
3007 * @brief Create a System V message label
3008 * @param cred Subject credential
3009 * @param msqptr The message queue the message will be placed in
3010 * @param msqlabel The label of the message queue
3011 * @param msgptr The message
3012 * @param msglabel The label of the message
3014 * Label the message as its placed in the message queue.
3016 typedef void mpo_sysvmsg_label_associate_t(
3018 struct msqid_kernel
*msqptr
,
3019 struct label
*msqlabel
,
3021 struct label
*msglabel
3024 * @brief Destroy System V message label
3025 * @param label The label to be destroyed
3027 * Destroy a System V message label. Since the object is
3028 * going out of scope, policy modules should free any internal storage
3029 * associated with the label so that it may be destroyed.
3031 typedef void mpo_sysvmsg_label_destroy_t(
3035 * @brief Initialize System V message label
3036 * @param label New label to initialize
3038 * Initialize the label for a newly instantiated System V message.
3040 typedef void mpo_sysvmsg_label_init_t(
3044 * @brief Clean up a System V message label
3045 * @param label The label to be destroyed
3047 * Clean up a System V message label. Darwin pre-allocates
3048 * messages at system boot time and re-uses them rather than
3049 * allocating new ones. Before messages are returned to the "free
3050 * pool", policies can cleanup or overwrite any information present in
3053 typedef void mpo_sysvmsg_label_recycle_t(
3057 * @brief Access control check for System V message enqueuing
3058 * @param cred Subject credential
3059 * @param msgptr The message
3060 * @param msglabel The message's label
3061 * @param msqptr The message queue
3062 * @param msqlabel The message queue's label
3064 * Determine whether the subject identified by the credential can add the
3065 * given message to the given message queue.
3067 * @return Return 0 if access is granted, otherwise an appropriate value for
3068 * errno should be returned.
3070 typedef int mpo_sysvmsq_check_enqueue_t(
3073 struct label
*msglabel
,
3074 struct msqid_kernel
*msqptr
,
3075 struct label
*msqlabel
3078 * @brief Access control check for System V message reception
3079 * @param cred The credential of the intended recipient
3080 * @param msgptr The message
3081 * @param msglabel The message's label
3083 * Determine whether the subject identified by the credential can receive
3084 * the given message.
3086 * @return Return 0 if access is granted, otherwise an appropriate value for
3087 * errno should be returned.
3089 typedef int mpo_sysvmsq_check_msgrcv_t(
3092 struct label
*msglabel
3095 * @brief Access control check for System V message queue removal
3096 * @param cred The credential of the caller
3097 * @param msgptr The message
3098 * @param msglabel The message's label
3100 * System V message queues are removed using the msgctl() system call.
3101 * The system will iterate over each messsage in the queue, calling this
3102 * function for each, to determine whether the caller has the appropriate
3105 * @return Return 0 if access is granted, otherwise an appropriate value for
3106 * errno should be returned.
3108 typedef int mpo_sysvmsq_check_msgrmid_t(
3111 struct label
*msglabel
3114 * @brief Access control check for msgctl()
3115 * @param cred The credential of the caller
3116 * @param msqptr The message queue
3117 * @param msqlabel The message queue's label
3119 * This access check is performed to validate calls to msgctl().
3121 * @return Return 0 if access is granted, otherwise an appropriate value for
3122 * errno should be returned.
3124 typedef int mpo_sysvmsq_check_msqctl_t(
3126 struct msqid_kernel
*msqptr
,
3127 struct label
*msqlabel
,
3131 * @brief Access control check to get a System V message queue
3132 * @param cred The credential of the caller
3133 * @param msqptr The message queue requested
3134 * @param msqlabel The message queue's label
3136 * On a call to msgget(), if the queue requested already exists,
3137 * and it is a public queue, this check will be performed before the
3138 * queue's ID is returned to the user.
3140 * @return Return 0 if access is granted, otherwise an appropriate value for
3141 * errno should be returned.
3143 typedef int mpo_sysvmsq_check_msqget_t(
3145 struct msqid_kernel
*msqptr
,
3146 struct label
*msqlabel
3149 * @brief Access control check to receive a System V message from the given queue
3150 * @param cred The credential of the caller
3151 * @param msqptr The message queue to receive from
3152 * @param msqlabel The message queue's label
3154 * On a call to msgrcv(), this check is performed to determine whether the
3155 * caller has receive rights on the given queue.
3157 * @return Return 0 if access is granted, otherwise an appropriate value for
3158 * errno should be returned.
3160 typedef int mpo_sysvmsq_check_msqrcv_t(
3162 struct msqid_kernel
*msqptr
,
3163 struct label
*msqlabel
3166 * @brief Access control check to send a System V message to the given queue
3167 * @param cred The credential of the caller
3168 * @param msqptr The message queue to send to
3169 * @param msqlabel The message queue's label
3171 * On a call to msgsnd(), this check is performed to determine whether the
3172 * caller has send rights on the given queue.
3174 * @return Return 0 if access is granted, otherwise an appropriate value for
3175 * errno should be returned.
3177 typedef int mpo_sysvmsq_check_msqsnd_t(
3179 struct msqid_kernel
*msqptr
,
3180 struct label
*msqlabel
3183 * @brief Create a System V message queue label
3184 * @param cred Subject credential
3185 * @param msqptr The message queue
3186 * @param msqlabel The label of the message queue
3189 typedef void mpo_sysvmsq_label_associate_t(
3191 struct msqid_kernel
*msqptr
,
3192 struct label
*msqlabel
3195 * @brief Destroy System V message queue label
3196 * @param label The label to be destroyed
3198 * Destroy a System V message queue label. Since the object is
3199 * going out of scope, policy modules should free any internal storage
3200 * associated with the label so that it may be destroyed.
3202 typedef void mpo_sysvmsq_label_destroy_t(
3206 * @brief Initialize System V message queue label
3207 * @param label New label to initialize
3209 * Initialize the label for a newly instantiated System V message queue.
3211 typedef void mpo_sysvmsq_label_init_t(
3215 * @brief Clean up a System V message queue label
3216 * @param label The label to be destroyed
3218 * Clean up a System V message queue label. Darwin pre-allocates
3219 * message queues at system boot time and re-uses them rather than
3220 * allocating new ones. Before message queues are returned to the "free
3221 * pool", policies can cleanup or overwrite any information present in
3224 typedef void mpo_sysvmsq_label_recycle_t(
3228 * @brief Access control check for System V semaphore control operation
3229 * @param cred Subject credential
3230 * @param semakptr Pointer to semaphore identifier
3231 * @param semaklabel Label associated with semaphore
3232 * @param cmd Control operation to be performed; see semctl(2)
3234 * Determine whether the subject identified by the credential can perform
3235 * the operation indicated by cmd on the System V semaphore semakptr.
3237 * @return Return 0 if access is granted, otherwise an appropriate value for
3238 * errno should be returned.
3240 typedef int mpo_sysvsem_check_semctl_t(
3242 struct semid_kernel
*semakptr
,
3243 struct label
*semaklabel
,
3247 * @brief Access control check for obtaining a System V semaphore
3248 * @param cred Subject credential
3249 * @param semakptr Pointer to semaphore identifier
3250 * @param semaklabel Label to associate with the semaphore
3252 * Determine whether the subject identified by the credential can
3253 * obtain a System V semaphore.
3255 * @return Return 0 if access is granted, otherwise an appropriate value for
3256 * errno should be returned.
3258 typedef int mpo_sysvsem_check_semget_t(
3260 struct semid_kernel
*semakptr
,
3261 struct label
*semaklabel
3264 * @brief Access control check for System V semaphore operations
3265 * @param cred Subject credential
3266 * @param semakptr Pointer to semaphore identifier
3267 * @param semaklabel Label associated with the semaphore
3268 * @param accesstype Flags to indicate access (read and/or write)
3270 * Determine whether the subject identified by the credential can
3271 * perform the operations on the System V semaphore indicated by
3272 * semakptr. The accesstype flags hold the maximum set of permissions
3273 * from the sem_op array passed to the semop system call. It may
3274 * contain SEM_R for read-only operations or SEM_A for read/write
3277 * @return Return 0 if access is granted, otherwise an appropriate value for
3278 * errno should be returned.
3280 typedef int mpo_sysvsem_check_semop_t(
3282 struct semid_kernel
*semakptr
,
3283 struct label
*semaklabel
,
3287 * @brief Create a System V semaphore label
3288 * @param cred Subject credential
3289 * @param semakptr The semaphore being created
3290 * @param semalabel Label to associate with the new semaphore
3292 * Label a new System V semaphore. The label was previously
3293 * initialized and associated with the semaphore. At this time, an
3294 * appropriate initial label value should be assigned to the object and
3295 * stored in semalabel.
3297 typedef void mpo_sysvsem_label_associate_t(
3299 struct semid_kernel
*semakptr
,
3300 struct label
*semalabel
3303 * @brief Destroy System V semaphore label
3304 * @param label The label to be destroyed
3306 * Destroy a System V semaphore label. Since the object is
3307 * going out of scope, policy modules should free any internal storage
3308 * associated with the label so that it may be destroyed.
3310 typedef void mpo_sysvsem_label_destroy_t(
3314 * @brief Initialize System V semaphore label
3315 * @param label New label to initialize
3317 * Initialize the label for a newly instantiated System V semaphore. Sleeping
3320 typedef void mpo_sysvsem_label_init_t(
3324 * @brief Clean up a System V semaphore label
3325 * @param label The label to be cleaned
3327 * Clean up a System V semaphore label. Darwin pre-allocates
3328 * semaphores at system boot time and re-uses them rather than
3329 * allocating new ones. Before semaphores are returned to the "free
3330 * pool", policies can cleanup or overwrite any information present in
3333 typedef void mpo_sysvsem_label_recycle_t(
3337 * @brief Access control check for mapping System V shared memory
3338 * @param cred Subject credential
3339 * @param shmsegptr Pointer to shared memory segment identifier
3340 * @param shmseglabel Label associated with the shared memory segment
3341 * @param shmflg shmat flags; see shmat(2)
3343 * Determine whether the subject identified by the credential can map
3344 * the System V shared memory segment associated with shmsegptr.
3346 * @return Return 0 if access is granted, otherwise an appropriate value for
3347 * errno should be returned.
3349 typedef int mpo_sysvshm_check_shmat_t(
3351 struct shmid_kernel
*shmsegptr
,
3352 struct label
*shmseglabel
,
3356 * @brief Access control check for System V shared memory control operation
3357 * @param cred Subject credential
3358 * @param shmsegptr Pointer to shared memory segment identifier
3359 * @param shmseglabel Label associated with the shared memory segment
3360 * @param cmd Control operation to be performed; see shmctl(2)
3362 * Determine whether the subject identified by the credential can perform
3363 * the operation indicated by cmd on the System V shared memory segment
3366 * @return Return 0 if access is granted, otherwise an appropriate value for
3367 * errno should be returned.
3369 typedef int mpo_sysvshm_check_shmctl_t(
3371 struct shmid_kernel
*shmsegptr
,
3372 struct label
*shmseglabel
,
3376 * @brief Access control check for unmapping System V shared memory
3377 * @param cred Subject credential
3378 * @param shmsegptr Pointer to shared memory segment identifier
3379 * @param shmseglabel Label associated with the shared memory segment
3381 * Determine whether the subject identified by the credential can unmap
3382 * the System V shared memory segment associated with shmsegptr.
3384 * @return Return 0 if access is granted, otherwise an appropriate value for
3385 * errno should be returned.
3387 typedef int mpo_sysvshm_check_shmdt_t(
3389 struct shmid_kernel
*shmsegptr
,
3390 struct label
*shmseglabel
3393 * @brief Access control check obtaining System V shared memory identifier
3394 * @param cred Subject credential
3395 * @param shmsegptr Pointer to shared memory segment identifier
3396 * @param shmseglabel Label associated with the shared memory segment
3397 * @param shmflg shmget flags; see shmget(2)
3399 * Determine whether the subject identified by the credential can get
3400 * the System V shared memory segment address.
3402 * @return Return 0 if access is granted, otherwise an appropriate value for
3403 * errno should be returned.
3405 typedef int mpo_sysvshm_check_shmget_t(
3407 struct shmid_kernel
*shmsegptr
,
3408 struct label
*shmseglabel
,
3412 * @brief Create a System V shared memory region label
3413 * @param cred Subject credential
3414 * @param shmsegptr The shared memory region being created
3415 * @param shmlabel Label to associate with the new shared memory region
3417 * Label a new System V shared memory region. The label was previously
3418 * initialized and associated with the shared memory region. At this
3419 * time, an appropriate initial label value should be assigned to the
3420 * object and stored in shmlabel.
3422 typedef void mpo_sysvshm_label_associate_t(
3424 struct shmid_kernel
*shmsegptr
,
3425 struct label
*shmlabel
3428 * @brief Destroy System V shared memory label
3429 * @param label The label to be destroyed
3431 * Destroy a System V shared memory region label. Since the
3432 * object is going out of scope, policy modules should free any
3433 * internal storage associated with the label so that it may be
3436 typedef void mpo_sysvshm_label_destroy_t(
3440 * @brief Initialize System V Shared Memory region label
3441 * @param label New label to initialize
3443 * Initialize the label for a newly instantiated System V Shared Memory
3444 * region. Sleeping is permitted.
3446 typedef void mpo_sysvshm_label_init_t(
3450 * @brief Clean up a System V Share Memory Region label
3451 * @param shmlabel The label to be cleaned
3453 * Clean up a System V Shared Memory Region label. Darwin
3454 * pre-allocates these objects at system boot time and re-uses them
3455 * rather than allocating new ones. Before the memory regions are
3456 * returned to the "free pool", policies can cleanup or overwrite any
3457 * information present in the label.
3459 typedef void mpo_sysvshm_label_recycle_t(
3460 struct label
*shmlabel
3463 * @brief Access control check for getting a process's task name
3464 * @param cred Subject credential
3465 * @param pident Object unique process identifier
3467 * Determine whether the subject identified by the credential can get
3468 * the passed process's task name port.
3469 * This call is used by the task_name_for_pid(2) API.
3471 * @return Return 0 if access is granted, otherwise an appropriate value for
3472 * errno should be returned. Suggested failure: EACCES for label mismatch,
3473 * EPERM for lack of privilege, or ESRCH to hide visibility of the target.
3475 typedef int mpo_proc_check_get_task_name_t(
3477 struct proc_ident
*pident
3480 * @brief Access control check for getting a process's task port
3481 * @param cred Subject credential
3482 * @param pident Object unique process identifier
3484 * Determine whether the subject identified by the credential can get
3485 * the passed process's task control port.
3486 * This call is used by the task_for_pid(2) API.
3488 * @return Return 0 if access is granted, otherwise an appropriate value for
3489 * errno should be returned. Suggested failure: EACCES for label mismatch,
3490 * EPERM for lack of privilege, or ESRCH to hide visibility of the target.
3492 typedef int mpo_proc_check_get_task_t(
3494 struct proc_ident
*pident
3498 * @brief Access control check for exposing a process's task port
3499 * @param cred Subject credential
3500 * @param pident Object unique process identifier
3502 * Determine whether the subject identified by the credential can expose
3503 * the passed process's task control port.
3504 * This call is used by the accessor APIs like processor_set_tasks() and
3505 * processor_set_threads().
3507 * @return Return 0 if access is granted, otherwise an appropriate value for
3508 * errno should be returned. Suggested failure: EACCES for label mismatch,
3509 * EPERM for lack of privilege, or ESRCH to hide visibility of the target.
3511 typedef int mpo_proc_check_expose_task_t(
3513 struct proc_ident
*pident
3517 * @brief Check whether task's IPC may inherit across process exec
3518 * @param p current process instance
3519 * @param cur_vp vnode pointer to current instance
3520 * @param cur_offset offset of binary of currently executing image
3521 * @param img_vp vnode pointer to to be exec'ed image
3522 * @param img_offset offset into file which is selected for execution
3523 * @param scriptvp vnode pointer of script file if any.
3524 * @return Return 0 if access is granted.
3525 * EPERM if parent does not have any entitlements.
3526 * EACCESS if mismatch in entitlements
3528 typedef int mpo_proc_check_inherit_ipc_ports_t(
3530 struct vnode
*cur_vp
,
3532 struct vnode
*img_vp
,
3534 struct vnode
*scriptvp
3538 * @brief Privilege check for a process to run invalid
3539 * @param p Object process
3541 * Determine whether the process may execute even though the system determined
3542 * that it is untrusted (eg unidentified / modified code).
3544 * @return Return 0 if access is granted, otherwise an appropriate value for
3545 * errno should be returned.
3547 typedef int mpo_proc_check_run_cs_invalid_t(
3552 * @brief Notification a process was invalidated
3553 * @param p Object process
3555 * Notifies that the CS_VALID bit was removed from a process' csflags. This
3556 * either indicates that a validly code-signed process has encountered an
3557 * invalidly code-signed page for the first time, or that it was explicitly
3558 * marked invalid via a csops(CS_OPS_MARKINVALID) syscall.
3560 * @warning This hook can be called from the page fault handler; it should not
3561 * perform any operations that may result in paging, and stack space is extremely
3562 * limited. Furthermore, the hook is called with proc lock held, and if called
3563 * from the fault handler, with vm object lock held. Consumers reacting to this
3564 * hook being called are expected to defer processing to a userret, possibly
3565 * after suspending the task.
3567 typedef void mpo_proc_notify_cs_invalidated_t(
3572 * @brief Notification a process is finished with exec and will jump to userspace
3573 * @param p Object process
3575 * Notifies all MAC policies that a process has completed an exec and is about to
3576 * jump to userspace to continue execution. This may result in process termination
3577 * via signals. Hook is designed to hold no/minimal locks so it can be used for any
3578 * necessary upcalls.
3580 typedef void mpo_proc_notify_exec_complete_t(
3585 * @brief Perform MAC-related events when a thread returns to user space
3586 * @param thread Mach (not BSD) thread that is returning
3588 * This entry point permits policy modules to perform MAC-related
3589 * events when a thread returns to user space, via a system call
3590 * return or trap return.
3592 typedef void mpo_thread_userret_t(
3593 struct thread
*thread
3597 * @brief Check vnode access
3598 * @param cred Subject credential
3599 * @param vp Object vnode
3600 * @param label Label for vp
3601 * @param acc_mode access(2) flags
3603 * Determine how invocations of access(2) and related calls by the
3604 * subject identified by the credential should return when performed
3605 * on the passed vnode using the passed access flags. This should
3606 * generally be implemented using the same semantics used in
3607 * mpo_vnode_check_open.
3609 * @return Return 0 if access is granted, otherwise an appropriate value for
3610 * errno should be returned. Suggested failure: EACCES for label mismatch or
3611 * EPERM for lack of privilege.
3613 typedef int mpo_vnode_check_access_t(
3616 struct label
*label
,
3620 * @brief Access control check for changing working directory
3621 * @param cred Subject credential
3622 * @param dvp Object; vnode to chdir(2) into
3623 * @param dlabel Policy label for dvp
3625 * Determine whether the subject identified by the credential can change
3626 * the process working directory to the passed vnode.
3628 * @return Return 0 if access is granted, otherwise an appropriate value for
3629 * errno should be returned. Suggested failure: EACCES for label mismatch or
3630 * EPERM for lack of privilege.
3632 typedef int mpo_vnode_check_chdir_t(
3635 struct label
*dlabel
3638 * @brief Access control check for changing root directory
3639 * @param cred Subject credential
3640 * @param dvp Directory vnode
3641 * @param dlabel Policy label associated with dvp
3642 * @param cnp Component name for dvp
3644 * Determine whether the subject identified by the credential should be
3645 * allowed to chroot(2) into the specified directory (dvp).
3647 * @return In the event of an error, an appropriate value for errno
3648 * should be returned, otherwise return 0 upon success.
3650 typedef int mpo_vnode_check_chroot_t(
3653 struct label
*dlabel
,
3654 struct componentname
*cnp
3657 * @brief Access control check for creating clone
3658 * @param cred Subject credential
3659 * @param dvp Vnode of directory to create the clone in
3660 * @param dlabel Policy label associated with dvp
3661 * @param vp Vnode of the file to clone from
3662 * @param label Policy label associated with vp
3663 * @param cnp Component name for the clone being created
3665 * Determine whether the subject identified by the credential should be
3666 * allowed to create a clone of the vnode vp with the name specified by cnp.
3668 * @return Return 0 if access is granted, otherwise an appropriate value for
3669 * errno should be returned.
3671 typedef int mpo_vnode_check_clone_t(
3674 struct label
*dlabel
,
3676 struct label
*label
,
3677 struct componentname
*cnp
3680 * @brief Access control check for creating vnode
3681 * @param cred Subject credential
3682 * @param dvp Directory vnode
3683 * @param dlabel Policy label for dvp
3684 * @param cnp Component name for dvp
3685 * @param vap vnode attributes for vap
3687 * Determine whether the subject identified by the credential can create
3688 * a vnode with the passed parent directory, passed name information,
3689 * and passed attribute information. This call may be made in a number of
3690 * situations, including as a result of calls to open(2) with O_CREAT,
3691 * mknod(2), mkfifo(2), and others.
3693 * @return Return 0 if access is granted, otherwise an appropriate value for
3694 * errno should be returned. Suggested failure: EACCES for label mismatch or
3695 * EPERM for lack of privilege.
3697 typedef int mpo_vnode_check_create_t(
3700 struct label
*dlabel
,
3701 struct componentname
*cnp
,
3702 struct vnode_attr
*vap
3705 * @brief Access control check for deleting extended attribute
3706 * @param cred Subject credential
3707 * @param vp Object vnode
3708 * @param vlabel Label associated with vp
3709 * @param name Extended attribute name
3711 * Determine whether the subject identified by the credential can delete
3712 * the extended attribute from the passed vnode.
3714 * @return Return 0 if access is granted, otherwise an appropriate value for
3715 * errno should be returned. Suggested failure: EACCES for label mismatch or
3716 * EPERM for lack of privilege.
3718 typedef int mpo_vnode_check_deleteextattr_t(
3721 struct label
*vlabel
,
3725 * @brief Access control check for exchanging file data
3726 * @param cred Subject credential
3727 * @param v1 vnode 1 to swap
3728 * @param vl1 Policy label for v1
3729 * @param v2 vnode 2 to swap
3730 * @param vl2 Policy label for v2
3732 * Determine whether the subject identified by the credential can swap the data
3733 * in the two supplied vnodes.
3735 * @return Return 0 if access is granted, otherwise an appropriate value for
3736 * errno should be returned. Suggested failure: EACCES for label mismatch or
3737 * EPERM for lack of privilege.
3739 typedef int mpo_vnode_check_exchangedata_t(
3747 * @brief Access control check for executing the vnode
3748 * @param cred Subject credential
3749 * @param vp Object vnode to execute
3750 * @param scriptvp Script being executed by interpreter, if any.
3751 * @param vnodelabel Label corresponding to vp
3752 * @param scriptlabel Script vnode label
3753 * @param execlabel Userspace provided execution label
3754 * @param cnp Component name for file being executed
3755 * @param macpolicyattr MAC policy-specific spawn attribute data.
3756 * @param macpolicyattrlen Length of policy-specific spawn attribute data.
3758 * Determine whether the subject identified by the credential can execute
3759 * the passed vnode. Determination of execute privilege is made separately
3760 * from decisions about any process label transitioning event.
3762 * The final label, execlabel, corresponds to a label supplied by a
3763 * user space application through the use of the mac_execve system call.
3764 * This label will be NULL if the user application uses the the vendor
3765 * execve(2) call instead of the MAC Framework mac_execve() call.
3767 * @return Return 0 if access is granted, otherwise an appropriate value for
3768 * errno should be returned. Suggested failure: EACCES for label mismatch or
3769 * EPERM for lack of privilege.
3771 typedef int mpo_vnode_check_exec_t(
3774 struct vnode
*scriptvp
,
3775 struct label
*vnodelabel
,
3776 struct label
*scriptlabel
,
3777 struct label
*execlabel
, /* NULLOK */
3778 struct componentname
*cnp
,
3780 void *macpolicyattr
,
3781 size_t macpolicyattrlen
3784 * @brief Access control check for fsgetpath
3785 * @param cred Subject credential
3786 * @param vp Vnode for which a path will be returned
3787 * @param label Label associated with the vnode
3789 * Determine whether the subject identified by the credential can get the path
3790 * of the given vnode with fsgetpath.
3792 * @return Return 0 if access is granted, otherwise an appropriate value for
3793 * errno should be returned.
3795 typedef int mpo_vnode_check_fsgetpath_t(
3801 * @brief Access control check for retrieving file attributes
3802 * @param active_cred Subject credential
3803 * @param file_cred Credential associated with the struct fileproc
3804 * @param vp Object vnode
3805 * @param vlabel Policy label for vp
3806 * @param va Vnode attributes to retrieve
3808 * Determine whether the subject identified by the credential can
3809 * get information about the passed vnode. The active_cred hold
3810 * the credentials of the subject performing the operation, and
3811 * file_cred holds the credentials of the subject that originally
3812 * opened the file. This check happens during stat(), lstat(),
3813 * fstat(), and getattrlist() syscalls. See <sys/vnode.h> for
3814 * definitions of the attributes.
3816 * @return Return 0 if access is granted, otherwise an appropriate value for
3817 * errno should be returned.
3819 * @note Policies may change the contents of va to alter the list of
3820 * file attributes returned.
3822 typedef int mpo_vnode_check_getattr_t(
3823 kauth_cred_t active_cred
,
3824 kauth_cred_t file_cred
, /* NULLOK */
3826 struct label
*vlabel
,
3827 struct vnode_attr
*va
3830 * @brief Access control check for retrieving file attributes
3831 * @param cred Subject credential
3832 * @param vp Object vnode
3833 * @param vlabel Policy label for vp
3834 * @param alist List of attributes to retrieve
3836 * Determine whether the subject identified by the credential can read
3837 * various attributes of the specified vnode, or the filesystem or volume on
3838 * which that vnode resides. See <sys/attr.h> for definitions of the
3841 * @return Return 0 if access is granted, otherwise an appropriate value for
3842 * errno should be returned. Suggested failure: EACCES for label mismatch or
3843 * EPERM for lack of privilege. Access control covers all attributes requested
3844 * with this call; the security policy is not permitted to change the set of
3845 * attributes requested.
3847 typedef int mpo_vnode_check_getattrlist_t(
3850 struct label
*vlabel
,
3851 struct attrlist
*alist
3854 * @brief Access control check for retrieving an extended attribute
3855 * @param cred Subject credential
3856 * @param vp Object vnode
3857 * @param label Policy label for vp
3858 * @param name Extended attribute name
3859 * @param uio I/O structure pointer
3861 * Determine whether the subject identified by the credential can retrieve
3862 * the extended attribute from the passed vnode. The uio parameter
3863 * will be NULL when the getxattr(2) call has been made with a NULL data
3864 * value; this is done to request the size of the data only.
3866 * @return Return 0 if access is granted, otherwise an appropriate value for
3867 * errno should be returned. Suggested failure: EACCES for label mismatch or
3868 * EPERM for lack of privilege.
3870 typedef int mpo_vnode_check_getextattr_t(
3873 struct label
*label
, /* NULLOK */
3875 struct uio
*uio
/* NULLOK */
3878 * @brief Access control check for ioctl
3879 * @param cred Subject credential
3880 * @param vp Object vnode
3881 * @param label Policy label for vp
3882 * @param cmd Device-dependent request code; see ioctl(2)
3884 * Determine whether the subject identified by the credential can perform
3885 * the ioctl operation indicated by com.
3887 * @warning Since ioctl data is opaque from the standpoint of the MAC
3888 * framework, and since ioctls can affect many aspects of system
3889 * operation, policies must exercise extreme care when implementing
3890 * access control checks.
3892 * @return Return 0 if access is granted, otherwise an appropriate value for
3893 * errno should be returned.
3895 typedef int mpo_vnode_check_ioctl_t(
3898 struct label
*label
,
3902 * @brief Access control check for vnode kqfilter
3903 * @param active_cred Subject credential
3904 * @param kn Object knote
3905 * @param vp Object vnode
3906 * @param label Policy label for vp
3908 * Determine whether the subject identified by the credential can
3909 * receive the knote on the passed vnode.
3911 * @return Return 0 if access if granted, otherwise an appropriate
3912 * value for errno should be returned.
3914 typedef int mpo_vnode_check_kqfilter_t(
3915 kauth_cred_t active_cred
,
3916 kauth_cred_t file_cred
, /* NULLOK */
3922 * @brief Access control check for relabel
3923 * @param cred Subject credential
3924 * @param vp Object vnode
3925 * @param vnodelabel Existing policy label for vp
3926 * @param newlabel Policy label update to later be applied to vp
3927 * @see mpo_relable_vnode_t
3929 * Determine whether the subject identified by the credential can relabel
3930 * the passed vnode to the passed label update. If all policies permit
3931 * the label change, the actual relabel entry point (mpo_vnode_label_update)
3934 * @return Return 0 if access is granted, otherwise an appropriate value for
3935 * errno should be returned.
3937 typedef int mpo_vnode_check_label_update_t(
3940 struct label
*vnodelabel
,
3941 struct label
*newlabel
3944 * @brief Access control check for creating link
3945 * @param cred Subject credential
3946 * @param dvp Directory vnode
3947 * @param dlabel Policy label associated with dvp
3948 * @param vp Link destination vnode
3949 * @param label Policy label associated with vp
3950 * @param cnp Component name for the link being created
3952 * Determine whether the subject identified by the credential should be
3953 * allowed to create a link to the vnode vp with the name specified by cnp.
3955 * @return Return 0 if access is granted, otherwise an appropriate value for
3956 * errno should be returned.
3958 typedef int mpo_vnode_check_link_t(
3961 struct label
*dlabel
,
3963 struct label
*label
,
3964 struct componentname
*cnp
3967 * @brief Access control check for listing extended attributes
3968 * @param cred Subject credential
3969 * @param vp Object vnode
3970 * @param vlabel Policy label associated with vp
3972 * Determine whether the subject identified by the credential can retrieve
3973 * a list of named extended attributes from a vnode.
3975 * @return Return 0 if access is granted, otherwise an appropriate value for
3976 * errno should be returned.
3978 typedef int mpo_vnode_check_listextattr_t(
3981 struct label
*vlabel
3984 * @brief Access control check for lookup
3985 * @param cred Subject credential
3986 * @param dvp Directory vnode
3987 * @param dlabel Policy label for dvp
3988 * @param path Path being looked up
3989 * @param pathlen Length of path in bytes
3991 * Determine whether the subject identified by the credential can perform
3992 * a lookup of the passed path relative to the passed directory vnode.
3994 * @return Return 0 if access is granted, otherwise an appropriate value for
3995 * errno should be returned. Suggested failure: EACCES for label mismatch or
3996 * EPERM for lack of privilege.
3998 * @note The path may contain untrusted input. If approved, lookup proceeds
3999 * on the path; if a component is found to be a symlink then this hook is
4000 * called again with the updated path.
4002 typedef int mpo_vnode_check_lookup_preflight_t(
4005 struct label
*dlabel
,
4010 * @brief Access control check for lookup
4011 * @param cred Subject credential
4012 * @param dvp Object vnode
4013 * @param dlabel Policy label for dvp
4014 * @param cnp Component name being looked up
4016 * Determine whether the subject identified by the credential can perform
4017 * a lookup in the passed directory vnode for the passed name (cnp).
4019 * @return Return 0 if access is granted, otherwise an appropriate value for
4020 * errno should be returned. Suggested failure: EACCES for label mismatch or
4021 * EPERM for lack of privilege.
4023 typedef int mpo_vnode_check_lookup_t(
4026 struct label
*dlabel
,
4027 struct componentname
*cnp
4030 * @brief Access control check for open
4031 * @param cred Subject credential
4032 * @param vp Object vnode
4033 * @param label Policy label associated with vp
4034 * @param acc_mode open(2) access mode
4036 * Determine whether the subject identified by the credential can perform
4037 * an open operation on the passed vnode with the passed access mode.
4039 * @return Return 0 if access is granted, otherwise an appropriate value for
4040 * errno should be returned. Suggested failure: EACCES for label mismatch or
4041 * EPERM for lack of privilege.
4043 typedef int mpo_vnode_check_open_t(
4046 struct label
*label
,
4050 * @brief Access control check for read
4051 * @param active_cred Subject credential
4052 * @param file_cred Credential associated with the struct fileproc
4053 * @param vp Object vnode
4054 * @param label Policy label for vp
4056 * Determine whether the subject identified by the credential can perform
4057 * a read operation on the passed vnode. The active_cred hold the credentials
4058 * of the subject performing the operation, and file_cred holds the
4059 * credentials of the subject that originally opened the file.
4061 * @return Return 0 if access is granted, otherwise an appropriate value for
4062 * errno should be returned. Suggested failure: EACCES for label mismatch or
4063 * EPERM for lack of privilege.
4065 typedef int mpo_vnode_check_read_t(
4066 kauth_cred_t active_cred
, /* SUBJECT */
4067 kauth_cred_t file_cred
, /* NULLOK */
4068 struct vnode
*vp
, /* OBJECT */
4069 struct label
*label
/* LABEL */
4072 * @brief Access control check for read directory
4073 * @param cred Subject credential
4074 * @param dvp Object directory vnode
4075 * @param dlabel Policy label for dvp
4077 * Determine whether the subject identified by the credential can
4078 * perform a readdir operation on the passed directory vnode.
4080 * @return Return 0 if access is granted, otherwise an appropriate value for
4081 * errno should be returned. Suggested failure: EACCES for label mismatch or
4082 * EPERM for lack of privilege.
4084 typedef int mpo_vnode_check_readdir_t(
4085 kauth_cred_t cred
, /* SUBJECT */
4086 struct vnode
*dvp
, /* OBJECT */
4087 struct label
*dlabel
/* LABEL */
4090 * @brief Access control check for read link
4091 * @param cred Subject credential
4092 * @param vp Object vnode
4093 * @param label Policy label for vp
4095 * Determine whether the subject identified by the credential can perform
4096 * a readlink operation on the passed symlink vnode. This call can be made
4097 * in a number of situations, including an explicit readlink call by the
4098 * user process, or as a result of an implicit readlink during a name
4099 * lookup by the process.
4101 * @return Return 0 if access is granted, otherwise an appropriate value for
4102 * errno should be returned. Suggested failure: EACCES for label mismatch or
4103 * EPERM for lack of privilege.
4105 typedef int mpo_vnode_check_readlink_t(
4111 * @brief Access control check for rename
4112 * @param cred Subject credential
4113 * @param dvp Directory vnode
4114 * @param dlabel Policy label associated with dvp
4115 * @param vp vnode to be renamed
4116 * @param label Policy label associated with vp
4117 * @param cnp Component name for vp
4118 * @param tdvp Destination directory vnode
4119 * @param tdlabel Policy label associated with tdvp
4120 * @param tvp Overwritten vnode
4121 * @param tlabel Policy label associated with tvp
4122 * @param tcnp Destination component name
4124 * Determine whether the subject identified by the credential should be allowed
4125 * to rename the vnode vp to something else.
4127 * @return Return 0 if access is granted, otherwise an appropriate value for
4128 * errno should be returned.
4130 typedef int mpo_vnode_check_rename_t(
4133 struct label
*dlabel
,
4135 struct label
*label
,
4136 struct componentname
*cnp
,
4138 struct label
*tdlabel
,
4140 struct label
*tlabel
,
4141 struct componentname
*tcnp
4144 * @brief Access control check for rename from
4145 * @param cred Subject credential
4146 * @param dvp Directory vnode
4147 * @param dlabel Policy label associated with dvp
4148 * @param vp vnode to be renamed
4149 * @param label Policy label associated with vp
4150 * @param cnp Component name for vp
4151 * @see mpo_vnode_check_rename_t
4152 * @see mpo_vnode_check_rename_to_t
4154 * Determine whether the subject identified by the credential should be
4155 * allowed to rename the vnode vp to something else.
4157 * Due to VFS locking constraints (to make sure proper vnode locks are
4158 * held during this entry point), the vnode relabel checks had to be
4159 * split into two parts: relabel_from and relabel to.
4161 * This hook is deprecated, mpo_vnode_check_rename_t should be used instead.
4163 * @return Return 0 if access is granted, otherwise an appropriate value for
4164 * errno should be returned.
4166 typedef int mpo_vnode_check_rename_from_t(
4169 struct label
*dlabel
,
4171 struct label
*label
,
4172 struct componentname
*cnp
4175 * @brief Access control check for rename to
4176 * @param cred Subject credential
4177 * @param dvp Directory vnode
4178 * @param dlabel Policy label associated with dvp
4179 * @param vp Overwritten vnode
4180 * @param label Policy label associated with vp
4181 * @param samedir Boolean; 1 if the source and destination directories are the same
4182 * @param cnp Destination component name
4183 * @see mpo_vnode_check_rename_t
4184 * @see mpo_vnode_check_rename_from_t
4186 * Determine whether the subject identified by the credential should be
4187 * allowed to rename to the vnode vp, into the directory dvp, or to the
4188 * name represented by cnp. If there is no existing file to overwrite,
4189 * vp and label will be NULL.
4191 * Due to VFS locking constraints (to make sure proper vnode locks are
4192 * held during this entry point), the vnode relabel checks had to be
4193 * split into two parts: relabel_from and relabel to.
4195 * This hook is deprecated, mpo_vnode_check_rename_t should be used instead.
4197 * @return Return 0 if access is granted, otherwise an appropriate value for
4198 * errno should be returned.
4200 typedef int mpo_vnode_check_rename_to_t(
4203 struct label
*dlabel
,
4204 struct vnode
*vp
, /* NULLOK */
4205 struct label
*label
, /* NULLOK */
4207 struct componentname
*cnp
4210 * @brief Access control check for revoke
4211 * @param cred Subject credential
4212 * @param vp Object vnode
4213 * @param label Policy label for vp
4215 * Determine whether the subject identified by the credential can revoke
4216 * access to the passed vnode.
4218 * @return Return 0 if access is granted, otherwise an appropriate value for
4219 * errno should be returned. Suggested failure: EACCES for label mismatch or
4220 * EPERM for lack of privilege.
4222 typedef int mpo_vnode_check_revoke_t(
4228 * @brief Access control check for searchfs
4229 * @param cred Subject credential
4230 * @param vp Object vnode
4231 * @param vlabel Policy label for vp
4232 * @param alist List of attributes used as search criteria
4234 * Determine whether the subject identified by the credential can search the
4235 * vnode using the searchfs system call.
4237 * @return Return 0 if access is granted, otherwise an appropriate value for
4238 * errno should be returned.
4240 typedef int mpo_vnode_check_searchfs_t(
4243 struct label
*vlabel
,
4244 struct attrlist
*alist
4247 * @brief Access control check for select
4248 * @param cred Subject credential
4249 * @param vp Object vnode
4250 * @param label Policy label for vp
4251 * @param which The operation selected on: FREAD or FWRITE
4253 * Determine whether the subject identified by the credential can select
4256 * @return Return 0 if access is granted, otherwise an appropriate value for
4257 * errno should be returned.
4259 typedef int mpo_vnode_check_select_t(
4262 struct label
*label
,
4266 * @brief Access control check for setting ACL
4267 * @param cred Subject credential
4268 * @param vp Object node
4269 * @param label Policy label for vp
4270 * @param acl ACL structure pointer
4272 * Determine whether the subject identified by the credential can set an ACL
4273 * on the specified vnode. The ACL pointer will be NULL when removing an ACL.
4275 * @return Return 0 if access is granted, otherwise an appropriate value for
4276 * errno should be returned. Suggested failure: EACCES for label mismatch or
4277 * EPERM for lack of privilege.
4279 typedef int mpo_vnode_check_setacl_t(
4282 struct label
*label
,
4283 struct kauth_acl
*acl
4286 * @brief Access control check for setting file attributes
4287 * @param cred Subject credential
4288 * @param vp Object vnode
4289 * @param vlabel Policy label for vp
4290 * @param alist List of attributes to set
4292 * Determine whether the subject identified by the credential can set
4293 * various attributes of the specified vnode, or the filesystem or volume on
4294 * which that vnode resides. See <sys/attr.h> for definitions of the
4297 * @return Return 0 if access is granted, otherwise an appropriate value for
4298 * errno should be returned. Suggested failure: EACCES for label mismatch or
4299 * EPERM for lack of privilege. Access control covers all attributes requested
4302 typedef int mpo_vnode_check_setattrlist_t(
4305 struct label
*vlabel
,
4306 struct attrlist
*alist
4309 * @brief Access control check for setting extended attribute
4310 * @param cred Subject credential
4311 * @param vp Object vnode
4312 * @param label Policy label for vp
4313 * @param name Extended attribute name
4314 * @param uio I/O structure pointer
4316 * Determine whether the subject identified by the credential can set the
4317 * extended attribute of passed name and passed namespace on the passed
4318 * vnode. Policies implementing security labels backed into extended
4319 * attributes may want to provide additional protections for those
4320 * attributes. Additionally, policies should avoid making decisions based
4321 * on the data referenced from uio, as there is a potential race condition
4322 * between this check and the actual operation. The uio may also be NULL
4323 * if a delete operation is being performed.
4325 * @return Return 0 if access is granted, otherwise an appropriate value for
4326 * errno should be returned. Suggested failure: EACCES for label mismatch or
4327 * EPERM for lack of privilege.
4329 typedef int mpo_vnode_check_setextattr_t(
4332 struct label
*label
,
4337 * @brief Access control check for setting flags
4338 * @param cred Subject credential
4339 * @param vp Object vnode
4340 * @param label Policy label for vp
4341 * @param flags File flags; see chflags(2)
4343 * Determine whether the subject identified by the credential can set
4344 * the passed flags on the passed vnode.
4346 * @return Return 0 if access is granted, otherwise an appropriate value for
4347 * errno should be returned. Suggested failure: EACCES for label mismatch or
4348 * EPERM for lack of privilege.
4350 typedef int mpo_vnode_check_setflags_t(
4353 struct label
*label
,
4357 * @brief Access control check for setting mode
4358 * @param cred Subject credential
4359 * @param vp Object vnode
4360 * @param label Policy label for vp
4361 * @param mode File mode; see chmod(2)
4363 * Determine whether the subject identified by the credential can set
4364 * the passed mode on the passed vnode.
4366 * @return Return 0 if access is granted, otherwise an appropriate value for
4367 * errno should be returned. Suggested failure: EACCES for label mismatch or
4368 * EPERM for lack of privilege.
4370 typedef int mpo_vnode_check_setmode_t(
4373 struct label
*label
,
4377 * @brief Access control check for setting uid and gid
4378 * @param cred Subject credential
4379 * @param vp Object vnode
4380 * @param label Policy label for vp
4381 * @param uid User ID
4382 * @param gid Group ID
4384 * Determine whether the subject identified by the credential can set
4385 * the passed uid and passed gid as file uid and file gid on the passed
4386 * vnode. The IDs may be set to (-1) to request no update.
4388 * @return Return 0 if access is granted, otherwise an appropriate value for
4389 * errno should be returned. Suggested failure: EACCES for label mismatch or
4390 * EPERM for lack of privilege.
4392 typedef int mpo_vnode_check_setowner_t(
4395 struct label
*label
,
4400 * @brief Access control check for setting timestamps
4401 * @param cred Subject credential
4402 * @param vp Object vnode
4403 * @param label Policy label for vp
4404 * @param atime Access time; see utimes(2)
4405 * @param mtime Modification time; see utimes(2)
4407 * Determine whether the subject identified by the credential can set
4408 * the passed access timestamps on the passed vnode.
4410 * @return Return 0 if access is granted, otherwise an appropriate value for
4411 * errno should be returned. Suggested failure: EACCES for label mismatch or
4412 * EPERM for lack of privilege.
4414 typedef int mpo_vnode_check_setutimes_t(
4417 struct label
*label
,
4418 struct timespec atime
,
4419 struct timespec mtime
4422 * @brief Access control check after determining the code directory hash
4423 * @param vp vnode vnode to combine into proc
4424 * @param label label associated with the vnode
4425 * @param cpu_type cpu type of the signature being checked
4426 * @param cs_blob the code signature to check
4427 * @param cs_flags update code signing flags if needed
4428 * @param signer_type output parameter for the code signature's signer type
4429 * @param flags operational flag to mpo_vnode_check_signature
4430 * @param platform platform of the signature being checked
4431 * @param fatal_failure_desc description of fatal failure
4432 * @param fatal_failure_desc_len failure description len, failure is fatal if non-0
4434 * @return Return 0 if access is granted, otherwise an appropriate value for
4435 * errno should be returned.
4437 typedef int mpo_vnode_check_signature_t(
4439 struct label
*label
,
4440 cpu_type_t cpu_type
,
4441 struct cs_blob
*cs_blob
,
4442 unsigned int *cs_flags
,
4443 unsigned int *signer_type
,
4445 unsigned int platform
,
4446 char **fatal_failure_desc
, size_t *fatal_failure_desc_len
4450 * @brief Access control check for supplemental signature attachement
4451 * @param vp the vnode to which the signature will be attached
4452 * @param label label associated with the vnode
4453 * @param cs_blob the code signature to check
4454 * @param linked_vp vnode to which this new vp is related
4455 * @param linked_cs_blob the code signature of the linked vnode
4456 * @param signer_type output parameter for the signer type of the code signature being checked.
4458 * @return Return 0 if access is granted, otherwise an appropriate value for
4459 * errno should be returned.
4461 typedef int mpo_vnode_check_supplemental_signature_t(
4463 struct label
*label
,
4464 struct cs_blob
*cs_blob
,
4465 struct vnode
*linked_vp
,
4466 struct cs_blob
*linked_cs_blob
,
4467 unsigned int *signer_type
4471 * @brief Access control check for stat
4472 * @param active_cred Subject credential
4473 * @param file_cred Credential associated with the struct fileproc
4474 * @param vp Object vnode
4475 * @param label Policy label for vp
4477 * Determine whether the subject identified by the credential can stat
4478 * the passed vnode. See stat(2) for more information. The active_cred
4479 * hold the credentials of the subject performing the operation, and
4480 * file_cred holds the credentials of the subject that originally
4483 * @return Return 0 if access is granted, otherwise an appropriate value for
4484 * errno should be returned. Suggested failure: EACCES for label mismatch or
4485 * EPERM for lack of privilege.
4487 typedef int mpo_vnode_check_stat_t(
4488 struct ucred
*active_cred
,
4489 struct ucred
*file_cred
, /* NULLOK */
4494 * @brief Access control check for vnode trigger resolution
4495 * @param cred Subject credential
4496 * @param dvp Object vnode
4497 * @param dlabel Policy label for dvp
4498 * @param cnp Component name that triggered resolution
4500 * Determine whether the subject identified by the credential can trigger
4501 * resolution of the passed name (cnp) in the passed directory vnode
4502 * via an external trigger resolver.
4504 * @return Return 0 if access is granted, otherwise an appropriate value for
4505 * errno should be returned. Suggested failure: EACCES for label mismatch or
4506 * EPERM for lack of privilege.
4508 typedef int mpo_vnode_check_trigger_resolve_t(
4511 struct label
*dlabel
,
4512 struct componentname
*cnp
4515 * @brief Access control check for truncate/ftruncate
4516 * @param active_cred Subject credential
4517 * @param file_cred Credential associated with the struct fileproc
4518 * @param vp Object vnode
4519 * @param label Policy label for vp
4521 * Determine whether the subject identified by the credential can
4522 * perform a truncate operation on the passed vnode. The active_cred hold
4523 * the credentials of the subject performing the operation, and
4524 * file_cred holds the credentials of the subject that originally
4527 * @return Return 0 if access is granted, otherwise an appropriate value for
4528 * errno should be returned. Suggested failure: EACCES for label mismatch or
4529 * EPERM for lack of privilege.
4531 typedef int mpo_vnode_check_truncate_t(
4532 kauth_cred_t active_cred
,
4533 kauth_cred_t file_cred
, /* NULLOK */
4538 * @brief Access control check for binding UNIX domain socket
4539 * @param cred Subject credential
4540 * @param dvp Directory vnode
4541 * @param dlabel Policy label for dvp
4542 * @param cnp Component name for dvp
4543 * @param vap vnode attributes for vap
4545 * Determine whether the subject identified by the credential can perform a
4546 * bind operation on a UNIX domain socket with the passed parent directory,
4547 * passed name information, and passed attribute information.
4549 * @return Return 0 if access is granted, otherwise an appropriate value for
4550 * errno should be returned. Suggested failure: EACCES for label mismatch or
4551 * EPERM for lack of privilege.
4553 typedef int mpo_vnode_check_uipc_bind_t(
4556 struct label
*dlabel
,
4557 struct componentname
*cnp
,
4558 struct vnode_attr
*vap
4561 * @brief Access control check for connecting UNIX domain socket
4562 * @param cred Subject credential
4563 * @param vp Object vnode
4564 * @param label Policy label associated with vp
4567 * Determine whether the subject identified by the credential can perform a
4568 * connect operation on the passed UNIX domain socket vnode.
4570 * @return Return 0 if access is granted, otherwise an appropriate value for
4571 * errno should be returned. Suggested failure: EACCES for label mismatch or
4572 * EPERM for lack of privilege.
4574 typedef int mpo_vnode_check_uipc_connect_t(
4577 struct label
*label
,
4581 * @brief Access control check for deleting vnode
4582 * @param cred Subject credential
4583 * @param dvp Parent directory vnode
4584 * @param dlabel Policy label for dvp
4585 * @param vp Object vnode to delete
4586 * @param label Policy label for vp
4587 * @param cnp Component name for vp
4588 * @see mpo_check_rename_to_t
4590 * Determine whether the subject identified by the credential can delete
4591 * a vnode from the passed parent directory and passed name information.
4592 * This call may be made in a number of situations, including as a
4593 * results of calls to unlink(2) and rmdir(2). Policies implementing
4594 * this entry point should also implement mpo_check_rename_to to
4595 * authorize deletion of objects as a result of being the target of a rename.
4597 * @return Return 0 if access is granted, otherwise an appropriate value for
4598 * errno should be returned. Suggested failure: EACCES for label mismatch or
4599 * EPERM for lack of privilege.
4601 typedef int mpo_vnode_check_unlink_t(
4604 struct label
*dlabel
,
4606 struct label
*label
,
4607 struct componentname
*cnp
4610 * @brief Access control check for write
4611 * @param active_cred Subject credential
4612 * @param file_cred Credential associated with the struct fileproc
4613 * @param vp Object vnode
4614 * @param label Policy label for vp
4616 * Determine whether the subject identified by the credential can
4617 * perform a write operation on the passed vnode. The active_cred hold
4618 * the credentials of the subject performing the operation, and
4619 * file_cred holds the credentials of the subject that originally
4622 * @return Return 0 if access is granted, otherwise an appropriate value for
4623 * errno should be returned. Suggested failure: EACCES for label mismatch or
4624 * EPERM for lack of privilege.
4626 typedef int mpo_vnode_check_write_t(
4627 kauth_cred_t active_cred
,
4628 kauth_cred_t file_cred
, /* NULLOK */
4633 * @brief Associate a vnode with a devfs entry
4634 * @param mp Devfs mount point
4635 * @param mntlabel Devfs mount point label
4636 * @param de Devfs directory entry
4637 * @param delabel Label associated with de
4638 * @param vp vnode associated with de
4639 * @param vlabel Label associated with vp
4641 * Fill in the label (vlabel) for a newly created devfs vnode. The
4642 * label is typically derived from the label on the devfs directory
4643 * entry or the label on the filesystem, supplied as parameters.
4645 typedef void mpo_vnode_label_associate_devfs_t(
4647 struct label
*mntlabel
,
4649 struct label
*delabel
,
4651 struct label
*vlabel
4654 * @brief Associate a label with a vnode
4655 * @param mp File system mount point
4656 * @param mntlabel File system mount point label
4657 * @param vp Vnode to label
4658 * @param vlabel Label associated with vp
4660 * Attempt to retrieve label information for the vnode, vp, from the
4661 * file system extended attribute store. The label should be stored in
4662 * the supplied vlabel parameter. If a policy cannot retrieve an
4663 * extended attribute, sometimes it is acceptible to fallback to using
4666 * If the policy requires vnodes to have a valid label elsewhere it
4667 * MUST NOT return other than temporary errors, and must always provide
4668 * a valid label of some sort. Returning an error will cause vnode
4669 * labeling to be retried at a later access. Failure to handle policy
4670 * centric errors internally (corrupt labels etc.) will result in
4671 * inaccessible files.
4673 * @return In the event of an error, an appropriate value for errno
4674 * should be returned, otherwise return 0 upon success.
4676 typedef int mpo_vnode_label_associate_extattr_t(
4678 struct label
*mntlabel
,
4680 struct label
*vlabel
4683 * @brief Associate a file label with a vnode
4684 * @param cred User credential
4685 * @param mp Fdesc mount point
4686 * @param mntlabel Fdesc mount point label
4687 * @param fg Fileglob structure
4688 * @param label Policy label for fg
4689 * @param vp Vnode to label
4690 * @param vlabel Label associated with vp
4692 * Associate label information for the vnode, vp, with the label of
4693 * the open file descriptor described by fg.
4694 * The label should be stored in the supplied vlabel parameter.
4696 typedef void mpo_vnode_label_associate_file_t(
4699 struct label
*mntlabel
,
4700 struct fileglob
*fg
,
4701 struct label
*label
,
4703 struct label
*vlabel
4706 * @brief Associate a pipe label with a vnode
4707 * @param cred User credential for the process that opened the pipe
4708 * @param cpipe Pipe structure
4709 * @param pipelabel Label associated with pipe
4710 * @param vp Vnode to label
4711 * @param vlabel Label associated with vp
4713 * Associate label information for the vnode, vp, with the label of
4714 * the pipe described by the pipe structure cpipe.
4715 * The label should be stored in the supplied vlabel parameter.
4717 typedef void mpo_vnode_label_associate_pipe_t(
4720 struct label
*pipelabel
,
4722 struct label
*vlabel
4725 * @brief Associate a POSIX semaphore label with a vnode
4726 * @param cred User credential for the process that create psem
4727 * @param psem POSIX semaphore structure
4728 * @param psemlabel Label associated with psem
4729 * @param vp Vnode to label
4730 * @param vlabel Label associated with vp
4732 * Associate label information for the vnode, vp, with the label of
4733 * the POSIX semaphore described by psem.
4734 * The label should be stored in the supplied vlabel parameter.
4736 typedef void mpo_vnode_label_associate_posixsem_t(
4738 struct pseminfo
*psem
,
4739 struct label
*psemlabel
,
4741 struct label
*vlabel
4744 * @brief Associate a POSIX shared memory label with a vnode
4745 * @param cred User credential for the process that created pshm
4746 * @param pshm POSIX shared memory structure
4747 * @param pshmlabel Label associated with pshm
4748 * @param vp Vnode to label
4749 * @param vlabel Label associated with vp
4751 * Associate label information for the vnode, vp, with the label of
4752 * the POSIX shared memory region described by pshm.
4753 * The label should be stored in the supplied vlabel parameter.
4755 typedef void mpo_vnode_label_associate_posixshm_t(
4757 struct pshminfo
*pshm
,
4758 struct label
*pshmlabel
,
4760 struct label
*vlabel
4763 * @brief Associate a label with a vnode
4764 * @param mp File system mount point
4765 * @param mntlabel File system mount point label
4766 * @param vp Vnode to label
4767 * @param vlabel Label associated with vp
4769 * On non-multilabel file systems, set the label for a vnode. The
4770 * label will most likely be based on the file system label.
4772 typedef void mpo_vnode_label_associate_singlelabel_t(
4774 struct label
*mntlabel
,
4776 struct label
*vlabel
4779 * @brief Associate a socket label with a vnode
4780 * @param cred User credential for the process that opened the socket
4781 * @param so Socket structure
4782 * @param solabel Label associated with so
4783 * @param vp Vnode to label
4784 * @param vlabel Label associated with vp
4786 * Associate label information for the vnode, vp, with the label of
4787 * the open socket described by the socket structure so.
4788 * The label should be stored in the supplied vlabel parameter.
4790 typedef void mpo_vnode_label_associate_socket_t(
4793 struct label
*solabel
,
4795 struct label
*vlabel
4798 * @brief Copy a vnode label
4799 * @param src Source vnode label
4800 * @param dest Destination vnode label
4802 * Copy the vnode label information from src to dest. On Darwin, this
4803 * is currently only necessary when executing interpreted scripts, but
4804 * will later be used if vnode label externalization cannot be an
4807 typedef void mpo_vnode_label_copy_t(
4812 * @brief Destroy vnode label
4813 * @param label The label to be destroyed
4815 * Destroy a vnode label. Since the object is going out of scope,
4816 * policy modules should free any internal storage associated with the
4817 * label so that it may be destroyed.
4819 typedef void mpo_vnode_label_destroy_t(
4823 * @brief Externalize a vnode label for auditing
4824 * @param label Label to be externalized
4825 * @param element_name Name of the label namespace for which labels should be
4827 * @param sb String buffer to be filled with a text representation of the label
4829 * Produce an external representation of the label on a vnode suitable for
4830 * inclusion in an audit record. An externalized label consists of a text
4831 * representation of the label contents that will be added to the audit record
4832 * as part of a text token. Policy-agnostic user space tools will display
4833 * this externalized version.
4835 * @return 0 on success, return non-zero if an error occurs while
4836 * externalizing the label data.
4839 typedef int mpo_vnode_label_externalize_audit_t(
4840 struct label
*label
,
4845 * @brief Externalize a vnode label
4846 * @param label Label to be externalized
4847 * @param element_name Name of the label namespace for which labels should be
4849 * @param sb String buffer to be filled with a text representation of the label
4851 * Produce an external representation of the label on a vnode. An
4852 * externalized label consists of a text representation of the label
4853 * contents that can be used with user applications. Policy-agnostic
4854 * user space tools will display this externalized version.
4856 * @return 0 on success, return non-zero if an error occurs while
4857 * externalizing the label data.
4860 typedef int mpo_vnode_label_externalize_t(
4861 struct label
*label
,
4866 * @brief Initialize vnode label
4867 * @param label New label to initialize
4869 * Initialize label storage for use with a newly instantiated vnode, or
4870 * for temporary storage associated with the copying in or out of a
4871 * vnode label. While it is necessary to allocate space for a
4872 * kernel-resident vnode label, it is not yet necessary to link this vnode
4873 * with persistent label storage facilities, such as extended attributes.
4874 * Sleeping is permitted.
4876 typedef void mpo_vnode_label_init_t(
4880 * @brief Internalize a vnode label
4881 * @param label Label to be internalized
4882 * @param element_name Name of the label namespace for which the label should
4884 * @param element_data Text data to be internalized
4886 * Produce a vnode label from an external representation. An
4887 * externalized label consists of a text representation of the label
4888 * contents that can be used with user applications. Policy-agnostic
4889 * user space tools will forward text version to the kernel for
4890 * processing by individual policy modules.
4892 * The policy's internalize entry points will be called only if the
4893 * policy has registered interest in the label namespace.
4895 * @return 0 on success, Otherwise, return non-zero if an error occurs
4896 * while internalizing the label data.
4898 typedef int mpo_vnode_label_internalize_t(
4899 struct label
*label
,
4904 * @brief Clean up a vnode label
4905 * @param label The label to be cleaned or purged
4907 * Clean up a vnode label. Darwin (Tiger, 8.x) allocates vnodes on demand, but
4908 * typically never frees them. Before vnodes are placed back on free lists for
4909 * re-use, policies can cleanup or overwrite any information present in the label,
4910 * or free any internal resources used for the label.
4912 typedef void mpo_vnode_label_recycle_t(
4916 * @brief Write a label to a extended attribute
4917 * @param cred Subject credential
4918 * @param vp The vnode for which the label is being stored
4919 * @param vlabel Label associated with vp
4920 * @param intlabel The new label to store
4922 * Store a new label in the extended attribute corresponding to the
4923 * supplied vnode. The policy has already authorized the operation;
4924 * this call must be implemented in order to perform the actual
4927 * @return In the event of an error, an appropriate value for errno
4928 * should be returned, otherwise return 0 upon success.
4930 * @warning XXX After examining the extended attribute implementation on
4931 * Apple's future release, this entry point may be changed.
4933 typedef int mpo_vnode_label_store_t(
4936 struct label
*vlabel
,
4937 struct label
*intlabel
4940 * @brief Update vnode label from extended attributes
4941 * @param mp File system mount point
4942 * @param mntlabel Mount point label
4943 * @param vp Vnode to label
4944 * @param vlabel Label associated with vp
4945 * @param name Name of the xattr
4946 * @see mpo_vnode_check_setextattr_t
4948 * When an extended attribute is updated via the Vendor attribute management
4949 * functions, the MAC vnode label might also require an update.
4950 * Policies should first determine if 'name' matches their xattr label
4951 * name. If it does, the kernel is has either replaced or removed the
4952 * named extended attribute that was previously associated with the
4953 * vnode. Normally labels should only be modified via MAC Framework label
4954 * management calls, but sometimes the user space components will directly
4955 * modify extended attributes. For example, 'cp', 'tar', etc. manage
4956 * extended attributes in userspace, not the kernel.
4958 * This entry point is called after the label update has occurred, so
4959 * it cannot return a failure. However, the operation is preceded by
4960 * the mpo_vnode_check_setextattr() access control check.
4962 * If the vnode label needs to be updated the policy should return
4963 * a non-zero value. The vnode label will be marked for re-association
4966 typedef int mpo_vnode_label_update_extattr_t(
4968 struct label
*mntlabel
,
4970 struct label
*vlabel
,
4974 * @brief Update a vnode label
4975 * @param cred Subject credential
4976 * @param vp The vnode to relabel
4977 * @param vnodelabel Existing vnode label
4978 * @param label New label to replace existing label
4979 * @see mpo_vnode_check_label_update_t
4981 * The subject identified by the credential has previously requested
4982 * and was authorized to relabel the vnode; this entry point allows
4983 * policies to perform the actual relabel operation. Policies should
4984 * update vnodelabel using the label stored in the label parameter.
4986 typedef void mpo_vnode_label_update_t(
4989 struct label
*vnodelabel
,
4993 * @brief Find deatched signatures for a shared library
4994 * @param p file trying to find the signature
4995 * @param vp The vnode to relabel
4996 * @param offset offset in the macho that the signature is requested for (for fat binaries)
4997 * @param label Existing vnode label
5000 typedef int mpo_vnode_find_sigs_t(
5007 * @brief Create a new vnode, backed by extended attributes
5008 * @param cred User credential for the creating process
5009 * @param mp File system mount point
5010 * @param mntlabel File system mount point label
5011 * @param dvp Parent directory vnode
5012 * @param dlabel Parent directory vnode label
5013 * @param vp Newly created vnode
5014 * @param vlabel Label to associate with the new vnode
5015 * @param cnp Component name for vp
5017 * Write out the label for the newly created vnode, most likely storing
5018 * the results in a file system extended attribute. Most policies will
5019 * derive the new vnode label using information from a combination
5020 * of the subject (user) credential, the file system label, the parent
5021 * directory label, and potentially the path name component.
5023 * @return If the operation succeeds, store the new label in vlabel and
5024 * return 0. Otherwise, return an appropriate errno value.
5026 typedef int mpo_vnode_notify_create_t(
5029 struct label
*mntlabel
,
5031 struct label
*dlabel
,
5033 struct label
*vlabel
,
5034 struct componentname
*cnp
5038 * @brief Inform MAC policies that a vnode has been opened
5039 * @param cred User credential for the creating process
5040 * @param vp vnode opened
5041 * @param label Policy label for the vp
5042 * @param acc_mode open(2) access mode used
5044 * Inform Mac policies that a vnode have been successfully opened
5045 * (passing all MAC polices and DAC).
5047 typedef void mpo_vnode_notify_open_t(
5050 struct label
*label
,
5055 * @brief Inform MAC policies that a vnode has been renamed
5056 * @param cred User credential for the renaming process
5057 * @param vp Vnode that's being renamed
5058 * @param label Policy label for vp
5059 * @param dvp Parent directory for the destination
5060 * @param dlabel Policy label for dvp
5061 * @param cnp Component name for the destination
5063 * Inform MAC policies that a vnode has been renamed.
5065 typedef void mpo_vnode_notify_rename_t(
5068 struct label
*label
,
5070 struct label
*dlabel
,
5071 struct componentname
*cnp
5075 * @brief Inform MAC policies that a vnode has been linked
5076 * @param cred User credential for the renaming process
5077 * @param dvp Parent directory for the destination
5078 * @param dlabel Policy label for dvp
5079 * @param vp Vnode that's being linked
5080 * @param vlabel Policy label for vp
5081 * @param cnp Component name for the destination
5083 * Inform MAC policies that a vnode has been linked.
5085 typedef void mpo_vnode_notify_link_t(
5088 struct label
*dlabel
,
5090 struct label
*vlabel
,
5091 struct componentname
*cnp
5095 * @brief Inform MAC policies that an extended attribute has been removed from a vnode
5096 * @param cred Subject credential
5097 * @param vp Object node
5098 * @param label Policy label for vp
5099 * @param name Extended attribute name
5101 * Inform MAC policies that an extended attribute has been removed from a vnode.
5103 typedef void mpo_vnode_notify_deleteextattr_t(
5106 struct label
*label
,
5112 * @brief Inform MAC policies that an ACL has been set on a vnode
5113 * @param cred Subject credential
5114 * @param vp Object node
5115 * @param label Policy label for vp
5116 * @param acl ACL structure pointer
5118 * Inform MAC policies that an ACL has been set on a vnode.
5120 typedef void mpo_vnode_notify_setacl_t(
5123 struct label
*label
,
5124 struct kauth_acl
*acl
5128 * @brief Inform MAC policies that an attributes have been set on a vnode
5129 * @param cred Subject credential
5130 * @param vp Object vnode
5131 * @param label Policy label for vp
5132 * @param alist List of attributes to set
5134 * Inform MAC policies that an attributes have been set on a vnode.
5136 typedef void mpo_vnode_notify_setattrlist_t(
5139 struct label
*label
,
5140 struct attrlist
*alist
5144 * @brief Inform MAC policies that an extended attribute has been set on a vnode
5145 * @param cred Subject credential
5146 * @param vp Object vnode
5147 * @param label Policy label for vp
5148 * @param name Extended attribute name
5149 * @param uio I/O structure pointer
5151 * Inform MAC policies that an extended attribute has been set on a vnode.
5153 typedef void mpo_vnode_notify_setextattr_t(
5156 struct label
*label
,
5162 * @brief Inform MAC policies that flags have been set on a vnode
5163 * @param cred Subject credential
5164 * @param vp Object vnode
5165 * @param label Policy label for vp
5166 * @param flags File flags; see chflags(2)
5168 * Inform MAC policies that flags have been set on a vnode.
5170 typedef void mpo_vnode_notify_setflags_t(
5173 struct label
*label
,
5178 * @brief Inform MAC policies that a new mode has been set on a vnode
5179 * @param cred Subject credential
5180 * @param vp Object vnode
5181 * @param label Policy label for vp
5182 * @param mode File mode; see chmod(2)
5184 * Inform MAC policies that a new mode has been set on a vnode.
5186 typedef void mpo_vnode_notify_setmode_t(
5189 struct label
*label
,
5194 * @brief Inform MAC policies that new uid/gid have been set on a vnode
5195 * @param cred Subject credential
5196 * @param vp Object vnode
5197 * @param label Policy label for vp
5198 * @param uid User ID
5199 * @param gid Group ID
5201 * Inform MAC policies that new uid/gid have been set on a vnode.
5203 typedef void mpo_vnode_notify_setowner_t(
5206 struct label
*label
,
5212 * @brief Inform MAC policies that new timestamps have been set on a vnode
5213 * @param cred Subject credential
5214 * @param vp Object vnode
5215 * @param label Policy label for vp
5216 * @param atime Access time; see utimes(2)
5217 * @param mtime Modification time; see utimes(2)
5219 * Inform MAC policies that new timestamps have been set on a vnode.
5221 typedef void mpo_vnode_notify_setutimes_t(
5224 struct label
*label
,
5225 struct timespec atime
,
5226 struct timespec mtime
5230 * @brief Inform MAC policies that a vnode has been truncated
5231 * @param cred Subject credential
5232 * @param file_cred Credential associated with the struct fileproc
5233 * @param vp Object vnode
5234 * @param label Policy label for vp
5236 * Inform MAC policies that a vnode has been truncated.
5238 typedef void mpo_vnode_notify_truncate_t(
5240 kauth_cred_t file_cred
,
5247 * @brief Inform MAC policies that a pty slave has been granted
5248 * @param p Responsible process
5249 * @param tp tty data structure
5250 * @param dev Major and minor numbers of device
5251 * @param label Policy label for tp
5253 * Inform MAC policies that a pty slave has been granted.
5255 typedef void mpo_pty_notify_grant_t(
5263 * @brief Inform MAC policies that a pty master has been closed
5264 * @param p Responsible process
5265 * @param tp tty data structure
5266 * @param dev Major and minor numbers of device
5267 * @param label Policy label for tp
5269 * Inform MAC policies that a pty master has been closed.
5271 typedef void mpo_pty_notify_close_t(
5279 * @brief Access control check for kext loading
5280 * @param cred Subject credential
5281 * @param identifier Kext identifier
5283 * Determine whether the subject identified by the credential can load the
5286 * @return Return 0 if access is granted, otherwise an appropriate value for
5287 * errno should be returned. Suggested failure: EPERM for lack of privilege.
5289 typedef int mpo_kext_check_load_t(
5291 const char *identifier
5295 * @brief Access control check for kext unloading
5296 * @param cred Subject credential
5297 * @param identifier Kext identifier
5299 * Determine whether the subject identified by the credential can unload the
5302 * @return Return 0 if access is granted, otherwise an appropriate value for
5303 * errno should be returned. Suggested failure: EPERM for lack of privilege.
5305 typedef int mpo_kext_check_unload_t(
5307 const char *identifier
5311 * @brief Access control check for querying information about loaded kexts
5312 * @param cred Subject credential
5314 * Determine whether the subject identified by the credential can query
5315 * information about loaded kexts.
5317 * @return Return 0 if access is granted, otherwise an appropriate value for
5318 * errno should be returned. Suggested failure: EPERM for lack of privilege.
5320 typedef int mpo_kext_check_query_t(
5325 * @brief Inform MAC policies that a vnode is being reclaimed
5326 * @param vp Object vnode
5328 * Any external accounting tracking this vnode must consider it to be no longer valid.
5330 typedef void mpo_vnode_notify_reclaim_t(
5335 * Placeholder for future events that may need mac hooks.
5337 typedef void mpo_reserved_hook_t(void);
5340 * Policy module operations.
5342 * Please note that this should be kept in sync with the check assumptions
5343 * policy in bsd/kern/policy_check.c (policy_ops struct).
5345 #define MAC_POLICY_OPS_VERSION 69 /* inc when new reserved slots are taken */
5346 struct mac_policy_ops
{
5347 mpo_audit_check_postselect_t
*mpo_audit_check_postselect
;
5348 mpo_audit_check_preselect_t
*mpo_audit_check_preselect
;
5350 mpo_reserved_hook_t
*mpo_reserved01
;
5351 mpo_reserved_hook_t
*mpo_reserved02
;
5352 mpo_reserved_hook_t
*mpo_reserved03
;
5353 mpo_reserved_hook_t
*mpo_reserved04
;
5355 mpo_cred_check_label_update_execve_t
*mpo_cred_check_label_update_execve
;
5356 mpo_cred_check_label_update_t
*mpo_cred_check_label_update
;
5357 mpo_cred_check_visible_t
*mpo_cred_check_visible
;
5358 mpo_cred_label_associate_fork_t
*mpo_cred_label_associate_fork
;
5359 mpo_cred_label_associate_kernel_t
*mpo_cred_label_associate_kernel
;
5360 mpo_cred_label_associate_t
*mpo_cred_label_associate
;
5361 mpo_cred_label_associate_user_t
*mpo_cred_label_associate_user
;
5362 mpo_cred_label_destroy_t
*mpo_cred_label_destroy
;
5363 mpo_cred_label_externalize_audit_t
*mpo_cred_label_externalize_audit
;
5364 mpo_cred_label_externalize_t
*mpo_cred_label_externalize
;
5365 mpo_cred_label_init_t
*mpo_cred_label_init
;
5366 mpo_cred_label_internalize_t
*mpo_cred_label_internalize
;
5367 mpo_cred_label_update_execve_t
*mpo_cred_label_update_execve
;
5368 mpo_cred_label_update_t
*mpo_cred_label_update
;
5370 mpo_devfs_label_associate_device_t
*mpo_devfs_label_associate_device
;
5371 mpo_devfs_label_associate_directory_t
*mpo_devfs_label_associate_directory
;
5372 mpo_devfs_label_copy_t
*mpo_devfs_label_copy
;
5373 mpo_devfs_label_destroy_t
*mpo_devfs_label_destroy
;
5374 mpo_devfs_label_init_t
*mpo_devfs_label_init
;
5375 mpo_devfs_label_update_t
*mpo_devfs_label_update
;
5377 mpo_file_check_change_offset_t
*mpo_file_check_change_offset
;
5378 mpo_file_check_create_t
*mpo_file_check_create
;
5379 mpo_file_check_dup_t
*mpo_file_check_dup
;
5380 mpo_file_check_fcntl_t
*mpo_file_check_fcntl
;
5381 mpo_file_check_get_offset_t
*mpo_file_check_get_offset
;
5382 mpo_file_check_get_t
*mpo_file_check_get
;
5383 mpo_file_check_inherit_t
*mpo_file_check_inherit
;
5384 mpo_file_check_ioctl_t
*mpo_file_check_ioctl
;
5385 mpo_file_check_lock_t
*mpo_file_check_lock
;
5386 mpo_file_check_mmap_downgrade_t
*mpo_file_check_mmap_downgrade
;
5387 mpo_file_check_mmap_t
*mpo_file_check_mmap
;
5388 mpo_file_check_receive_t
*mpo_file_check_receive
;
5389 mpo_file_check_set_t
*mpo_file_check_set
;
5390 mpo_file_label_init_t
*mpo_file_label_init
;
5391 mpo_file_label_destroy_t
*mpo_file_label_destroy
;
5392 mpo_file_label_associate_t
*mpo_file_label_associate
;
5393 mpo_file_notify_close_t
*mpo_file_notify_close
;
5395 mpo_reserved_hook_t
*mpo_reserved06
;
5396 mpo_reserved_hook_t
*mpo_reserved07
;
5397 mpo_reserved_hook_t
*mpo_reserved08
;
5398 mpo_reserved_hook_t
*mpo_reserved09
;
5399 mpo_reserved_hook_t
*mpo_reserved10
;
5400 mpo_reserved_hook_t
*mpo_reserved11
;
5401 mpo_reserved_hook_t
*mpo_reserved12
;
5402 mpo_reserved_hook_t
*mpo_reserved13
;
5403 mpo_reserved_hook_t
*mpo_reserved14
;
5404 mpo_reserved_hook_t
*mpo_reserved15
;
5405 mpo_reserved_hook_t
*mpo_reserved16
;
5406 mpo_reserved_hook_t
*mpo_reserved17
;
5407 mpo_reserved_hook_t
*mpo_reserved18
;
5408 mpo_reserved_hook_t
*mpo_reserved19
;
5409 mpo_reserved_hook_t
*mpo_reserved20
;
5410 mpo_reserved_hook_t
*mpo_reserved21
;
5411 mpo_reserved_hook_t
*mpo_reserved22
;
5412 mpo_reserved_hook_t
*mpo_reserved23
;
5413 mpo_reserved_hook_t
*mpo_reserved24
;
5414 mpo_reserved_hook_t
*mpo_reserved25
;
5415 mpo_reserved_hook_t
*mpo_reserved26
;
5417 mpo_file_check_library_validation_t
*mpo_file_check_library_validation
;
5418 mpo_vnode_notify_setacl_t
*mpo_vnode_notify_setacl
;
5419 mpo_vnode_notify_setattrlist_t
*mpo_vnode_notify_setattrlist
;
5420 mpo_vnode_notify_setextattr_t
*mpo_vnode_notify_setextattr
;
5421 mpo_vnode_notify_setflags_t
*mpo_vnode_notify_setflags
;
5422 mpo_vnode_notify_setmode_t
*mpo_vnode_notify_setmode
;
5423 mpo_vnode_notify_setowner_t
*mpo_vnode_notify_setowner
;
5424 mpo_vnode_notify_setutimes_t
*mpo_vnode_notify_setutimes
;
5425 mpo_vnode_notify_truncate_t
*mpo_vnode_notify_truncate
;
5427 mpo_reserved_hook_t
*mpo_reserved27
;
5428 mpo_reserved_hook_t
*mpo_reserved28
;
5429 mpo_reserved_hook_t
*mpo_reserved29
;
5430 mpo_reserved_hook_t
*mpo_reserved30
;
5431 mpo_reserved_hook_t
*mpo_reserved31
;
5432 mpo_reserved_hook_t
*mpo_reserved32
;
5433 mpo_reserved_hook_t
*mpo_reserved33
;
5434 mpo_reserved_hook_t
*mpo_reserved34
;
5435 mpo_reserved_hook_t
*mpo_reserved35
;
5436 mpo_reserved_hook_t
*mpo_reserved36
;
5437 mpo_reserved_hook_t
*mpo_reserved37
;
5439 mpo_mount_check_fsctl_t
*mpo_mount_check_fsctl
;
5440 mpo_mount_check_getattr_t
*mpo_mount_check_getattr
;
5441 mpo_mount_check_label_update_t
*mpo_mount_check_label_update
;
5442 mpo_mount_check_mount_t
*mpo_mount_check_mount
;
5443 mpo_mount_check_remount_t
*mpo_mount_check_remount
;
5444 mpo_mount_check_setattr_t
*mpo_mount_check_setattr
;
5445 mpo_mount_check_stat_t
*mpo_mount_check_stat
;
5446 mpo_mount_check_umount_t
*mpo_mount_check_umount
;
5447 mpo_mount_label_associate_t
*mpo_mount_label_associate
;
5448 mpo_mount_label_destroy_t
*mpo_mount_label_destroy
;
5449 mpo_mount_label_externalize_t
*mpo_mount_label_externalize
;
5450 mpo_mount_label_init_t
*mpo_mount_label_init
;
5451 mpo_mount_label_internalize_t
*mpo_mount_label_internalize
;
5453 mpo_reserved_hook_t
*mpo_reserved38
;
5454 mpo_reserved_hook_t
*mpo_reserved39
;
5455 mpo_reserved_hook_t
*mpo_reserved40
;
5457 mpo_pipe_check_ioctl_t
*mpo_pipe_check_ioctl
;
5458 mpo_pipe_check_kqfilter_t
*mpo_pipe_check_kqfilter
;
5459 mpo_reserved_hook_t
*mpo_reserved41
;
5460 mpo_pipe_check_read_t
*mpo_pipe_check_read
;
5461 mpo_pipe_check_select_t
*mpo_pipe_check_select
;
5462 mpo_pipe_check_stat_t
*mpo_pipe_check_stat
;
5463 mpo_pipe_check_write_t
*mpo_pipe_check_write
;
5464 mpo_pipe_label_associate_t
*mpo_pipe_label_associate
;
5465 mpo_reserved_hook_t
*mpo_reserved42
;
5466 mpo_pipe_label_destroy_t
*mpo_pipe_label_destroy
;
5467 mpo_reserved_hook_t
*mpo_reserved43
;
5468 mpo_pipe_label_init_t
*mpo_pipe_label_init
;
5469 mpo_reserved_hook_t
*mpo_reserved44
;
5470 mpo_reserved_hook_t
*mpo_reserved45
;
5472 mpo_policy_destroy_t
*mpo_policy_destroy
;
5473 mpo_policy_init_t
*mpo_policy_init
;
5474 mpo_policy_initbsd_t
*mpo_policy_initbsd
;
5475 mpo_policy_syscall_t
*mpo_policy_syscall
;
5477 mpo_system_check_sysctlbyname_t
*mpo_system_check_sysctlbyname
;
5478 mpo_proc_check_inherit_ipc_ports_t
*mpo_proc_check_inherit_ipc_ports
;
5479 mpo_vnode_check_rename_t
*mpo_vnode_check_rename
;
5480 mpo_kext_check_query_t
*mpo_kext_check_query
;
5481 mpo_proc_notify_exec_complete_t
*mpo_proc_notify_exec_complete
;
5482 mpo_proc_notify_cs_invalidated_t
*mpo_proc_notify_cs_invalidated
;
5483 mpo_proc_check_syscall_unix_t
*mpo_proc_check_syscall_unix
;
5484 mpo_proc_check_expose_task_t
*mpo_proc_check_expose_task
;
5485 mpo_proc_check_set_host_special_port_t
*mpo_proc_check_set_host_special_port
;
5486 mpo_proc_check_set_host_exception_port_t
*mpo_proc_check_set_host_exception_port
;
5487 mpo_exc_action_check_exception_send_t
*mpo_exc_action_check_exception_send
;
5488 mpo_exc_action_label_associate_t
*mpo_exc_action_label_associate
;
5489 mpo_exc_action_label_populate_t
*mpo_exc_action_label_populate
;
5490 mpo_exc_action_label_destroy_t
*mpo_exc_action_label_destroy
;
5491 mpo_exc_action_label_init_t
*mpo_exc_action_label_init
;
5492 mpo_exc_action_label_update_t
*mpo_exc_action_label_update
;
5494 mpo_vnode_check_trigger_resolve_t
*mpo_vnode_check_trigger_resolve
;
5495 mpo_mount_check_mount_late_t
*mpo_mount_check_mount_late
;
5496 mpo_mount_check_snapshot_mount_t
*mpo_mount_check_snapshot_mount
;
5497 mpo_vnode_notify_reclaim_t
*mpo_vnode_notify_reclaim
;
5498 mpo_skywalk_flow_check_connect_t
*mpo_skywalk_flow_check_connect
;
5499 mpo_skywalk_flow_check_listen_t
*mpo_skywalk_flow_check_listen
;
5501 mpo_posixsem_check_create_t
*mpo_posixsem_check_create
;
5502 mpo_posixsem_check_open_t
*mpo_posixsem_check_open
;
5503 mpo_posixsem_check_post_t
*mpo_posixsem_check_post
;
5504 mpo_posixsem_check_unlink_t
*mpo_posixsem_check_unlink
;
5505 mpo_posixsem_check_wait_t
*mpo_posixsem_check_wait
;
5506 mpo_posixsem_label_associate_t
*mpo_posixsem_label_associate
;
5507 mpo_posixsem_label_destroy_t
*mpo_posixsem_label_destroy
;
5508 mpo_posixsem_label_init_t
*mpo_posixsem_label_init
;
5509 mpo_posixshm_check_create_t
*mpo_posixshm_check_create
;
5510 mpo_posixshm_check_mmap_t
*mpo_posixshm_check_mmap
;
5511 mpo_posixshm_check_open_t
*mpo_posixshm_check_open
;
5512 mpo_posixshm_check_stat_t
*mpo_posixshm_check_stat
;
5513 mpo_posixshm_check_truncate_t
*mpo_posixshm_check_truncate
;
5514 mpo_posixshm_check_unlink_t
*mpo_posixshm_check_unlink
;
5515 mpo_posixshm_label_associate_t
*mpo_posixshm_label_associate
;
5516 mpo_posixshm_label_destroy_t
*mpo_posixshm_label_destroy
;
5517 mpo_posixshm_label_init_t
*mpo_posixshm_label_init
;
5519 mpo_proc_check_debug_t
*mpo_proc_check_debug
;
5520 mpo_proc_check_fork_t
*mpo_proc_check_fork
;
5521 mpo_proc_check_get_task_name_t
*mpo_proc_check_get_task_name
;
5522 mpo_proc_check_get_task_t
*mpo_proc_check_get_task
;
5523 mpo_proc_check_getaudit_t
*mpo_proc_check_getaudit
;
5524 mpo_proc_check_getauid_t
*mpo_proc_check_getauid
;
5525 mpo_proc_check_getlcid_t
*mpo_proc_check_getlcid
;
5526 mpo_proc_check_mprotect_t
*mpo_proc_check_mprotect
;
5527 mpo_proc_check_sched_t
*mpo_proc_check_sched
;
5528 mpo_proc_check_setaudit_t
*mpo_proc_check_setaudit
;
5529 mpo_proc_check_setauid_t
*mpo_proc_check_setauid
;
5530 mpo_proc_check_setlcid_t
*mpo_proc_check_setlcid
;
5531 mpo_proc_check_signal_t
*mpo_proc_check_signal
;
5532 mpo_proc_check_wait_t
*mpo_proc_check_wait
;
5533 mpo_proc_check_dump_core_t
*mpo_proc_check_dump_core
;
5534 mpo_proc_check_remote_thread_create_t
*mpo_proc_check_remote_thread_create
;
5536 mpo_socket_check_accept_t
*mpo_socket_check_accept
;
5537 mpo_socket_check_accepted_t
*mpo_socket_check_accepted
;
5538 mpo_socket_check_bind_t
*mpo_socket_check_bind
;
5539 mpo_socket_check_connect_t
*mpo_socket_check_connect
;
5540 mpo_socket_check_create_t
*mpo_socket_check_create
;
5541 mpo_reserved_hook_t
*mpo_reserved46
;
5542 mpo_reserved_hook_t
*mpo_reserved47
;
5543 mpo_reserved_hook_t
*mpo_reserved48
;
5544 mpo_socket_check_listen_t
*mpo_socket_check_listen
;
5545 mpo_socket_check_receive_t
*mpo_socket_check_receive
;
5546 mpo_socket_check_received_t
*mpo_socket_check_received
;
5547 mpo_reserved_hook_t
*mpo_reserved49
;
5548 mpo_socket_check_send_t
*mpo_socket_check_send
;
5549 mpo_socket_check_stat_t
*mpo_socket_check_stat
;
5550 mpo_socket_check_setsockopt_t
*mpo_socket_check_setsockopt
;
5551 mpo_socket_check_getsockopt_t
*mpo_socket_check_getsockopt
;
5553 mpo_reserved_hook_t
*mpo_reserved50
;
5554 mpo_reserved_hook_t
*mpo_reserved51
;
5555 mpo_reserved_hook_t
*mpo_reserved52
;
5556 mpo_reserved_hook_t
*mpo_reserved53
;
5557 mpo_reserved_hook_t
*mpo_reserved54
;
5558 mpo_reserved_hook_t
*mpo_reserved55
;
5559 mpo_reserved_hook_t
*mpo_reserved56
;
5560 mpo_reserved_hook_t
*mpo_reserved57
;
5561 mpo_reserved_hook_t
*mpo_reserved58
;
5562 mpo_reserved_hook_t
*mpo_reserved59
;
5563 mpo_reserved_hook_t
*mpo_reserved60
;
5564 mpo_reserved_hook_t
*mpo_reserved61
;
5565 mpo_reserved_hook_t
*mpo_reserved62
;
5567 mpo_system_check_acct_t
*mpo_system_check_acct
;
5568 mpo_system_check_audit_t
*mpo_system_check_audit
;
5569 mpo_system_check_auditctl_t
*mpo_system_check_auditctl
;
5570 mpo_system_check_auditon_t
*mpo_system_check_auditon
;
5571 mpo_system_check_host_priv_t
*mpo_system_check_host_priv
;
5572 mpo_system_check_nfsd_t
*mpo_system_check_nfsd
;
5573 mpo_system_check_reboot_t
*mpo_system_check_reboot
;
5574 mpo_system_check_settime_t
*mpo_system_check_settime
;
5575 mpo_system_check_swapoff_t
*mpo_system_check_swapoff
;
5576 mpo_system_check_swapon_t
*mpo_system_check_swapon
;
5577 mpo_socket_check_ioctl_t
*mpo_socket_check_ioctl
;
5579 mpo_sysvmsg_label_associate_t
*mpo_sysvmsg_label_associate
;
5580 mpo_sysvmsg_label_destroy_t
*mpo_sysvmsg_label_destroy
;
5581 mpo_sysvmsg_label_init_t
*mpo_sysvmsg_label_init
;
5582 mpo_sysvmsg_label_recycle_t
*mpo_sysvmsg_label_recycle
;
5583 mpo_sysvmsq_check_enqueue_t
*mpo_sysvmsq_check_enqueue
;
5584 mpo_sysvmsq_check_msgrcv_t
*mpo_sysvmsq_check_msgrcv
;
5585 mpo_sysvmsq_check_msgrmid_t
*mpo_sysvmsq_check_msgrmid
;
5586 mpo_sysvmsq_check_msqctl_t
*mpo_sysvmsq_check_msqctl
;
5587 mpo_sysvmsq_check_msqget_t
*mpo_sysvmsq_check_msqget
;
5588 mpo_sysvmsq_check_msqrcv_t
*mpo_sysvmsq_check_msqrcv
;
5589 mpo_sysvmsq_check_msqsnd_t
*mpo_sysvmsq_check_msqsnd
;
5590 mpo_sysvmsq_label_associate_t
*mpo_sysvmsq_label_associate
;
5591 mpo_sysvmsq_label_destroy_t
*mpo_sysvmsq_label_destroy
;
5592 mpo_sysvmsq_label_init_t
*mpo_sysvmsq_label_init
;
5593 mpo_sysvmsq_label_recycle_t
*mpo_sysvmsq_label_recycle
;
5594 mpo_sysvsem_check_semctl_t
*mpo_sysvsem_check_semctl
;
5595 mpo_sysvsem_check_semget_t
*mpo_sysvsem_check_semget
;
5596 mpo_sysvsem_check_semop_t
*mpo_sysvsem_check_semop
;
5597 mpo_sysvsem_label_associate_t
*mpo_sysvsem_label_associate
;
5598 mpo_sysvsem_label_destroy_t
*mpo_sysvsem_label_destroy
;
5599 mpo_sysvsem_label_init_t
*mpo_sysvsem_label_init
;
5600 mpo_sysvsem_label_recycle_t
*mpo_sysvsem_label_recycle
;
5601 mpo_sysvshm_check_shmat_t
*mpo_sysvshm_check_shmat
;
5602 mpo_sysvshm_check_shmctl_t
*mpo_sysvshm_check_shmctl
;
5603 mpo_sysvshm_check_shmdt_t
*mpo_sysvshm_check_shmdt
;
5604 mpo_sysvshm_check_shmget_t
*mpo_sysvshm_check_shmget
;
5605 mpo_sysvshm_label_associate_t
*mpo_sysvshm_label_associate
;
5606 mpo_sysvshm_label_destroy_t
*mpo_sysvshm_label_destroy
;
5607 mpo_sysvshm_label_init_t
*mpo_sysvshm_label_init
;
5608 mpo_sysvshm_label_recycle_t
*mpo_sysvshm_label_recycle
;
5610 mpo_proc_notify_exit_t
*mpo_proc_notify_exit
;
5611 mpo_mount_check_snapshot_revert_t
*mpo_mount_check_snapshot_revert
;
5612 mpo_vnode_check_getattr_t
*mpo_vnode_check_getattr
;
5613 mpo_mount_check_snapshot_create_t
*mpo_mount_check_snapshot_create
;
5614 mpo_mount_check_snapshot_delete_t
*mpo_mount_check_snapshot_delete
;
5615 mpo_vnode_check_clone_t
*mpo_vnode_check_clone
;
5616 mpo_proc_check_get_cs_info_t
*mpo_proc_check_get_cs_info
;
5617 mpo_proc_check_set_cs_info_t
*mpo_proc_check_set_cs_info
;
5619 mpo_iokit_check_hid_control_t
*mpo_iokit_check_hid_control
;
5621 mpo_vnode_check_access_t
*mpo_vnode_check_access
;
5622 mpo_vnode_check_chdir_t
*mpo_vnode_check_chdir
;
5623 mpo_vnode_check_chroot_t
*mpo_vnode_check_chroot
;
5624 mpo_vnode_check_create_t
*mpo_vnode_check_create
;
5625 mpo_vnode_check_deleteextattr_t
*mpo_vnode_check_deleteextattr
;
5626 mpo_vnode_check_exchangedata_t
*mpo_vnode_check_exchangedata
;
5627 mpo_vnode_check_exec_t
*mpo_vnode_check_exec
;
5628 mpo_vnode_check_getattrlist_t
*mpo_vnode_check_getattrlist
;
5629 mpo_vnode_check_getextattr_t
*mpo_vnode_check_getextattr
;
5630 mpo_vnode_check_ioctl_t
*mpo_vnode_check_ioctl
;
5631 mpo_vnode_check_kqfilter_t
*mpo_vnode_check_kqfilter
;
5632 mpo_vnode_check_label_update_t
*mpo_vnode_check_label_update
;
5633 mpo_vnode_check_link_t
*mpo_vnode_check_link
;
5634 mpo_vnode_check_listextattr_t
*mpo_vnode_check_listextattr
;
5635 mpo_vnode_check_lookup_t
*mpo_vnode_check_lookup
;
5636 mpo_vnode_check_open_t
*mpo_vnode_check_open
;
5637 mpo_vnode_check_read_t
*mpo_vnode_check_read
;
5638 mpo_vnode_check_readdir_t
*mpo_vnode_check_readdir
;
5639 mpo_vnode_check_readlink_t
*mpo_vnode_check_readlink
;
5640 mpo_vnode_check_rename_from_t
*mpo_vnode_check_rename_from
;
5641 mpo_vnode_check_rename_to_t
*mpo_vnode_check_rename_to
;
5642 mpo_vnode_check_revoke_t
*mpo_vnode_check_revoke
;
5643 mpo_vnode_check_select_t
*mpo_vnode_check_select
;
5644 mpo_vnode_check_setattrlist_t
*mpo_vnode_check_setattrlist
;
5645 mpo_vnode_check_setextattr_t
*mpo_vnode_check_setextattr
;
5646 mpo_vnode_check_setflags_t
*mpo_vnode_check_setflags
;
5647 mpo_vnode_check_setmode_t
*mpo_vnode_check_setmode
;
5648 mpo_vnode_check_setowner_t
*mpo_vnode_check_setowner
;
5649 mpo_vnode_check_setutimes_t
*mpo_vnode_check_setutimes
;
5650 mpo_vnode_check_stat_t
*mpo_vnode_check_stat
;
5651 mpo_vnode_check_truncate_t
*mpo_vnode_check_truncate
;
5652 mpo_vnode_check_unlink_t
*mpo_vnode_check_unlink
;
5653 mpo_vnode_check_write_t
*mpo_vnode_check_write
;
5654 mpo_vnode_label_associate_devfs_t
*mpo_vnode_label_associate_devfs
;
5655 mpo_vnode_label_associate_extattr_t
*mpo_vnode_label_associate_extattr
;
5656 mpo_vnode_label_associate_file_t
*mpo_vnode_label_associate_file
;
5657 mpo_vnode_label_associate_pipe_t
*mpo_vnode_label_associate_pipe
;
5658 mpo_vnode_label_associate_posixsem_t
*mpo_vnode_label_associate_posixsem
;
5659 mpo_vnode_label_associate_posixshm_t
*mpo_vnode_label_associate_posixshm
;
5660 mpo_vnode_label_associate_singlelabel_t
*mpo_vnode_label_associate_singlelabel
;
5661 mpo_vnode_label_associate_socket_t
*mpo_vnode_label_associate_socket
;
5662 mpo_vnode_label_copy_t
*mpo_vnode_label_copy
;
5663 mpo_vnode_label_destroy_t
*mpo_vnode_label_destroy
;
5664 mpo_vnode_label_externalize_audit_t
*mpo_vnode_label_externalize_audit
;
5665 mpo_vnode_label_externalize_t
*mpo_vnode_label_externalize
;
5666 mpo_vnode_label_init_t
*mpo_vnode_label_init
;
5667 mpo_vnode_label_internalize_t
*mpo_vnode_label_internalize
;
5668 mpo_vnode_label_recycle_t
*mpo_vnode_label_recycle
;
5669 mpo_vnode_label_store_t
*mpo_vnode_label_store
;
5670 mpo_vnode_label_update_extattr_t
*mpo_vnode_label_update_extattr
;
5671 mpo_vnode_label_update_t
*mpo_vnode_label_update
;
5672 mpo_vnode_notify_create_t
*mpo_vnode_notify_create
;
5673 mpo_vnode_check_signature_t
*mpo_vnode_check_signature
;
5674 mpo_vnode_check_uipc_bind_t
*mpo_vnode_check_uipc_bind
;
5675 mpo_vnode_check_uipc_connect_t
*mpo_vnode_check_uipc_connect
;
5677 mpo_proc_check_run_cs_invalid_t
*mpo_proc_check_run_cs_invalid
;
5678 mpo_proc_check_suspend_resume_t
*mpo_proc_check_suspend_resume
;
5680 mpo_thread_userret_t
*mpo_thread_userret
;
5682 mpo_iokit_check_set_properties_t
*mpo_iokit_check_set_properties
;
5684 mpo_vnode_check_supplemental_signature_t
*mpo_vnode_check_supplemental_signature
;
5686 mpo_vnode_check_searchfs_t
*mpo_vnode_check_searchfs
;
5688 mpo_priv_check_t
*mpo_priv_check
;
5689 mpo_priv_grant_t
*mpo_priv_grant
;
5691 mpo_proc_check_map_anon_t
*mpo_proc_check_map_anon
;
5693 mpo_vnode_check_fsgetpath_t
*mpo_vnode_check_fsgetpath
;
5695 mpo_iokit_check_open_t
*mpo_iokit_check_open
;
5697 mpo_proc_check_ledger_t
*mpo_proc_check_ledger
;
5699 mpo_vnode_notify_rename_t
*mpo_vnode_notify_rename
;
5701 mpo_vnode_check_setacl_t
*mpo_vnode_check_setacl
;
5703 mpo_vnode_notify_deleteextattr_t
*mpo_vnode_notify_deleteextattr
;
5705 mpo_system_check_kas_info_t
*mpo_system_check_kas_info
;
5707 mpo_vnode_check_lookup_preflight_t
*mpo_vnode_check_lookup_preflight
;
5709 mpo_vnode_notify_open_t
*mpo_vnode_notify_open
;
5711 mpo_system_check_info_t
*mpo_system_check_info
;
5713 mpo_pty_notify_grant_t
*mpo_pty_notify_grant
;
5714 mpo_pty_notify_close_t
*mpo_pty_notify_close
;
5716 mpo_vnode_find_sigs_t
*mpo_vnode_find_sigs
;
5718 mpo_kext_check_load_t
*mpo_kext_check_load
;
5719 mpo_kext_check_unload_t
*mpo_kext_check_unload
;
5721 mpo_proc_check_proc_info_t
*mpo_proc_check_proc_info
;
5722 mpo_vnode_notify_link_t
*mpo_vnode_notify_link
;
5723 mpo_iokit_check_filter_properties_t
*mpo_iokit_check_filter_properties
;
5724 mpo_iokit_check_get_property_t
*mpo_iokit_check_get_property
;
5728 * @brief MAC policy handle type
5730 * The MAC handle is used to uniquely identify a loaded policy within
5731 * the MAC Framework.
5733 * A variable of this type is set by mac_policy_register().
5735 typedef unsigned int mac_policy_handle_t
;
5737 #define mpc_t struct mac_policy_conf *
5740 * @brief Mac policy configuration
5742 * This structure specifies the configuration information for a
5743 * MAC policy module. A policy module developer must supply
5744 * a short unique policy name, a more descriptive full name, a list of label
5745 * namespaces and count, a pointer to the registered enty point operations,
5746 * any load time flags, and optionally, a pointer to a label slot identifier.
5748 * The Framework will update the runtime flags (mpc_runtime_flags) to
5749 * indicate that the module has been registered.
5751 * If the label slot identifier (mpc_field_off) is NULL, the Framework
5752 * will not provide label storage for the policy. Otherwise, the
5753 * Framework will store the label location (slot) in this field.
5755 * The mpc_list field is used by the Framework and should not be
5756 * modified by policies.
5758 /* XXX - reorder these for better aligment on 64bit platforms */
5759 struct mac_policy_conf
{
5760 const char *mpc_name
; /** policy name */
5761 const char *mpc_fullname
; /** full name */
5762 char const * const *mpc_labelnames
; /** managed label namespaces */
5763 unsigned int mpc_labelname_count
; /** number of managed label namespaces */
5764 const struct mac_policy_ops
*mpc_ops
; /** operation vector */
5765 int mpc_loadtime_flags
; /** load time flags */
5766 int *mpc_field_off
; /** label slot */
5767 int mpc_runtime_flags
; /** run time flags */
5768 mpc_t mpc_list
; /** List reference */
5769 void *mpc_data
; /** module data */
5773 * @brief MAC policy module registration routine
5775 * This function is called to register a policy with the
5776 * MAC framework. A policy module will typically call this from the
5777 * Darwin KEXT registration routine.
5779 int mac_policy_register(struct mac_policy_conf
*mpc
,
5780 mac_policy_handle_t
*handlep
, void *xd
);
5783 * @brief MAC policy module de-registration routine
5785 * This function is called to de-register a policy with theD
5786 * MAC framework. A policy module will typically call this from the
5787 * Darwin KEXT de-registration routine.
5789 int mac_policy_unregister(mac_policy_handle_t handle
);
5792 * Framework entry points for the policies to add audit data.
5794 int mac_audit_text(char *text
, mac_policy_handle_t handle
);
5797 * Calls to assist with use of Apple XATTRs within policy modules.
5799 int mac_vnop_setxattr(struct vnode
*, const char *, char *, size_t);
5800 int mac_vnop_getxattr(struct vnode
*, const char *, char *, size_t,
5802 int mac_vnop_removexattr(struct vnode
*, const char *);
5805 * @brief Set an extended attribute on a vnode-based fileglob.
5806 * @param fg fileglob representing file to attach the extended attribute
5807 * @param name extended attribute name
5808 * @param buf buffer of data to use as the extended attribute value
5809 * @param len size of buffer
5811 * Sets the value of an extended attribute on a file.
5813 * Caller must hold an iocount on the vnode represented by the fileglob.
5815 #ifdef KERNEL_PRIVATE
5816 int mac_file_setxattr(struct fileglob
*fg
, const char *name
, char *buf
, size_t len
);
5820 * @brief Get an extended attribute from a vnode-based fileglob.
5821 * @param fg fileglob representing file to read the extended attribute
5822 * @param name extended attribute name
5823 * @param buf buffer of data to hold the extended attribute value
5824 * @param len size of buffer
5825 * @param attrlen size of full extended attribute value
5827 * Gets the value of an extended attribute on a file.
5829 * Caller must hold an iocount on the vnode represented by the fileglob.
5831 #ifdef KERNEL_PRIVATE
5832 int mac_file_getxattr(struct fileglob
*fg
, const char *name
, char *buf
, size_t len
,
5837 * @brief Remove an extended attribute from a vnode-based fileglob.
5838 * @param fg fileglob representing file to remove the extended attribute
5839 * @param name extended attribute name
5841 * Removes the named extended attribute from the file.
5843 * Caller must hold an iocount on the vnode represented by the fileglob.
5845 #ifdef KERNEL_PRIVATE
5846 int mac_file_removexattr(struct fileglob
*fg
, const char *name
);
5850 * Arbitrary limit on how much data will be logged by the audit
5851 * entry points above.
5853 #define MAC_AUDIT_DATA_LIMIT 1024
5856 * Values returned by mac_audit_{pre,post}select. To combine the responses
5857 * of the security policies into a single decision,
5858 * mac_audit_{pre,post}select() choose the greatest value returned.
5860 #define MAC_AUDIT_DEFAULT 0 /* use system behavior */
5861 #define MAC_AUDIT_NO 1 /* force not auditing this event */
5862 #define MAC_AUDIT_YES 2 /* force auditing this event */
5864 // \defgroup mpc_loadtime_flags Flags for the mpc_loadtime_flags field
5867 * @name Flags for the mpc_loadtime_flags field
5868 * @see mac_policy_conf
5870 * This is the complete list of flags that are supported by the
5871 * mpc_loadtime_flags field of the mac_policy_conf structure. These
5872 * flags specify the load time behavior of MAC Framework policy
5879 * @brief Flag to indicate registration preference
5881 * This flag indicates that the policy module must be loaded and
5882 * initialized early in the boot process. If the flag is specified,
5883 * attempts to register the module following boot will be rejected. The
5884 * flag may be used by policies that require pervasive labeling of all
5885 * system objects, and cannot handle objects that have not been
5886 * properly initialized by the policy.
5888 #define MPC_LOADTIME_FLAG_NOTLATE 0x00000001
5891 * @brief Flag to indicate unload preference
5893 * This flag indicates that the policy module may be unloaded. If this
5894 * flag is not set, then the policy framework will reject requests to
5895 * unload the module. This flag might be used by modules that allocate
5896 * label state and are unable to free that state at runtime, or for
5897 * modules that simply do not want to permit unload operations.
5899 #define MPC_LOADTIME_FLAG_UNLOADOK 0x00000002
5902 * @brief Unsupported
5904 * XXX This flag is not yet supported.
5906 #define MPC_LOADTIME_FLAG_LABELMBUFS 0x00000004
5909 * @brief Flag to indicate a base policy
5911 * This flag indicates that the policy module is a base policy. Only
5912 * one module can declare itself as base, otherwise the boot process
5915 #define MPC_LOADTIME_BASE_POLICY 0x00000008
5920 * @brief Policy registration flag
5921 * @see mac_policy_conf
5923 * This flag indicates that the policy module has been successfully
5924 * registered with the TrustedBSD MAC Framework. The Framework will
5925 * set this flag in the mpc_runtime_flags field of the policy's
5926 * mac_policy_conf structure after registering the policy.
5928 #define MPC_RUNTIME_FLAG_REGISTERED 0x00000001
5931 * Depends on POLICY_VER
5935 #define POLICY_VER 1.0
5938 #define MAC_POLICY_SET(handle, mpops, mpname, mpfullname, lnames, lcount, slot, lflags, rflags) \
5939 static struct mac_policy_conf mpname##_mac_policy_conf = { \
5940 .mpc_name = #mpname, \
5941 .mpc_fullname = mpfullname, \
5942 .mpc_labelnames = lnames, \
5943 .mpc_labelname_count = lcount, \
5945 .mpc_loadtime_flags = lflags, \
5946 .mpc_field_off = slot, \
5947 .mpc_runtime_flags = rflags \
5950 static kern_return_t \
5951 kmod_start(kmod_info_t *ki, void *xd) \
5953 return mac_policy_register(&mpname##_mac_policy_conf, \
5957 static kern_return_t \
5958 kmod_stop(kmod_info_t *ki, void *xd) \
5960 return mac_policy_unregister(handle); \
5963 extern kern_return_t _start(kmod_info_t *ki, void *data); \
5964 extern kern_return_t _stop(kmod_info_t *ki, void *data); \
5966 KMOD_EXPLICIT_DECL(security.mpname, POLICY_VER, _start, _stop) \
5967 kmod_start_func_t *_realmain = kmod_start; \
5968 kmod_stop_func_t *_antimain = kmod_stop; \
5969 int _kext_apple_cc = __APPLE_CC__
5972 #define LABEL_TO_SLOT(l, s) (l)->l_perpolicy[s]
5975 * Policy interface to map a struct label pointer to per-policy data.
5976 * Typically, policies wrap this in their own accessor macro that casts an
5977 * intptr_t to a policy-specific data type.
5979 #ifdef KERNEL_PRIVATE
5980 intptr_t mac_label_get(struct label
*l
, int slot
);
5981 void mac_label_set(struct label
*l
, int slot
, intptr_t v
);
5982 intptr_t mac_vnode_label_get(struct vnode
*vp
, int slot
, intptr_t sentinel
);
5983 void mac_vnode_label_set(struct vnode
*vp
, int slot
, intptr_t v
);
5986 #define mac_get_mpc(h) (mac_policy_list.entries[h].mpc)
5989 * @name Flags for MAC allocator interfaces
5991 * These flags are passed to the Darwin kernel allocator routines to
5992 * indicate whether the allocation is permitted to block or not.
5993 * Caution should be taken; some operations are not permitted to sleep,
5994 * and some types of locks cannot be held when sleeping.
6000 * @brief Allocation operations may block
6002 * If memory is not immediately available, the allocation routine
6003 * will block (typically sleeping) until memory is available.
6005 * @warning Inappropriate use of this flag may cause kernel panics.
6007 #define MAC_WAITOK 0
6010 * @brief Allocation operations may not block
6012 * Rather than blocking, the allocator may return an error if memory
6013 * is not immediately available. This type of allocation will not
6014 * sleep, preserving locking semantics.
6016 #define MAC_NOWAIT 1
6020 #endif /* !_SECURITY_MAC_POLICY_H_ */