1 /* 2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 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. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 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. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28 /* 29 * @OSF_COPYRIGHT@ 30 */ 31 32 /* 33 * Define Basic IPC types available to callers. 34 * These are not intended to be used directly, but 35 * are used to define other types available through 36 * port.h and mach_types.h for in-kernel entities. 37 */ 38 39 #ifndef _IPC_IPC_TYPES_H_ 40 #define _IPC_IPC_TYPES_H_ 41 42 #include <mach/port.h> 43 #include <mach/message.h> 44 #include <mach/mach_types.h> 45 46 #ifdef MACH_KERNEL_PRIVATE 47 48 typedef natural_t ipc_table_index_t; /* index into tables */ 49 typedef natural_t ipc_table_elems_t; /* size of tables */ 50 typedef natural_t ipc_entry_bits_t; 51 typedef ipc_table_elems_t ipc_entry_num_t; /* number of entries */ 52 typedef ipc_table_index_t ipc_port_request_index_t; 53 54 typedef mach_port_name_t mach_port_index_t; /* index values */ 55 typedef mach_port_name_t mach_port_gen_t; /* generation numbers */ 56 57 typedef struct ipc_entry *ipc_entry_t; 58 59 typedef struct ipc_table_size *ipc_table_size_t; 60 typedef struct ipc_port_request *ipc_port_request_t; 61 typedef struct ipc_pset *ipc_pset_t; 62 typedef struct ipc_kmsg *ipc_kmsg_t; 63 typedef uint8_t sync_qos_count_t; 64 65 typedef uint64_t ipc_label_t; 66 #define IPC_LABEL_NONE ((ipc_label_t)0x0000) 67 #define IPC_LABEL_DEXT ((ipc_label_t)0x0001) 68 #define IPC_LABEL_PLATFORM ((ipc_label_t)0x0002) 69 #define IPC_LABEL_SPECIAL ((ipc_label_t)0x0003) 70 #define IPC_LABEL_SPACE_MASK ((ipc_label_t)0x00ff) 71 72 #define IPC_LABEL_SUBST_TASK_READ ((ipc_label_t)0x0400) 73 #define IPC_LABEL_SUBST_THREAD_READ ((ipc_label_t)0x0500) 74 #define IPC_LABEL_SUBST_MASK ((ipc_label_t)0xff00) 75 76 typedef struct ipc_kobject_label *ipc_kobject_label_t; 77 78 #define IE_NULL ((ipc_entry_t)NULL) 79 80 #define ITS_NULL ((ipc_table_size_t)NULL) 81 #define ITS_SIZE_NONE ((ipc_table_elems_t) -1) 82 #define IPR_NULL ((ipc_port_request_t)NULL) 83 #define IPS_NULL ((ipc_pset_t)NULL) 84 #define IKM_NULL ((ipc_kmsg_t)NULL) 85 86 typedef void (*mach_msg_continue_t)(mach_msg_return_t); /* after wakeup */ 87 #define MACH_MSG_CONTINUE_NULL ((mach_msg_continue_t)NULL) 88 89 typedef struct ipc_importance_elem *__single ipc_importance_elem_t; 90 #define IIE_NULL ((ipc_importance_elem_t)NULL) 91 92 typedef struct ipc_importance_task *__single ipc_importance_task_t; 93 #define IIT_NULL ((ipc_importance_task_t)NULL) 94 95 typedef struct ipc_importance_inherit *__single ipc_importance_inherit_t; 96 #define III_NULL ((ipc_importance_inherit_t)NULL) 97 98 /*! 99 * @typedef ipc_space_policy_t 100 * 101 * @brief 102 * Flags used to determine the IPC policy for a given task/space. 103 * 104 * @const IPC_SPACE_POLICY_INVALID 105 * This policy is never used, the zero value is never a valid policy. 106 * 107 * @const IPC_SPACE_POLICY_DEFAULT 108 * Denotes that this task has the default policy. 109 * This bit is always set in a properly inited policy. 110 * 111 * @const IPC_SPACE_POLICY_ENHANCED 112 * Denotes an IPC space for a task that has opted in some way to receive more 113 * security. The "enhanced" security space has several versions for bincompat 114 * reasons, where each increasing version opts you into more security features. 115 * `ENHANCED_V0` includes those opted into macOS hardened runtime 116 * `ENHANCED_V1` includes those opted into browser entitlements (FY24) 117 * `ENHANCED_V2` includes those opted into the FY25 platform restrictions entitlement 118 * No new features should be placed into the previous versions for bincompat 119 * reasons, and binaries opted into the newer versions always get the features 120 * from all previous versions. 121 * 122 * @const IPC_SPACE_POLICY_PLATFORM 123 * Denotes an IPC space for a platform binary. This flag always implies 124 * @c IPC_SPACE_POLICY_ENHANCED is set, meaning platform binaries always get the 125 * highest version of platform restrictions. 126 * 127 * @const IPC_SPACE_POLICY_KERNEL 128 * Denotes that this is the IPC space for the kernel. 129 * 130 * @const IPC_SPACE_POLICY_SIMULATED 131 * Denotes IPC spaces for simulator environments (macOS only). 132 * In general this bit will cause policies to be relaxed because software 133 * running in these environment was written before policies were made, 134 * and probably do not comply with them naturally. 135 * 136 * @const IPC_SPACE_POLICY_TRANSLATED 137 * Denotes IPC spaces for translated environments (macOS only). 138 * Similarly to @c IPC_SPACE_POLICY_SIMULATED, processes running in a Rosetta 139 * environment are likely older software that predate policy changes, 140 * and these processes tend to be opted out of certain policies as a result. 141 */ 142 143 __options_closed_decl(ipc_space_policy_t, uint32_t, { 144 IPC_SPACE_POLICY_INVALID = 0x0000, 145 146 /* Security level */ 147 IPC_SPACE_POLICY_DEFAULT = 0x0001, /* MACH64_POLICY_DEFAULT */ 148 IPC_SPACE_POLICY_ENHANCED = 0x0002, 149 IPC_SPACE_POLICY_PLATFORM = 0x0004, 150 IPC_SPACE_POLICY_KERNEL = 0x0010, 151 152 /* flags to turn off security */ 153 #if XNU_TARGET_OS_OSX 154 IPC_SPACE_POLICY_SIMULATED = 0x0020, 155 #else 156 IPC_SPACE_POLICY_SIMULATED = 0x0000, 157 #endif 158 #if CONFIG_ROSETTA 159 IPC_SPACE_POLICY_TRANSLATED = 0x0040, 160 #else 161 IPC_SPACE_POLICY_TRANSLATED = 0x0000, 162 #endif 163 #if XNU_TARGET_OS_OSX 164 IPC_SPACE_POLICY_OPTED_OUT = 0x0080, 165 #else 166 IPC_SPACE_POLICY_OPTED_OUT = 0x0000, 167 #endif 168 169 170 IPC_SPACE_POLICY_MASK = ( 171 IPC_SPACE_POLICY_DEFAULT | 172 IPC_SPACE_POLICY_ENHANCED | 173 IPC_SPACE_POLICY_PLATFORM | 174 IPC_SPACE_POLICY_KERNEL | 175 IPC_SPACE_POLICY_SIMULATED | 176 IPC_SPACE_POLICY_TRANSLATED | 177 IPC_SPACE_POLICY_OPTED_OUT), 178 179 180 /* platform restrictions Versioning Levels */ 181 IPC_SPACE_POLICY_ENHANCED_V0 = 0x100, /* DEPRECATED - includes macos hardened runtime */ 182 IPC_SPACE_POLICY_ENHANCED_V1 = 0x200, /* ES features exposed to 3P in FY2024 release */ 183 IPC_SPACE_POLICY_ENHANCED_V2 = 0x400, /* ES features exposed to 3P in FY2025 release */ 184 IPC_SPACE_POLICY_ENHANCED_VERSION_MASK = ( 185 IPC_SPACE_POLICY_ENHANCED_V0 | 186 IPC_SPACE_POLICY_ENHANCED_V1 | 187 IPC_SPACE_POLICY_ENHANCED_V2 188 ), 189 }); 190 191 #define IPC_SPACE_POLICY_BASE(prefix) \ 192 prefix ## _DEFAULT = IPC_SPACE_POLICY_DEFAULT, \ 193 prefix ## _ENHANCED = IPC_SPACE_POLICY_ENHANCED, \ 194 prefix ## _PLATFORM = IPC_SPACE_POLICY_PLATFORM, \ 195 prefix ## _KERNEL = IPC_SPACE_POLICY_KERNEL, \ 196 prefix ## _SIMULATED = IPC_SPACE_POLICY_SIMULATED, \ 197 prefix ## _TRANSLATED = IPC_SPACE_POLICY_TRANSLATED, \ 198 prefix ## _MASK = IPC_SPACE_POLICY_MASK 199 200 #else /* MACH_KERNEL_PRIVATE */ 201 202 struct ipc_object; 203 204 #endif /* MACH_KERNEL_PRIVATE */ 205 #if XNU_KERNEL_PRIVATE 206 207 /*! 208 * @brief 209 * Type for IPC objects 210 * 211 * @discussion 212 * This type is non ABI stable, and limited to XNU internally. 213 * Please keep this type ordered semantically for readability purposes. 214 * 215 * When adding types here, update @c mach_port_kobject_type() which maps 216 * these values to the previously stable legacy IKOT_* values for the sake 217 * of userspace (and tools like lsmp(1)). 218 */ 219 __enum_decl(ipc_object_type_t, uint8_t, { 220 /* 221 * Object is a port set (see <ipc/ipc_pset.h>). 222 */ 223 IOT_PORT_SET, 224 225 /* 226 * Catchall type for generic ports. 227 */ 228 IOT_PORT, 229 230 /* 231 * Service/Connection ports 232 */ 233 IOT_SERVICE_PORT, 234 IOT_BOOTSTRAP_PORT, 235 IOT_WEAK_SERVICE_PORT, 236 IOT_CONNECTION_PORT, 237 IOT_CONNECTION_PORT_WITH_PORT_ARRAY, 238 239 /* 240 * Notification ports 241 */ 242 IOT_EXCEPTION_PORT, 243 IOT_TIMER_PORT, 244 245 /* 246 * Reply Ports 247 */ 248 IOT_REPLY_PORT, 249 IOT_SPECIAL_REPLY_PORT, 250 IOT_PROVISIONAL_REPLY_PORT, 251 252 /* 253 * IPC Kernel Object types 254 * 255 * Matching entries must be added to <mach_debug/ipc_info.h>, 256 * and case labels to mach_port_kobject_type(). 257 */ 258 __IKOT_FIRST, 259 260 /* thread ports */ 261 IKOT_THREAD_CONTROL = __IKOT_FIRST, 262 IKOT_THREAD_READ, 263 IKOT_THREAD_INSPECT, 264 265 /* task ports */ 266 IKOT_TASK_CONTROL, 267 IKOT_TASK_READ, 268 IKOT_TASK_INSPECT, 269 IKOT_TASK_NAME, 270 271 IKOT_TASK_RESUME, 272 IKOT_TASK_ID_TOKEN, 273 IKOT_TASK_FATAL, /* CONFIG_PROC_RESOURCE_LIMITS only */ 274 275 /* host services */ 276 IKOT_HOST, 277 IKOT_HOST_PRIV, 278 IKOT_CLOCK, 279 IKOT_PROCESSOR, 280 IKOT_PROCESSOR_SET, 281 IKOT_PROCESSOR_SET_NAME, 282 283 /* common userspace used ports */ 284 IKOT_EVENTLINK, 285 IKOT_FILEPORT, 286 IKOT_SEMAPHORE, 287 IKOT_VOUCHER, 288 IKOT_WORK_INTERVAL, 289 290 /* VM ports */ 291 IKOT_MEMORY_OBJECT, 292 IKOT_NAMED_ENTRY, 293 294 /* IOKit & exclaves ports */ 295 IKOT_MAIN_DEVICE, 296 IKOT_IOKIT_IDENT, 297 IKOT_IOKIT_CONNECT, 298 IKOT_IOKIT_OBJECT, 299 IKOT_UEXT_OBJECT, 300 IKOT_EXCLAVES_RESOURCE, /* CONFIG_EXCLAVES only */ 301 302 /* misc. */ 303 IKOT_ARCADE_REG, /* CONFIG_ARCADE only */ 304 IKOT_AU_SESSIONPORT, /* CONFIG_AUDIT only */ 305 IKOT_HYPERVISOR, /* HYPERVISOR only */ 306 IKOT_KCDATA, 307 IKOT_UND_REPLY, /* CONFIG_USER_NOTIFICATION only */ 308 IKOT_UX_HANDLER, 309 310 /* catchall, keep last */ 311 IOT_UNKNOWN, 312 IOT_ANY = 0xff, 313 }); 314 315 #endif /* XNU_KERNEL_PRIVATE */ 316 317 typedef struct ipc_object *ipc_object_t; 318 319 #define IPC_OBJECT_NULL ((ipc_object_t) 0) 320 #define IPC_OBJECT_DEAD ((ipc_object_t)~0) 321 #define IPC_OBJECT_VALID(io) (((io) != IPC_OBJECT_NULL) && \ 322 ((io) != IPC_OBJECT_DEAD)) 323 324 #endif /* _IPC_IPC_TYPES_H_ */ 325