2 * Copyright (c) 2000-2006 Apple Computer, 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@
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
34 * All Rights Reserved.
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
46 * Carnegie Mellon requests users of this software to return to
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
57 * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce
58 * support for mandatory and extensible security protections. This notice
59 * is included in support of clause 2.2 (b) of the Apple Public License,
65 * File: kern/ipc_kobject.h
69 * Declarations for letting a port represent a kernel object.
72 #ifdef MACH_KERNEL_PRIVATE
73 #include <ipc/ipc_kmsg.h>
74 #include <ipc/ipc_port.h>
75 #endif /* MACH_KERNEL_PRIVATE */
77 #ifndef _KERN_IPC_KOBJECT_H_
78 #define _KERN_IPC_KOBJECT_H_
82 * This is the legacy in-kernel ipc-object mechanism. Over the next
83 * several months, this will be phased out in favor of a mechanism that
84 * is less Mach IPC specific, and common across in-mach, in-kernel-component,
85 * and user-level-component (Plugin) models.
87 #include <mach/machine/vm_types.h>
88 #include <mach/mach_types.h>
90 typedef natural_t ipc_kobject_type_t
;
93 #define IKOT_THREAD_CONTROL 1
94 #define IKOT_TASK_CONTROL 2
96 #define IKOT_HOST_PRIV 4
97 #define IKOT_PROCESSOR 5
99 #define IKOT_PSET_NAME 7
101 #define IKOT_PORT_SUBST_ONCE 9
103 #define IKOT_MEMORY_OBJECT 11
104 #define IKOT_XMM_PAGER 12
105 #define IKOT_XMM_KERNEL 13
106 #define IKOT_XMM_REPLY 14
107 #define IKOT_UND_REPLY 15
108 #define IKOT_HOST_NOTIFY 16
109 #define IKOT_HOST_SECURITY 17
110 #define IKOT_LEDGER 18
111 #define IKOT_MASTER_DEVICE 19
112 #define IKOT_TASK_NAME 20
113 #define IKOT_SUBSYSTEM 21
114 #define IKOT_IO_DONE_QUEUE 22
115 #define IKOT_SEMAPHORE 23
116 #define IKOT_LOCK_SET 24
117 #define IKOT_CLOCK 25
118 #define IKOT_CLOCK_CTRL 26
119 #define IKOT_IOKIT_IDENT 27
120 #define IKOT_NAMED_ENTRY 28
121 #define IKOT_IOKIT_CONNECT 29
122 #define IKOT_IOKIT_OBJECT 30
124 #define IKOT_MEM_OBJ_CONTROL 32
125 #define IKOT_AU_SESSIONPORT 33
126 #define IKOT_FILEPORT 34
127 #define IKOT_LABELH 35
128 #define IKOT_TASK_RESUME 36
129 #define IKOT_VOUCHER 37
130 #define IKOT_VOUCHER_ATTR_CONTROL 38
131 #define IKOT_WORK_INTERVAL 39
132 #define IKOT_UX_HANDLER 40
133 #define IKOT_UEXT_OBJECT 41
134 #define IKOT_ARCADE_REG 42
135 #define IKOT_EVENTLINK 43
136 #define IKOT_TASK_INSPECT 44
137 #define IKOT_TASK_READ 45
138 #define IKOT_THREAD_INSPECT 46
139 #define IKOT_THREAD_READ 47
140 #define IKOT_SUID_CRED 48
141 #define IKOT_HYPERVISOR 49
142 #define IKOT_TASK_ID_TOKEN 50
145 * Add new entries here and adjust IKOT_UNKNOWN.
146 * Please keep ipc/ipc_object.c:ikot_print_array up to date.
148 #define IKOT_UNKNOWN 51 /* magic catchall */
149 #define IKOT_MAX_TYPE (IKOT_UNKNOWN+1) /* # of IKOT_ types */
151 /* set the bitstring index for kobject */
152 extern kern_return_t
ipc_kobject_set_kobjidx(
156 #ifdef MACH_KERNEL_PRIVATE
158 struct ipc_kobject_label
{
159 ipc_label_t ikol_label
; /* [private] mandatory access label */
160 ipc_kobject_t
XNU_PTRAUTH_SIGNED_PTR("ipc_kobject_label.ikol_kobject") ikol_kobject
; /* actual kobject address */
163 /* initialization of kobject subsystem */
164 extern void ipc_kobject_init(void);
166 /* Dispatch a kernel server function */
167 extern ipc_kmsg_t
ipc_kobject_server(
169 mach_msg_option_t option
);
171 /* Make a port represent a kernel object of the given type */
172 extern void ipc_kobject_set(
174 ipc_kobject_t kobject
,
175 ipc_kobject_type_t type
);
177 extern void ipc_kobject_set_atomically(
179 ipc_kobject_t kobject
,
180 ipc_kobject_type_t type
);
182 __options_decl(ipc_kobject_alloc_options_t
, uint32_t, {
183 /* Just make the naked port */
184 IPC_KOBJECT_ALLOC_NONE
= 0x00000000,
185 /* Make a send right */
186 IPC_KOBJECT_ALLOC_MAKE_SEND
= 0x00000001,
187 /* Register for no-more-senders */
188 IPC_KOBJECT_ALLOC_NSREQUEST
= 0x00000002,
189 /* Make it no grant port */
190 IPC_KOBJECT_ALLOC_NO_GRANT
= 0x00000004,
191 /* Make all the send rights immovable */
192 IPC_KOBJECT_ALLOC_IMMOVABLE_SEND
= 0x00000008,
193 /* Add a label structure to the port */
194 IPC_KOBJECT_ALLOC_LABEL
= 0x00000010,
195 /* Make all rights pinned (non dealloc-able) in an ipc space*/
196 IPC_KOBJECT_ALLOC_PINNED
= 0x00000020,
199 /* Allocates a kobject port, never fails */
200 extern ipc_port_t
ipc_kobject_alloc_port(
201 ipc_kobject_t kobject
,
202 ipc_kobject_type_t type
,
203 ipc_kobject_alloc_options_t options
);
205 /* Allocates a kobject port, never fails */
206 extern ipc_port_t
ipc_kobject_alloc_labeled_port(
207 ipc_kobject_t kobject
,
208 ipc_kobject_type_t type
,
210 ipc_kobject_alloc_options_t options
);
212 extern ipc_port_t
ipc_kobject_alloc_subst_once(
215 /* Makes a send right, lazily allocating a kobject port, arming for no-senders, never fails */
216 extern boolean_t
ipc_kobject_make_send_lazy_alloc_port(
217 ipc_port_t
*port_store
,
218 ipc_kobject_t kobject
,
219 ipc_kobject_type_t type
,
220 ipc_kobject_alloc_options_t alloc_opts
,
221 boolean_t should_ptrauth
,
222 uint64_t ptrauth_discriminator
) __result_use_check
;
224 /* Makes a send right, lazily allocating a kobject port, arming for no-senders, never fails */
225 extern boolean_t
ipc_kobject_make_send_lazy_alloc_labeled_port(
226 ipc_port_t
*port_store
,
227 ipc_kobject_t kobject
,
228 ipc_kobject_type_t type
,
229 ipc_label_t label
) __result_use_check
;
231 /* Get the kobject address associated with a port */
232 static inline ipc_kobject_t
233 ipc_kobject_get(ipc_port_t port
)
235 if (ip_is_kobject(port
)) {
236 if (ip_is_kolabeled(port
)) {
237 return port
->ip_kolabel
->ikol_kobject
;
239 return port
->ip_kobject
;
244 /* Check if a kobject can be copied out to a given space */
245 extern bool ipc_kobject_label_check(
248 mach_msg_type_name_t msgt_name
,
249 ipc_object_copyout_flags_t
*flags
,
250 ipc_port_t
*subst_portp
) __result_use_check
;
257 mach_msg_type_name_t msgt_name
,
258 ipc_object_copyout_flags_t
*flags
,
259 ipc_port_t
*subst_portp
)
261 if (!ip_is_kolabeled(port
)) {
262 *subst_portp
= IP_NULL
;
265 return ipc_kobject_label_check(space
, port
, msgt_name
, flags
, subst_portp
);
268 /* Release any kernel object resources associated with a port */
269 extern void ipc_kobject_destroy(
272 #define null_conversion(port) (port)
275 uext_server(ipc_kmsg_t request
, ipc_kmsg_t
* reply
);
277 /* These boot-args decide if the pinned and immovable ports can be copied out to IPC space */
278 __options_decl(ipc_control_port_options_t
, uint32_t, {
279 IPC_CONTROL_PORT_OPTIONS_NONE
= 0x00,
281 IPC_CONTROL_PORT_OPTIONS_PINNED_SOFT
= 0x01,
282 IPC_CONTROL_PORT_OPTIONS_PINNED_HARD
= 0x02,
284 IPC_CONTROL_PORT_OPTIONS_IMMOVABLE_SOFT
= 0x10,
285 IPC_CONTROL_PORT_OPTIONS_IMMOVABLE_HARD
= 0x20,
288 extern ipc_control_port_options_t ipc_control_port_options
;
289 extern bool pinned_control_port_enabled
;
290 extern bool immovable_control_port_enabled
;
292 #endif /* MACH_KERNEL_PRIVATE */
294 #endif /* KERNEL_PRIVATE */
296 #endif /* _KERN_IPC_KOBJECT_H_ */