xref: /xnu-12377.1.9/bsd/sys/reason.h (revision f6217f891ac0bb64f3d375211650a4c1ff8ca1ea)
1*f6217f89SApple OSS Distributions /*
2*f6217f89SApple OSS Distributions  * Copyright (c) 2019 Apple Inc. All rights reserved.
3*f6217f89SApple OSS Distributions  *
4*f6217f89SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*f6217f89SApple OSS Distributions  *
6*f6217f89SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*f6217f89SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*f6217f89SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*f6217f89SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*f6217f89SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*f6217f89SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*f6217f89SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*f6217f89SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*f6217f89SApple OSS Distributions  *
15*f6217f89SApple OSS Distributions  * Please obtain a copy of the License at
16*f6217f89SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*f6217f89SApple OSS Distributions  *
18*f6217f89SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*f6217f89SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*f6217f89SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*f6217f89SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*f6217f89SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*f6217f89SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*f6217f89SApple OSS Distributions  * limitations under the License.
25*f6217f89SApple OSS Distributions  *
26*f6217f89SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*f6217f89SApple OSS Distributions  */
28*f6217f89SApple OSS Distributions 
29*f6217f89SApple OSS Distributions #ifndef _REASON_H_
30*f6217f89SApple OSS Distributions #define _REASON_H_
31*f6217f89SApple OSS Distributions 
32*f6217f89SApple OSS Distributions #include <stdint.h>
33*f6217f89SApple OSS Distributions 
34*f6217f89SApple OSS Distributions __BEGIN_DECLS
35*f6217f89SApple OSS Distributions 
36*f6217f89SApple OSS Distributions #ifdef KERNEL_PRIVATE
37*f6217f89SApple OSS Distributions 
38*f6217f89SApple OSS Distributions #include <kern/kern_cdata.h>
39*f6217f89SApple OSS Distributions 
40*f6217f89SApple OSS Distributions #ifdef XNU_KERNEL_PRIVATE
41*f6217f89SApple OSS Distributions #include <os/refcnt.h>
42*f6217f89SApple OSS Distributions #include <kern/locks.h>
43*f6217f89SApple OSS Distributions 
44*f6217f89SApple OSS Distributions typedef struct os_reason {
45*f6217f89SApple OSS Distributions 	decl_lck_mtx_data(, osr_lock);
46*f6217f89SApple OSS Distributions 	os_refcnt_t                     osr_refcount;
47*f6217f89SApple OSS Distributions 	uint32_t                        osr_namespace;
48*f6217f89SApple OSS Distributions 	uint64_t                        osr_code;
49*f6217f89SApple OSS Distributions 	uint64_t                        osr_flags;
50*f6217f89SApple OSS Distributions 	uint32_t                        osr_bufsize;
51*f6217f89SApple OSS Distributions 	struct kcdata_descriptor        osr_kcd_descriptor;
52*f6217f89SApple OSS Distributions 	char                            *osr_kcd_buf;
53*f6217f89SApple OSS Distributions } *os_reason_t;
54*f6217f89SApple OSS Distributions 
55*f6217f89SApple OSS Distributions #define OS_REASON_NULL ((os_reason_t) NULL)
56*f6217f89SApple OSS Distributions 
57*f6217f89SApple OSS Distributions /* We only include 800 bytes of the exit reason description to not blow through the panic buffer */
58*f6217f89SApple OSS Distributions #define LAUNCHD_PANIC_REASON_STRING_MAXLEN "800"
59*f6217f89SApple OSS Distributions 
60*f6217f89SApple OSS Distributions void os_reason_init(void);
61*f6217f89SApple OSS Distributions 
62*f6217f89SApple OSS Distributions os_reason_t build_userspace_exit_reason(uint32_t reason_namespace, uint64_t reason_code, user_addr_t payload, uint32_t payload_size,
63*f6217f89SApple OSS Distributions     user_addr_t reason_string, uint64_t reason_flags);
64*f6217f89SApple OSS Distributions char *exit_reason_get_string_desc(os_reason_t exit_reason);
65*f6217f89SApple OSS Distributions 
66*f6217f89SApple OSS Distributions /* The blocking allocation is currently not exported to KEXTs */
67*f6217f89SApple OSS Distributions int os_reason_alloc_buffer(os_reason_t cur_reason, uint32_t osr_bufsize);
68*f6217f89SApple OSS Distributions 
69*f6217f89SApple OSS Distributions typedef struct _exception_info {
70*f6217f89SApple OSS Distributions 	int os_reason;
71*f6217f89SApple OSS Distributions 	int signal;
72*f6217f89SApple OSS Distributions 	exception_type_t exception_type;
73*f6217f89SApple OSS Distributions 	mach_exception_data_type_t mx_code;
74*f6217f89SApple OSS Distributions 	mach_exception_data_type_t mx_subcode;
75*f6217f89SApple OSS Distributions 	struct kt_info {
76*f6217f89SApple OSS Distributions 		int kt_subsys;
77*f6217f89SApple OSS Distributions 		uint32_t kt_error;
78*f6217f89SApple OSS Distributions 	} kt_info;
79*f6217f89SApple OSS Distributions } exception_info_t;
80*f6217f89SApple OSS Distributions 
81*f6217f89SApple OSS Distributions #define PX_FLAGS_NONE           0
82*f6217f89SApple OSS Distributions /* think twice about userspace debugging experience before using PX_DEBUG_NO_HONOR */
83*f6217f89SApple OSS Distributions #define PX_DEBUG_NO_HONOR       (1 << 0) /* force exit even when debugging */
84*f6217f89SApple OSS Distributions #define PX_KTRIAGE              (1 << 1) /* leave a ktriage record */
85*f6217f89SApple OSS Distributions #define PX_PSIGNAL              (1 << 2) /* send sig instead of forced exit */
86*f6217f89SApple OSS Distributions #define PX_NO_EXCEPTION_UTHREAD (1 << 3) /* do not set bsdthread exception */
87*f6217f89SApple OSS Distributions 
88*f6217f89SApple OSS Distributions int exit_with_mach_exception(struct proc *p, exception_info_t exception, uint32_t flags);
89*f6217f89SApple OSS Distributions #if CONFIG_EXCLAVES
90*f6217f89SApple OSS Distributions int exit_with_exclave_exception(struct proc *p, exception_info_t exception, uint32_t flags);
91*f6217f89SApple OSS Distributions #endif
92*f6217f89SApple OSS Distributions void exit_with_mach_exception_using_ast(exception_info_t exception, uint32_t flags, bool fatal);
93*f6217f89SApple OSS Distributions 
94*f6217f89SApple OSS Distributions #else /* XNU_KERNEL_PRIVATE */
95*f6217f89SApple OSS Distributions 
96*f6217f89SApple OSS Distributions typedef void * os_reason_t;
97*f6217f89SApple OSS Distributions 
98*f6217f89SApple OSS Distributions #endif /* XNU_KERNEL_PRIVATE */
99*f6217f89SApple OSS Distributions 
100*f6217f89SApple OSS Distributions os_reason_t os_reason_create(uint32_t osr_namespace, uint64_t osr_code);
101*f6217f89SApple OSS Distributions int os_reason_alloc_buffer_noblock(os_reason_t cur_reason, uint32_t osr_bufsize);
102*f6217f89SApple OSS Distributions struct kcdata_descriptor * os_reason_get_kcdata_descriptor(os_reason_t cur_reason);
103*f6217f89SApple OSS Distributions void os_reason_ref(os_reason_t cur_reason);
104*f6217f89SApple OSS Distributions void os_reason_free(os_reason_t cur_reason);
105*f6217f89SApple OSS Distributions void os_reason_set_flags(os_reason_t cur_reason, uint64_t flags);
106*f6217f89SApple OSS Distributions void os_reason_set_description_data(os_reason_t cur_reason, uint32_t type, void *reason_data, uint32_t reason_data_len);
107*f6217f89SApple OSS Distributions #endif /* KERNEL_PRIVATE */
108*f6217f89SApple OSS Distributions 
109*f6217f89SApple OSS Distributions /*
110*f6217f89SApple OSS Distributions  * Reason namespaces.
111*f6217f89SApple OSS Distributions  */
112*f6217f89SApple OSS Distributions #define OS_REASON_INVALID       0
113*f6217f89SApple OSS Distributions #define OS_REASON_JETSAM        1
114*f6217f89SApple OSS Distributions #define OS_REASON_SIGNAL        2
115*f6217f89SApple OSS Distributions #define OS_REASON_CODESIGNING   3
116*f6217f89SApple OSS Distributions #define OS_REASON_HANGTRACER    4
117*f6217f89SApple OSS Distributions #define OS_REASON_TEST          5
118*f6217f89SApple OSS Distributions #define OS_REASON_DYLD          6
119*f6217f89SApple OSS Distributions #define OS_REASON_LIBXPC        7
120*f6217f89SApple OSS Distributions #define OS_REASON_OBJC          8
121*f6217f89SApple OSS Distributions #define OS_REASON_EXEC          9
122*f6217f89SApple OSS Distributions #define OS_REASON_SPRINGBOARD   10
123*f6217f89SApple OSS Distributions #define OS_REASON_TCC           11
124*f6217f89SApple OSS Distributions #define OS_REASON_REPORTCRASH   12
125*f6217f89SApple OSS Distributions #define OS_REASON_COREANIMATION 13
126*f6217f89SApple OSS Distributions #define OS_REASON_AGGREGATED    14
127*f6217f89SApple OSS Distributions #define OS_REASON_RUNNINGBOARD  15
128*f6217f89SApple OSS Distributions #define OS_REASON_ASSERTIOND    OS_REASON_RUNNINGBOARD  /* old name */
129*f6217f89SApple OSS Distributions #define OS_REASON_SKYWALK       16
130*f6217f89SApple OSS Distributions #define OS_REASON_SETTINGS      17
131*f6217f89SApple OSS Distributions #define OS_REASON_LIBSYSTEM     18
132*f6217f89SApple OSS Distributions #define OS_REASON_FOUNDATION    19
133*f6217f89SApple OSS Distributions #define OS_REASON_WATCHDOG      20
134*f6217f89SApple OSS Distributions #define OS_REASON_METAL         21
135*f6217f89SApple OSS Distributions #define OS_REASON_WATCHKIT      22
136*f6217f89SApple OSS Distributions #define OS_REASON_GUARD         23
137*f6217f89SApple OSS Distributions #define OS_REASON_ANALYTICS     24
138*f6217f89SApple OSS Distributions #define OS_REASON_SANDBOX       25
139*f6217f89SApple OSS Distributions #define OS_REASON_SECURITY      26
140*f6217f89SApple OSS Distributions #define OS_REASON_ENDPOINTSECURITY      27
141*f6217f89SApple OSS Distributions #define OS_REASON_PAC_EXCEPTION 28
142*f6217f89SApple OSS Distributions #define OS_REASON_BLUETOOTH_CHIP 29
143*f6217f89SApple OSS Distributions #define OS_REASON_PORT_SPACE    30
144*f6217f89SApple OSS Distributions #define OS_REASON_WEBKIT        31
145*f6217f89SApple OSS Distributions #define OS_REASON_BACKLIGHTSERVICES 32
146*f6217f89SApple OSS Distributions #define OS_REASON_MEDIA 33
147*f6217f89SApple OSS Distributions #define OS_REASON_ROSETTA 34
148*f6217f89SApple OSS Distributions #define OS_REASON_LIBIGNITION 35
149*f6217f89SApple OSS Distributions #define OS_REASON_BOOTMOUNT 36
150*f6217f89SApple OSS Distributions 
151*f6217f89SApple OSS Distributions 
152*f6217f89SApple OSS Distributions #define OS_REASON_REALITYKIT 38
153*f6217f89SApple OSS Distributions #define OS_REASON_AUDIO      39
154*f6217f89SApple OSS Distributions #define OS_REASON_WAKEBOARD  40
155*f6217f89SApple OSS Distributions #define OS_REASON_CORERC     41
156*f6217f89SApple OSS Distributions #define OS_REASON_SELF_RESTRICT 42
157*f6217f89SApple OSS Distributions #define OS_REASON_ARKIT      43
158*f6217f89SApple OSS Distributions #define OS_REASON_CAMERA     44
159*f6217f89SApple OSS Distributions #define OS_REASON_BACKBOARD  45
160*f6217f89SApple OSS Distributions #define OS_REASON_POWEREXCEPTIONS 46
161*f6217f89SApple OSS Distributions #define OS_REASON_SECINIT    47
162*f6217f89SApple OSS Distributions 
163*f6217f89SApple OSS Distributions /*
164*f6217f89SApple OSS Distributions  * Update whenever new OS_REASON namespaces are added.
165*f6217f89SApple OSS Distributions  */
166*f6217f89SApple OSS Distributions #define OS_REASON_MAX_VALID_NAMESPACE OS_REASON_SECINIT
167*f6217f89SApple OSS Distributions 
168*f6217f89SApple OSS Distributions #define OS_REASON_BUFFER_MAX_SIZE 5120
169*f6217f89SApple OSS Distributions 
170*f6217f89SApple OSS Distributions #define OS_REASON_FLAG_NO_CRASH_REPORT          0x1    /* Don't create a crash report */
171*f6217f89SApple OSS Distributions #define OS_REASON_FLAG_GENERATE_CRASH_REPORT    0x2    /* Create a crash report - the default for userspace requests */
172*f6217f89SApple OSS Distributions #define OS_REASON_FLAG_FROM_USERSPACE           0x4    /* Reason created from a userspace syscall */
173*f6217f89SApple OSS Distributions #define OS_REASON_FLAG_FAILED_DATA_COPYIN       0x8    /* We failed to copyin data from userspace */
174*f6217f89SApple OSS Distributions #define OS_REASON_FLAG_PAYLOAD_TRUNCATED        0x10   /* The payload was truncated because it was longer than allowed */
175*f6217f89SApple OSS Distributions #define OS_REASON_FLAG_BAD_PARAMS               0x20   /* Invalid parameters were passed involved with creating this reason */
176*f6217f89SApple OSS Distributions #define OS_REASON_FLAG_CONSISTENT_FAILURE       0x40   /* Whatever caused this reason to be created will happen again */
177*f6217f89SApple OSS Distributions #define OS_REASON_FLAG_ONE_TIME_FAILURE         0x80   /* Whatever caused this reason to be created was a one time issue */
178*f6217f89SApple OSS Distributions #define OS_REASON_FLAG_NO_CRASHED_TID           0x100  /* Don't include the TID that processed the exit in the crash report */
179*f6217f89SApple OSS Distributions #define OS_REASON_FLAG_ABORT                    0x200  /* Reason created from abort_* rather than terminate_* */
180*f6217f89SApple OSS Distributions #define OS_REASON_FLAG_SHAREDREGION_FAULT       0x400  /* Fault happened within the shared cache region */
181*f6217f89SApple OSS Distributions #define OS_REASON_FLAG_CAPTURE_LOGS             0x800  /* The report generated for this reason should capture logs */
182*f6217f89SApple OSS Distributions #define OS_REASON_FLAG_SECURITY_SENSITIVE       0x1000 /* Mark as security sensitive for priority treatment */
183*f6217f89SApple OSS Distributions 
184*f6217f89SApple OSS Distributions /*
185*f6217f89SApple OSS Distributions  * Set of flags that are allowed to be passed from userspace
186*f6217f89SApple OSS Distributions  */
187*f6217f89SApple OSS Distributions #define OS_REASON_FLAG_MASK_ALLOWED_FROM_USER (OS_REASON_FLAG_CONSISTENT_FAILURE | OS_REASON_FLAG_ONE_TIME_FAILURE | OS_REASON_FLAG_NO_CRASH_REPORT | OS_REASON_FLAG_ABORT | OS_REASON_FLAG_CAPTURE_LOGS | OS_REASON_FLAG_SECURITY_SENSITIVE)
188*f6217f89SApple OSS Distributions 
189*f6217f89SApple OSS Distributions /*
190*f6217f89SApple OSS Distributions  * Macros to encode the exit reason namespace and first 32 bits of code in exception code
191*f6217f89SApple OSS Distributions  * which is used by Report Crash as a hint. It should be only used as a hint since it
192*f6217f89SApple OSS Distributions  * loses higher 32 bits of exit reason code.
193*f6217f89SApple OSS Distributions  */
194*f6217f89SApple OSS Distributions #define ENCODE_OSR_NAMESPACE_TO_MACH_EXCEPTION_CODE(code, osr_namespace) \
195*f6217f89SApple OSS Distributions 	(code) = (code) | (((osr_namespace) & ((uint64_t)UINT32_MAX)) << 32)
196*f6217f89SApple OSS Distributions #define ENCODE_OSR_CODE_TO_MACH_EXCEPTION_CODE(code, osr_code) \
197*f6217f89SApple OSS Distributions 	(code) = (code) | ((osr_code) & ((uint64_t)UINT32_MAX))
198*f6217f89SApple OSS Distributions 
199*f6217f89SApple OSS Distributions #ifndef KERNEL
200*f6217f89SApple OSS Distributions /*
201*f6217f89SApple OSS Distributions  * abort_with_reason: Used to exit the current process and pass along
202*f6217f89SApple OSS Distributions  *                    specific information about why it is being terminated.
203*f6217f89SApple OSS Distributions  *
204*f6217f89SApple OSS Distributions  * Inputs:              args->reason_namespace - OS_REASON namespace specified for the reason
205*f6217f89SApple OSS Distributions  *                      args->reason_code - code in the specified namespace for the reason
206*f6217f89SApple OSS Distributions  *                      args->reason_string - additional string formatted information about the request
207*f6217f89SApple OSS Distributions  *                      args->reason_flags - options requested for how the process should be terminated (see OS_REASON_FLAG_* above).
208*f6217f89SApple OSS Distributions  *
209*f6217f89SApple OSS Distributions  * Outputs:             Does not return.
210*f6217f89SApple OSS Distributions  */
211*f6217f89SApple OSS Distributions void abort_with_reason(uint32_t reason_namespace, uint64_t reason_code, const char *reason_string, uint64_t reason_flags)
212*f6217f89SApple OSS Distributions __attribute__((noreturn, cold));
213*f6217f89SApple OSS Distributions 
214*f6217f89SApple OSS Distributions /*
215*f6217f89SApple OSS Distributions  * abort_with_payload: Used to exit the current process and pass along
216*f6217f89SApple OSS Distributions  *                     specific information about why it is being terminated. The payload pointer
217*f6217f89SApple OSS Distributions  *                     should point to structured data that can be interpreted by the consumer of
218*f6217f89SApple OSS Distributions  *                     exit reason information.
219*f6217f89SApple OSS Distributions  *
220*f6217f89SApple OSS Distributions  * Inputs:              args->reason_namespace - OS_REASON namespace specified for the reason
221*f6217f89SApple OSS Distributions  *                      args->reason_code - code in the specified namespace for the reason
222*f6217f89SApple OSS Distributions  *                      args->payload - pointer to payload structure in user space
223*f6217f89SApple OSS Distributions  *                      args->payload_size - length of payload buffer (this will be truncated to EXIT_REASON_PAYLOAD_MAX_LEN)
224*f6217f89SApple OSS Distributions  *                      args->reason_string - additional string formatted information about the request
225*f6217f89SApple OSS Distributions  *                      args->reason_flags - options requested for how the process should be terminated (see OS_REASON_FLAG_* above).
226*f6217f89SApple OSS Distributions  *
227*f6217f89SApple OSS Distributions  * Outputs:             Does not return.
228*f6217f89SApple OSS Distributions  */
229*f6217f89SApple OSS Distributions void abort_with_payload(uint32_t reason_namespace, uint64_t reason_code, void *payload, uint32_t payload_size, const char *reason_string,
230*f6217f89SApple OSS Distributions     uint64_t reason_flags) __attribute__((noreturn, cold));
231*f6217f89SApple OSS Distributions 
232*f6217f89SApple OSS Distributions /*
233*f6217f89SApple OSS Distributions  * terminate_with_reason: Used to terminate a specific process and pass along
234*f6217f89SApple OSS Distributions  *                        specific information about why it is being terminated.
235*f6217f89SApple OSS Distributions  *
236*f6217f89SApple OSS Distributions  * Inputs:              args->pid - the PID of the process to be terminated
237*f6217f89SApple OSS Distributions  *                      args->reason_namespace - OS_REASON namespace specified for the reason
238*f6217f89SApple OSS Distributions  *                      args->reason_code - code in the specified namespace for the reason
239*f6217f89SApple OSS Distributions  *                      args->reason_string - additional string formatted information about the request
240*f6217f89SApple OSS Distributions  *                      args->reason_flags - options requested for how the process should be terminated (see OS_REASON_FLAG_* above)
241*f6217f89SApple OSS Distributions  *
242*f6217f89SApple OSS Distributions  * Outputs:             returns -1 and sets errno to EINVAL if the PID requested is the same as that of the calling process, invalid or the namespace provided is invalid.
243*f6217f89SApple OSS Distributions  *                      returns -1 and sets errno to ESRCH if we couldn't find a live process with the requested PID
244*f6217f89SApple OSS Distributions  *                      returns -1 and sets errno to EPERM if the caller is not privileged enough to kill the process with the requested PID
245*f6217f89SApple OSS Distributions  *                      returns 0 otherwise
246*f6217f89SApple OSS Distributions  */
247*f6217f89SApple OSS Distributions int terminate_with_reason(int pid, uint32_t reason_namespace, uint64_t reason_code, const char *reason_string, uint64_t reason_flags);
248*f6217f89SApple OSS Distributions 
249*f6217f89SApple OSS Distributions /*
250*f6217f89SApple OSS Distributions  * terminate_with_payload: Used to terminate a specific process and pass along
251*f6217f89SApple OSS Distributions  *                         specific information about why it is being terminated. The payload pointer
252*f6217f89SApple OSS Distributions  *                         should point to structured data that can be interpreted by the consumer of
253*f6217f89SApple OSS Distributions  *                         exit reason information.
254*f6217f89SApple OSS Distributions  *
255*f6217f89SApple OSS Distributions  * Inputs:              args->pid - the PID of the process to be terminated.
256*f6217f89SApple OSS Distributions  *                      args->reason_namespace - OS_REASON namespace specified for the reason
257*f6217f89SApple OSS Distributions  *                      args->reason_code - code in the specified namespace for the reason
258*f6217f89SApple OSS Distributions  *                      args->payload - pointer to payload structure in user space
259*f6217f89SApple OSS Distributions  *                      args->payload_size - length of payload buffer (this will be truncated to EXIT_REASON_PAYLOAD_MAX_LEN)
260*f6217f89SApple OSS Distributions  *                      args->reason_string - additional string formatted information about the request
261*f6217f89SApple OSS Distributions  *                      args->reason_flags - options requested for how the process should be terminated (see OS_REASON_FLAG_* above)
262*f6217f89SApple OSS Distributions  *
263*f6217f89SApple OSS Distributions  * Outputs:             returns -1 and sets errno to EINVAL if the PID requested is the same as that of the calling process, is invalid or the namespace provided is invalid.
264*f6217f89SApple OSS Distributions  *                      returns -1 and sets errno to ESRCH if we couldn't find a live process with the requested PID
265*f6217f89SApple OSS Distributions  *                      returns -1 and sets errno to EPERM if the caller is not privileged enough to kill the process with the requested PID
266*f6217f89SApple OSS Distributions  *                      returns 0 otherwise
267*f6217f89SApple OSS Distributions  */
268*f6217f89SApple OSS Distributions int terminate_with_payload(int pid, uint32_t reason_namespace, uint64_t reason_code, void *payload, uint32_t payload_size,
269*f6217f89SApple OSS Distributions     const char *reason_string, uint64_t reason_flags);
270*f6217f89SApple OSS Distributions #endif /* KERNEL */
271*f6217f89SApple OSS Distributions 
272*f6217f89SApple OSS Distributions /*
273*f6217f89SApple OSS Distributions  * codesigning exit reasons
274*f6217f89SApple OSS Distributions  */
275*f6217f89SApple OSS Distributions #define CODESIGNING_EXIT_REASON_TASKGATED_INVALID_SIG           1
276*f6217f89SApple OSS Distributions #define CODESIGNING_EXIT_REASON_INVALID_PAGE                    2
277*f6217f89SApple OSS Distributions #define CODESIGNING_EXIT_REASON_TASK_ACCESS_PORT                3
278*f6217f89SApple OSS Distributions #define CODESIGNING_EXIT_REASON_LAUNCH_CONSTRAINT_VIOLATION     4
279*f6217f89SApple OSS Distributions /*
280*f6217f89SApple OSS Distributions  * exec path specific exit reasons
281*f6217f89SApple OSS Distributions  */
282*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_BAD_MACHO          1
283*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_SUGID_FAILURE      2
284*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_ACTV_THREADSTATE   3
285*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_STACK_ALLOC        4
286*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_APPLE_STRING_INIT  5
287*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_COPYOUT_STRINGS    6
288*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_COPYOUT_DYNLINKER  7
289*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_SECURITY_POLICY    8
290*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_TASKGATED_OTHER    9
291*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_FAIRPLAY_DECRYPT   10
292*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_DECRYPT            11
293*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_UPX                12
294*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_NO32EXEC           13
295*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_WRONG_PLATFORM     14
296*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_MAIN_FD_ALLOC      15
297*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_COPYOUT_ROSETTA    16
298*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_SET_DYLD_INFO      17
299*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_MACHINE_THREAD     18
300*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_BAD_PSATTR         19
301*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_NOX86EXEC          20
302*f6217f89SApple OSS Distributions #define EXEC_EXIT_REASON_MAP_EXEC_FAILURE   21
303*f6217f89SApple OSS Distributions /*
304*f6217f89SApple OSS Distributions  * guard reasons
305*f6217f89SApple OSS Distributions  */
306*f6217f89SApple OSS Distributions #define GUARD_REASON_VNODE       1
307*f6217f89SApple OSS Distributions #define GUARD_REASON_VIRT_MEMORY 2
308*f6217f89SApple OSS Distributions #define GUARD_REASON_MACH_PORT   3
309*f6217f89SApple OSS Distributions #define GUARD_REASON_EXCLAVES    4
310*f6217f89SApple OSS Distributions #define GUARD_REASON_JIT         5
311*f6217f89SApple OSS Distributions 
312*f6217f89SApple OSS Distributions __END_DECLS
313*f6217f89SApple OSS Distributions 
314*f6217f89SApple OSS Distributions #endif /* _REASON_H_ */
315