xref: /xnu-12377.61.12/bsd/sys/spawn_internal.h (revision 4d495c6e23c53686cf65f45067f79024cf5dcee8)
1 /*
2  * Copyright (c) 2006 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 
30 /*
31  * [SPN] Support for _POSIX_SPAWN
32  *
33  * This file contains internal data structures which are externally represented
34  * as opaque void pointers to prevent introspection.  This permits us to
35  * change the underlying implementation of the code to maintain it or to
36  * support new features, as needed, without the consumer needing to recompile
37  * their code because of structure size changes or data reorganization.
38  */
39 
40 #ifndef _SYS_SPAWN_INTERNAL_H_
41 #define _SYS_SPAWN_INTERNAL_H_
42 
43 #include <sys/_types.h>         /* __offsetof(), __darwin_size_t */
44 #include <sys/param.h>
45 #include <sys/syslimits.h>      /* PATH_MAX */
46 #include <sys/spawn.h>
47 #include <mach/machine.h>
48 #include <mach/port.h>
49 #include <mach/exception_types.h>
50 #include <mach/coalition.h>     /* COALITION_NUM_TYPES */
51 #include <mach/task_policy.h>
52 #include <os/overflow.h>
53 #include <mach/mach_param.h>
54 
55 /*
56  * Safely compute the size in bytes of a structure, '_type', whose last
57  * element, '_member', is a zero-sized array meant to hold 'x' bytes.
58  *
59  * If the size calculation overflows a size_t value, this macro returns 0.
60  */
61 #define PS_ACTION_SIZE(x, _type, _member_type) ({\
62 	size_t _ps_count = (size_t)x; \
63 	size_t _ps_size = 0; \
64 	/* (count * sizeof(_member_type)) + sizeof(_type) */ \
65 	if (os_mul_and_add_overflow(_ps_count, \
66 	                            sizeof(_member_type), \
67 	                            sizeof(_type), \
68 	                            &_ps_size)) { \
69 	        _ps_size = 0; \
70 	} \
71 	_ps_size; })
72 
73 /*
74  * Allowable posix_spawn() port action types
75  */
76 typedef enum {
77 	PSPA_SPECIAL = 0,
78 	PSPA_EXCEPTION = 1,
79 	PSPA_AU_SESSION = 2,
80 	PSPA_IMP_WATCHPORTS = 3,
81 	PSPA_REGISTERED_PORTS = 4,
82 	PSPA_PTRAUTH_TASK_PORT = 5,
83 } pspa_t;
84 
85 /*
86  * Internal representation of one port to be set on posix_spawn().
87  * Currently this is limited to setting special and exception ports,
88  * but could be extended to other inheritable port types.
89  */
90 typedef struct _ps_port_action {
91 	pspa_t                  port_type;
92 	exception_mask_t        mask;
93 	mach_port_name_t        new_port;
94 	exception_behavior_t    behavior;
95 	thread_state_flavor_t   flavor;
96 	int                     which;
97 } _ps_port_action_t;
98 
99 /*
100  * A collection of port actions to take on the newly spawned process.
101  */
102 typedef struct _posix_spawn_port_actions {
103 	int                     pspa_alloc;
104 	int                     pspa_count;
105 	_ps_port_action_t       pspa_actions[];
106 } *_posix_spawn_port_actions_t;
107 
108 /*
109  * Returns size in bytes of a _posix_spawn_port_actions holding x elements.
110  */
111 #define PS_PORT_ACTIONS_SIZE(x) \
112 	PS_ACTION_SIZE(x, struct _posix_spawn_port_actions, _ps_port_action_t)
113 
114 #define NBINPREFS       4
115 
116 /*
117  * Mapping of opaque data pointer to a MAC policy (specified by name).
118  */
119 typedef struct _ps_mac_policy_extension {
120 	char                    policyname[128];
121 	union {
122 		/* Address of the user space data passed into kernel space */
123 		uint64_t        data;
124 		/* In kernel space, offset into the pool of all extensions' data */
125 		uint64_t        dataoff;
126 	};
127 	uint64_t                datalen;
128 } _ps_mac_policy_extension_t;
129 
130 /*
131  * A collection of extra data passed to MAC policies for the newly spawned process.
132  */
133 typedef struct _posix_spawn_mac_policy_extensions {
134 	int                     psmx_alloc;
135 	int                     psmx_count;
136 	_ps_mac_policy_extension_t psmx_extensions[];
137 } *_posix_spawn_mac_policy_extensions_t;
138 
139 /*
140  * Returns size in bytes of a _posix_spawn_mac_policy_extensions holding x elements.
141  */
142 #define PS_MAC_EXTENSIONS_SIZE(x)     \
143 	PS_ACTION_SIZE(x, struct _posix_spawn_mac_policy_extensions, _ps_mac_policy_extension_t)
144 
145 #define PS_MAC_EXTENSIONS_INIT_COUNT    2
146 
147 /*
148  * Coalition posix spawn attributes
149  */
150 struct _posix_spawn_coalition_info {
151 	struct {
152 		uint64_t psci_id;
153 		uint32_t psci_role;
154 		uint32_t psci_reserved1;
155 		uint64_t psci_reserved2;
156 	} psci_info[COALITION_NUM_TYPES];
157 };
158 
159 /*
160  * UID/GID attributes
161  */
162 struct _posix_spawn_posix_cred_info {
163 	uint32_t pspci_flags;    /* spawn persona flags */
164 	uid_t    pspci_uid;      /* alternate posix/unix UID  */
165 	gid_t    pspci_gid;      /* alternate posix/unix GID */
166 	uint32_t pspci_ngroups;  /* alternate advisory groups */
167 	gid_t    pspci_groups[NGROUPS];
168 	uid_t    pspci_gmuid;    /* group membership UID */
169 	char     pspci_login[MAXLOGNAME + 1];
170 };
171 
172 #define POSIX_SPAWN_POSIX_CRED_UID          0x00010000
173 #define POSIX_SPAWN_POSIX_CRED_GID          0x00020000
174 #define POSIX_SPAWN_POSIX_CRED_GROUPS       0x00040000
175 #define POSIX_SPAWN_POSIX_CRED_LOGIN        0x00080000
176 
177 /*
178  * Persona attributes
179  */
180 struct _posix_spawn_persona_info {
181 	uid_t    pspi_id;       /* persona ID (unix UID) */
182 	uint32_t pspi_flags;    /* spawn persona flags */
183 	uid_t    pspi_uid;      /* alternate posix/unix UID  */
184 	gid_t    pspi_gid;      /* alternate posix/unix GID */
185 	uint32_t pspi_ngroups;  /* alternate advisory groups */
186 	gid_t    pspi_groups[NGROUPS];
187 	uid_t    pspi_gmuid;    /* group membership UID */
188 };
189 
190 #define POSIX_SPAWN_PERSONA_FLAGS_NONE      0x0
191 #define POSIX_SPAWN_PERSONA_FLAGS_OVERRIDE  0x1 /* noop, the only option */
192 #define POSIX_SPAWN_PERSONA_FLAGS_VERIFY    0x2 /* noop, unimplemented */
193 
194 #define POSIX_SPAWN_PERSONA_ALL_FLAGS \
195 	(POSIX_SPAWN_PERSONA_FLAGS_OVERRIDE \
196 	 | POSIX_SPAWN_PERSONA_FLAGS_VERIFY \
197 	)
198 
199 #define POSIX_SPAWN_PERSONA_UID             POSIX_SPAWN_POSIX_CRED_UID
200 #define POSIX_SPAWN_PERSONA_GID             POSIX_SPAWN_POSIX_CRED_GID
201 #define POSIX_SPAWN_PERSONA_GROUPS          POSIX_SPAWN_POSIX_CRED_GROUPS
202 
203 
204 /*
205  * A posix_spawnattr structure contains all of the attribute elements that
206  * can be set, as well as any metadata whose validity is signalled by the
207  * presence of a bit in the flags field.  All fields are initialized to the
208  * appropriate default values by posix_spawnattr_init().
209  *
210  * Fields must be added at the end of this, but before extensions array
211  * pointers.
212  */
213 
214 typedef struct _posix_spawnattr {
215 	short           psa_flags;              /* spawn attribute flags */
216 	short           flags_padding;  /* get the flags to be int aligned */
217 	sigset_t        psa_sigdefault;         /* signal set to default */
218 	sigset_t        psa_sigmask;            /* signal set to mask */
219 	pid_t           psa_pgroup;             /* pgroup to spawn into */
220 	cpu_type_t      psa_binprefs[NBINPREFS];   /* cpu affinity prefs*/
221 	int             psa_pcontrol;           /* process control bits on resource starvation */
222 	int             psa_apptype;            /* app type and process spec behav */
223 	uint64_t        psa_cpumonitor_percent; /* CPU usage monitor percentage */
224 	uint64_t        psa_cpumonitor_interval; /* CPU usage monitor interval, in seconds */
225 	uint64_t        psa_reserved;
226 
227 	short       psa_jetsam_flags;           /* jetsam flags */
228 	short           short_padding;          /* Padding for alignment issues */
229 	int         psa_priority;               /* jetsam relative importance */
230 	int         psa_memlimit_active;        /* jetsam memory limit (in MB) when process is active */
231 	int         psa_memlimit_inactive;      /* jetsam memory limit (in MB) when process is inactive */
232 
233 	uint64_t        psa_qos_clamp;          /* QoS Clamp to set on the new process */
234 	task_role_t     psa_darwin_role;           /* PRIO_DARWIN_ROLE to set on the new process */
235 	int             psa_thread_limit;       /* thread limit */
236 
237 	uint64_t        psa_max_addr;           /* Max valid VM address */
238 	bool            psa_no_smt;
239 	bool            psa_tecs;
240 	int             psa_platform;           /* Plaform for the binary */
241 
242 	cpu_subtype_t      psa_subcpuprefs[NBINPREFS];   /* subcpu affinity prefs*/
243 	uint32_t        psa_options;             /* More options to be passed to posix_spawn */
244 	uint32_t        psa_port_soft_limit;     /* port space soft limit */
245 	uint32_t        psa_port_hard_limit;     /* port space hard limit */
246 	uint32_t        psa_filedesc_soft_limit; /* file descriptor soft limit */
247 	uint32_t        psa_filedesc_hard_limit; /* file descriptor hard limit */
248 	uint32_t        psa_crash_behavior;      /* crash behavior flags */
249 	int             psa_dataless_iopolicy;   /* materialize dataless iopolicy parameter */
250 	uint64_t        psa_crash_behavior_deadline; /* crash behavior deadline */
251 	uint8_t         psa_launch_type;         /* type of launch for launch constraint enforcement */
252 	uint16_t        psa_sec_flags;           /* flags for task_sec */
253 
254 	/* For exponential backoff */
255 	uint32_t        psa_crash_count;
256 	uint32_t        psa_throttle_timeout;
257 
258 	uint32_t        psa_kqworkloop_soft_limit; /* kqworkloop soft limit */
259 	uint32_t        psa_kqworkloop_hard_limit; /* kqworkloop hard limit */
260 
261 	uint32_t        psa_conclave_mem_limit; /* conclave hard memory limit (in MB) */
262 
263 	/*
264 	 * NOTE: Extensions array pointers must stay at the end so that
265 	 * everything above this point stays the same size on different bitnesses
266 	 * see <rdar://problem/12858307>
267 	 */
268 	_posix_spawn_port_actions_t    psa_ports;  /* special/exception ports */
269 	_posix_spawn_mac_policy_extensions_t psa_mac_extensions; /* MAC policy-specific extensions. */
270 	struct _posix_spawn_coalition_info *psa_coalition_info;  /* coalition info */
271 	struct _posix_spawn_persona_info   *psa_persona_info;    /* spawn new process into given persona */
272 	struct _posix_spawn_posix_cred_info *psa_posix_cred_info; /* posix creds: uid/gid/groups */
273 	char                                *psa_subsystem_root_path; /* pass given path in apple strings */
274 	char                                *psa_conclave_id;         /* conclave string */
275 } *_posix_spawnattr_t;
276 
277 /*
278  * Task Sec flags, psa_sec_flags
279  */
280 __options_decl(posix_spawn_secflag_options, uint16_t, {
281 	POSIX_SPAWN_SECFLAG_EXPLICIT_ENABLE                 = 0x01,
282 	POSIX_SPAWN_SECFLAG_EXPLICIT_DISABLE                = 0x02,
283 	POSIX_SPAWN_SECFLAG_EXPLICIT_NEVER_CHECK_ENABLE     = 0x04,
284 	POSIX_SPAWN_SECFLAG_EXPLICIT_NEVER_CHECK_DISABLE    = 0x08,
285 	POSIX_SPAWN_SECFLAG_EXPLICIT_VM_POLICY_BYPASS       = 0x10,
286 	POSIX_SPAWN_SECFLAG_EXPLICIT_VM_POLICY_ENFORCE      = 0x20,
287 	POSIX_SPAWN_SECFLAG_EXPLICIT_CHECK_BYPASS           = 0x40,
288 	POSIX_SPAWN_SECFLAG_EXPLICIT_CHECK_ENFORCE          = 0x80,
289 	POSIX_SPAWN_SECFLAG_EXPLICIT_DISABLE_INHERIT        = 0x100,
290 	POSIX_SPAWN_SECFLAG_EXPLICIT_ENABLE_INHERIT         = 0x200,
291 	POSIX_SPAWN_SECFLAG_EXPLICIT_REQUIRE_ENABLE         = 0x400,
292 	POSIX_SPAWN_SECFLAG_EXPLICIT_ENABLE_PURE_DATA       = 0x800,
293 	POSIX_SPAWN_SECFLAG_EXPLICIT_PREFLIGHT              = 0x1000,
294 });
295 
296 /*
297  * Jetsam flags  eg: psa_jetsam_flags
298  */
299 #define POSIX_SPAWN_JETSAM_SET                      0x8000
300 
301 #define POSIX_SPAWN_JETSAM_USE_EFFECTIVE_PRIORITY       0x01
302 #define POSIX_SPAWN_JETSAM_HIWATER_BACKGROUND           0x02  /* to be deprecated */
303 #define POSIX_SPAWN_JETSAM_MEMLIMIT_FATAL               0x04  /* to be deprecated */
304 
305 /*
306  * Additional flags available for use with
307  * the posix_spawnattr_setjetsam_ext() call
308  */
309 #define POSIX_SPAWN_JETSAM_MEMLIMIT_ACTIVE_FATAL        0x04  /* if set, limit is fatal when the process is active   */
310 #define POSIX_SPAWN_JETSAM_MEMLIMIT_INACTIVE_FATAL      0x08  /* if set, limit is fatal when the process is inactive */
311 #define POSIX_SPAWN_JETSAM_REALTIME_AUDIO               0x10  /* if set, avoid expensive memory telemetry while audio is playing */
312 
313 /*
314  * Flags set based on posix_spawnattr_set_jetsam_ttr_np().
315  * Indicate relaunch behavior of process when jetsammed
316  */
317 /* Mask and bucket counts for relaunch behavior */
318 #define POSIX_SPAWN_JETSAM_RELAUNCH_BEHAVIOR_BUCKETS    (0x3)
319 #define POSIX_SPAWN_JETSAM_RELAUNCH_BEHAVIOR_MASK       (0x30)
320 
321 /* Actual buckets based on behavior data */
322 #define POSIX_SPAWN_JETSAM_RELAUNCH_BEHAVIOR_HIGH       (0x30)
323 #define POSIX_SPAWN_JETSAM_RELAUNCH_BEHAVIOR_MED        (0x20)
324 #define POSIX_SPAWN_JETSAM_RELAUNCH_BEHAVIOR_LOW        (0x10)
325 
326 /*
327  * Deprecated posix_spawn psa_flags values
328  *
329  * POSIX_SPAWN_OSX_TALAPP_START         0x0400
330  * POSIX_SPAWN_IOS_RESV1_APP_START      0x0400
331  * POSIX_SPAWN_IOS_APPLE_DAEMON_START   0x0800
332  * POSIX_SPAWN_IOS_APP_START            0x1000
333  * POSIX_SPAWN_OSX_WIDGET_START         0x0800
334  * POSIX_SPAWN_OSX_DBCLIENT_START       0x0800
335  * POSIX_SPAWN_OSX_RESVAPP_START        0x1000
336  */
337 
338 /*
339  * Deprecated posix_spawn psa_apptype values
340  *
341  * POSIX_SPAWN_PROCESS_TYPE_APPLEDAEMON             0x00000001
342  * POSIX_SPAWN_PROCESS_TYPE_UIAPP                   0x00000002
343  * POSIX_SPAWN_PROCESS_TYPE_ADAPTIVE                0x00000004
344  * POSIX_SPAWN_PROCESS_TYPE_TAL                     0x00000001
345  * POSIX_SPAWN_PROCESS_TYPE_WIDGET                  0x00000002
346  * POSIX_SPAWN_PROCESS_TYPE_DELAYIDLESLEEP          0x10000000
347  *
348  * POSIX_SPAWN_PROCESS_FLAG_IMPORTANCE_DONOR        0x00000010
349  * POSIX_SPAWN_PROCESS_FLAG_ADAPTIVE                0x00000020
350  * POSIX_SPAWN_PROCESS_FLAG_START_BACKGROUND        0x00000040
351  * POSIX_SPAWN_PROCESS_FLAG_START_LIGHT_THROTTLE    0x00000080
352  */
353 
354 /*
355  * posix_spawn psa_apptype process type settings.
356  * when POSIX_SPAWN_PROC_TYPE is set, old psa_apptype bits are ignored
357  */
358 #define POSIX_SPAWN_PROCESS_TYPE_NORMAL             0x00000000
359 #define POSIX_SPAWN_PROCESS_TYPE_DEFAULT            POSIX_SPAWN_PROCESS_TYPE_NORMAL
360 
361 #define POSIX_SPAWN_PROC_TYPE_MASK                  0x00000F00
362 
363 #define POSIX_SPAWN_PROC_TYPE_APP_DEFAULT           0x00000100
364 #define POSIX_SPAWN_PROC_TYPE_APP_NONUI             0x00000200
365 #define POSIX_SPAWN_PROC_TYPE_APP_TAL               POSIX_SPAWN_PROC_TYPE_APP_NONUI /* old name */
366 
367 #define POSIX_SPAWN_PROC_TYPE_DAEMON_STANDARD       0x00000300
368 #define POSIX_SPAWN_PROC_TYPE_DAEMON_INTERACTIVE    0x00000400
369 #define POSIX_SPAWN_PROC_TYPE_DAEMON_BACKGROUND     0x00000500
370 #define POSIX_SPAWN_PROC_TYPE_DAEMON_ADAPTIVE       0x00000600
371 
372 #define POSIX_SPAWN_PROC_TYPE_DRIVER                0x00000700
373 
374 #define POSIX_SPAWN_PROC_CLAMP_NONE                 0x00000000
375 #define POSIX_SPAWN_PROC_CLAMP_UTILITY              0x00000001
376 #define POSIX_SPAWN_PROC_CLAMP_BACKGROUND           0x00000002
377 #define POSIX_SPAWN_PROC_CLAMP_MAINTENANCE          0x00000003
378 #define POSIX_SPAWN_PROC_CLAMP_LAST                 0x00000004
379 
380 #define POSIX_SPAWN_ENTITLEMENT_DRIVER "com.apple.private.spawn-driver"
381 /* Setting to indicate no change to darwin role */
382 #define POSIX_SPAWN_DARWIN_ROLE_NONE                0x00000000
383 /* Other possible values are specified by PRIO_DARWIN_ROLE in sys/resource.h */
384 
385 /* Other posix spawn options passed through psa_options */
386 __options_decl(posix_spawn_options, uint32_t, {
387 	PSA_OPTION_NONE                         = 0,
388 	PSA_OPTION_PLUGIN_HOST_DISABLE_A_KEYS   = 0x1,
389 	PSA_OPTION_ALT_ROSETTA                  = 0x2,
390 	PSA_OPTION_DATALESS_IOPOLICY            = 0x4,
391 });
392 
393 /*
394  * Allowable posix_spawn() file actions
395  */
396 typedef enum {
397 	PSFA_OPEN = 0,
398 	PSFA_CLOSE = 1,
399 	PSFA_DUP2 = 2,
400 	PSFA_INHERIT = 3,
401 	PSFA_FILEPORT_DUP2 = 4,
402 	PSFA_CHDIR = 5,
403 	PSFA_FCHDIR = 6
404 } psfa_t;
405 
406 
407 /*
408  * A posix_spawn() file action record for a single action
409  *
410  * Notes:	We carry around the full open arguments for both the open
411  *		and the close to permit the use of a single array of action
412  *		elements to be associated with a file actions object.
413  *
414  *		A possible future optimization would be to break this into
415  *		a variable sized vector list to save space (i.e. a separate
416  *		string area, allocation of least amount of path buffer per
417  *		open action, etc.).
418  */
419 typedef struct _psfa_action {
420 	psfa_t  psfaa_type;                         /* file action type */
421 	union {
422 		int psfaa_filedes;                  /* fd to operate on */
423 		mach_port_name_t psfaa_fileport;    /* fileport to operate on */
424 	};
425 	union {
426 		struct {
427 			int     psfao_oflag;            /* open flags to use */
428 			mode_t  psfao_mode;             /* mode for open */
429 			char    psfao_path[PATH_MAX];   /* path to open */
430 		} psfaa_openargs;
431 		struct {
432 			int psfad_newfiledes;           /* new file descriptor to use */
433 		} psfaa_dup2args;
434 		struct {
435 			char    psfac_path[PATH_MAX];   /* path to chdir */
436 		} psfaa_chdirargs;
437 	};
438 } _psfa_action_t;
439 
440 
441 /*
442  * Internal representation of posix_spawn() file actions structure
443  *
444  * Notes:	This is implemented as a structure followed by an array of
445  *		file action records.  The psfa_act_alloc value is the number
446  *		of elements allocated in this array, and the psfa_act_count is
447  *		the number of elements currently in use (to permit some form
448  *		of preallocation, e.g. a power of 2 growth for reallocation,
449  *		etc.).
450  *
451  *		A possible future optimization would keep a size value and
452  *		a structure base reference pointer to permit copyin to the
453  *		kernel directly as a single blob, without damaging relative
454  *		internal pointer math.  It's probably better that this be a
455  *		long long rather than a true pointer, to make it invariant
456  *		for 32 vs. 64 bt programming SPIs.
457  */
458 typedef struct _posix_spawn_file_actions {
459 	int             psfa_act_alloc;         /* available actions space */
460 	int             psfa_act_count;         /* count of defined actions */
461 	_psfa_action_t  psfa_act_acts[];        /* actions array (uses c99) */
462 } *_posix_spawn_file_actions_t;
463 
464 /*
465  * Calculate the size of a structure, given the number of elements that it is
466  * capable of containing.
467  */
468 #define PSF_ACTIONS_SIZE(x)     \
469 	PS_ACTION_SIZE(x, struct _posix_spawn_file_actions, _psfa_action_t)
470 
471 /*
472  * Initial count of actions in a struct _posix_spawn_file_actions after it is
473  * first allocated; this should be non-zero, since we expect that one would not
474  * have been allocated unless there was an intent to use it.
475  */
476 #define PSF_ACTIONS_INIT_COUNT  2
477 
478 /*
479  * Structure defining the true third argument to the posix_spawn() system call
480  * entry point; we wrap it and pass a descriptor so that we can know the
481  * copyin size ahead of time, and deal with copying in variant lists of things
482  * as single monolithic units, instead of many individual elements.  This is a
483  * performance optimization.
484  */
485 struct _posix_spawn_args_desc {
486 	__darwin_size_t         attr_size;      /* size of attributes block */
487 	_posix_spawnattr_t      attrp;          /* pointer to block */
488 	__darwin_size_t file_actions_size;      /* size of file actions block */
489 	_posix_spawn_file_actions_t
490 	    file_actions;                       /* pointer to block */
491 	__darwin_size_t port_actions_size;      /* size of port actions block */
492 	_posix_spawn_port_actions_t
493 	    port_actions;                       /* pointer to port block */
494 	__darwin_size_t mac_extensions_size;
495 	_posix_spawn_mac_policy_extensions_t
496 	    mac_extensions;                     /* pointer to policy-specific
497 	                                         * attributes */
498 	__darwin_size_t coal_info_size;
499 	struct _posix_spawn_coalition_info *coal_info;  /* pointer to coalition info */
500 
501 	__darwin_size_t persona_info_size;
502 	struct _posix_spawn_persona_info   *persona_info;
503 
504 	__darwin_size_t posix_cred_info_size;
505 	struct _posix_spawn_posix_cred_info *posix_cred_info;
506 
507 	__darwin_size_t subsystem_root_path_size;
508 	char *subsystem_root_path;
509 
510 	__darwin_size_t conclave_id_size;
511 	char *conclave_id;
512 };
513 
514 #ifdef KERNEL
515 #include <sys/appleapiopts.h>
516 #ifdef __APPLE_API_PRIVATE
517 
518 #if __DARWIN_ALIGN_NATURAL
519 #pragma options align=natural
520 #endif
521 
522 struct user32__posix_spawn_args_desc {
523 	uint32_t        attr_size;              /* size of attributes block */
524 	uint32_t        attrp;                  /* pointer to block */
525 	uint32_t        file_actions_size;      /* size of file actions block */
526 	uint32_t        file_actions;           /* pointer to block */
527 	uint32_t        port_actions_size;      /* size of port actions block */
528 	uint32_t        port_actions;           /* pointer to block */
529 	uint32_t        mac_extensions_size;
530 	uint32_t        mac_extensions;
531 	uint32_t        coal_info_size;
532 	uint32_t        coal_info;
533 	uint32_t        persona_info_size;
534 	uint32_t        persona_info;
535 	uint32_t        posix_cred_info_size;
536 	uint32_t        posix_cred_info;
537 	uint32_t        subsystem_root_path_size;
538 	uint32_t        subsystem_root_path;
539 	uint32_t        conclave_id_size;
540 	uint32_t        conclave_id;
541 };
542 
543 struct user__posix_spawn_args_desc {
544 	user_size_t     attr_size;              /* size of attributes block */
545 	user_addr_t     attrp;                  /* pointer to block */
546 	user_size_t     file_actions_size;      /* size of file actions block */
547 	user_addr_t     file_actions;           /* pointer to block */
548 	user_size_t     port_actions_size;      /* size of port actions block */
549 	user_addr_t     port_actions;           /* pointer to block */
550 	user_size_t     mac_extensions_size;    /* size of MAC-specific attrs. */
551 	user_addr_t     mac_extensions;         /* pointer to block */
552 	user_size_t     coal_info_size;
553 	user_addr_t     coal_info;
554 	user_size_t     persona_info_size;
555 	user_addr_t     persona_info;
556 	user_size_t     posix_cred_info_size;
557 	user_addr_t     posix_cred_info;
558 	user_size_t     subsystem_root_path_size;
559 	user_addr_t     subsystem_root_path;
560 	user_size_t     conclave_id_size;
561 	user_addr_t     conclave_id;
562 };
563 
564 
565 #if __DARWIN_ALIGN_NATURAL
566 #pragma options align=reset
567 #endif
568 
569 #endif  /* __APPLE_API_PRIVATE */
570 #endif  /* KERNEL */
571 
572 #endif  /* _SYS_SPAWN_INTERNAL_H_ */
573