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