xref: /xnu-10063.101.15/tests/reply_port_defense.c (revision 94d3b452840153a99b38a3a9659680b2a006908e) !
1*94d3b452SApple OSS Distributions #include <stdio.h>
2*94d3b452SApple OSS Distributions #include <stdlib.h>
3*94d3b452SApple OSS Distributions #include <unistd.h>
4*94d3b452SApple OSS Distributions #include <darwintest.h>
5*94d3b452SApple OSS Distributions #include <spawn.h>
6*94d3b452SApple OSS Distributions #include <mach/mach.h>
7*94d3b452SApple OSS Distributions #include <sys/sysctl.h>
8*94d3b452SApple OSS Distributions #include <signal.h>
9*94d3b452SApple OSS Distributions #include "excserver_protect.h"
10*94d3b452SApple OSS Distributions #include "../osfmk/ipc/ipc_init.h"
11*94d3b452SApple OSS Distributions #include "../osfmk/mach/port.h"
12*94d3b452SApple OSS Distributions #include "../osfmk/kern/exc_guard.h"
13*94d3b452SApple OSS Distributions #include "exc_helpers.h"
14*94d3b452SApple OSS Distributions #include <sys/code_signing.h>
15*94d3b452SApple OSS Distributions #include "cs_helpers.h"
16*94d3b452SApple OSS Distributions 
17*94d3b452SApple OSS Distributions #define MAX_TEST_NUM 7
18*94d3b452SApple OSS Distributions #define MAX_ARGV 3
19*94d3b452SApple OSS Distributions 
20*94d3b452SApple OSS Distributions extern char **environ;
21*94d3b452SApple OSS Distributions static mach_exception_data_type_t received_exception_code = 0;
22*94d3b452SApple OSS Distributions static exception_type_t exception_taken = 0;
23*94d3b452SApple OSS Distributions 
24*94d3b452SApple OSS Distributions /*
25*94d3b452SApple OSS Distributions  * This test infrastructure is inspired from imm_pinned_control_port.c.
26*94d3b452SApple OSS Distributions  * It verifies no reply port security semantics are violated.
27*94d3b452SApple OSS Distributions  *
28*94d3b452SApple OSS Distributions  * 1. The rcv right of the port would be marked immovable.
29*94d3b452SApple OSS Distributions  */
30*94d3b452SApple OSS Distributions T_GLOBAL_META(
31*94d3b452SApple OSS Distributions 	T_META_NAMESPACE("xnu.ipc"),
32*94d3b452SApple OSS Distributions 	T_META_RADAR_COMPONENT_NAME("xnu"),
33*94d3b452SApple OSS Distributions 	T_META_RADAR_COMPONENT_VERSION("IPC"),
34*94d3b452SApple OSS Distributions 	T_META_RUN_CONCURRENTLY(TRUE));
35*94d3b452SApple OSS Distributions 
36*94d3b452SApple OSS Distributions static mach_port_t
alloc_exception_port(void)37*94d3b452SApple OSS Distributions alloc_exception_port(void)
38*94d3b452SApple OSS Distributions {
39*94d3b452SApple OSS Distributions 	kern_return_t kret;
40*94d3b452SApple OSS Distributions 	mach_port_t exc_port = MACH_PORT_NULL;
41*94d3b452SApple OSS Distributions 	mach_port_t task = mach_task_self();
42*94d3b452SApple OSS Distributions 
43*94d3b452SApple OSS Distributions 	kret = mach_port_allocate(task, MACH_PORT_RIGHT_RECEIVE, &exc_port);
44*94d3b452SApple OSS Distributions 	T_QUIET; T_EXPECT_MACH_SUCCESS(kret, "mach_port_allocate exc_port");
45*94d3b452SApple OSS Distributions 
46*94d3b452SApple OSS Distributions 	kret = mach_port_insert_right(task, exc_port, exc_port, MACH_MSG_TYPE_MAKE_SEND);
47*94d3b452SApple OSS Distributions 	T_QUIET; T_EXPECT_MACH_SUCCESS(kret, "mach_port_insert_right exc_port");
48*94d3b452SApple OSS Distributions 
49*94d3b452SApple OSS Distributions 	return exc_port;
50*94d3b452SApple OSS Distributions }
51*94d3b452SApple OSS Distributions 
52*94d3b452SApple OSS Distributions kern_return_t
catch_mach_exception_raise_state(mach_port_t exception_port,exception_type_t exception,const mach_exception_data_t code,mach_msg_type_number_t code_count,int * flavor,const thread_state_t old_state,mach_msg_type_number_t old_state_count,thread_state_t new_state,mach_msg_type_number_t * new_state_count)53*94d3b452SApple OSS Distributions catch_mach_exception_raise_state(mach_port_t exception_port,
54*94d3b452SApple OSS Distributions     exception_type_t exception,
55*94d3b452SApple OSS Distributions     const mach_exception_data_t code,
56*94d3b452SApple OSS Distributions     mach_msg_type_number_t code_count,
57*94d3b452SApple OSS Distributions     int * flavor,
58*94d3b452SApple OSS Distributions     const thread_state_t old_state,
59*94d3b452SApple OSS Distributions     mach_msg_type_number_t old_state_count,
60*94d3b452SApple OSS Distributions     thread_state_t new_state,
61*94d3b452SApple OSS Distributions     mach_msg_type_number_t * new_state_count)
62*94d3b452SApple OSS Distributions {
63*94d3b452SApple OSS Distributions #pragma unused(exception_port, exception, code, code_count, flavor, old_state, old_state_count, new_state, new_state_count)
64*94d3b452SApple OSS Distributions 	T_FAIL("Unsupported catch_mach_exception_raise_state");
65*94d3b452SApple OSS Distributions 	return KERN_NOT_SUPPORTED;
66*94d3b452SApple OSS Distributions }
67*94d3b452SApple OSS Distributions 
68*94d3b452SApple OSS Distributions kern_return_t
catch_mach_exception_raise_state_identity(mach_port_t exception_port,mach_port_t thread,mach_port_t task,exception_type_t exception,mach_exception_data_t code,mach_msg_type_number_t code_count,int * flavor,thread_state_t old_state,mach_msg_type_number_t old_state_count,thread_state_t new_state,mach_msg_type_number_t * new_state_count)69*94d3b452SApple OSS Distributions catch_mach_exception_raise_state_identity(mach_port_t exception_port,
70*94d3b452SApple OSS Distributions     mach_port_t thread,
71*94d3b452SApple OSS Distributions     mach_port_t task,
72*94d3b452SApple OSS Distributions     exception_type_t exception,
73*94d3b452SApple OSS Distributions     mach_exception_data_t code,
74*94d3b452SApple OSS Distributions     mach_msg_type_number_t code_count,
75*94d3b452SApple OSS Distributions     int * flavor,
76*94d3b452SApple OSS Distributions     thread_state_t old_state,
77*94d3b452SApple OSS Distributions     mach_msg_type_number_t old_state_count,
78*94d3b452SApple OSS Distributions     thread_state_t new_state,
79*94d3b452SApple OSS Distributions     mach_msg_type_number_t * new_state_count)
80*94d3b452SApple OSS Distributions {
81*94d3b452SApple OSS Distributions #pragma unused(exception_port, thread, task, exception, code, code_count, flavor, old_state, old_state_count, new_state, new_state_count)
82*94d3b452SApple OSS Distributions 	T_FAIL("Unsupported catch_mach_exception_raise_state_identity");
83*94d3b452SApple OSS Distributions 	return KERN_NOT_SUPPORTED;
84*94d3b452SApple OSS Distributions }
85*94d3b452SApple OSS Distributions 
86*94d3b452SApple OSS Distributions kern_return_t
catch_mach_exception_raise_identity_protected(__unused mach_port_t exception_port,uint64_t thread_id,mach_port_t task_id_token,exception_type_t exception,mach_exception_data_t codes,mach_msg_type_number_t codeCnt)87*94d3b452SApple OSS Distributions catch_mach_exception_raise_identity_protected(
88*94d3b452SApple OSS Distributions 	__unused mach_port_t      exception_port,
89*94d3b452SApple OSS Distributions 	uint64_t                  thread_id,
90*94d3b452SApple OSS Distributions 	mach_port_t               task_id_token,
91*94d3b452SApple OSS Distributions 	exception_type_t          exception,
92*94d3b452SApple OSS Distributions 	mach_exception_data_t     codes,
93*94d3b452SApple OSS Distributions 	mach_msg_type_number_t    codeCnt)
94*94d3b452SApple OSS Distributions {
95*94d3b452SApple OSS Distributions #pragma unused(exception_port, thread_id, task_id_token)
96*94d3b452SApple OSS Distributions 
97*94d3b452SApple OSS Distributions 	T_ASSERT_GT_UINT(codeCnt, 0, "CodeCnt");
98*94d3b452SApple OSS Distributions 
99*94d3b452SApple OSS Distributions 	T_LOG("Caught exception type: %d code: 0x%llx", exception, codes[0]);
100*94d3b452SApple OSS Distributions 	exception_taken = exception;
101*94d3b452SApple OSS Distributions 	if (exception == EXC_GUARD) {
102*94d3b452SApple OSS Distributions 		received_exception_code = EXC_GUARD_DECODE_GUARD_FLAVOR((uint64_t)codes[0]);
103*94d3b452SApple OSS Distributions 	} else if (exception == EXC_CORPSE_NOTIFY) {
104*94d3b452SApple OSS Distributions 		received_exception_code = codes[0];
105*94d3b452SApple OSS Distributions 	} else {
106*94d3b452SApple OSS Distributions 		T_FAIL("Unexpected exception");
107*94d3b452SApple OSS Distributions 	}
108*94d3b452SApple OSS Distributions 	return KERN_SUCCESS;
109*94d3b452SApple OSS Distributions }
110*94d3b452SApple OSS Distributions 
111*94d3b452SApple OSS Distributions kern_return_t
catch_mach_exception_raise(mach_port_t exception_port,mach_port_t thread,mach_port_t task,exception_type_t exception,mach_exception_data_t code,mach_msg_type_number_t code_count)112*94d3b452SApple OSS Distributions catch_mach_exception_raise(mach_port_t exception_port,
113*94d3b452SApple OSS Distributions     mach_port_t thread,
114*94d3b452SApple OSS Distributions     mach_port_t task,
115*94d3b452SApple OSS Distributions     exception_type_t exception,
116*94d3b452SApple OSS Distributions     mach_exception_data_t code,
117*94d3b452SApple OSS Distributions     mach_msg_type_number_t code_count)
118*94d3b452SApple OSS Distributions {
119*94d3b452SApple OSS Distributions #pragma unused(exception_port, thread, task, exception, code, code_count)
120*94d3b452SApple OSS Distributions 	T_FAIL("Unsupported catch_mach_exception_raise_state_identity");
121*94d3b452SApple OSS Distributions 	return KERN_NOT_SUPPORTED;
122*94d3b452SApple OSS Distributions }
123*94d3b452SApple OSS Distributions 
124*94d3b452SApple OSS Distributions static void *
exception_server_thread(void * arg)125*94d3b452SApple OSS Distributions exception_server_thread(void *arg)
126*94d3b452SApple OSS Distributions {
127*94d3b452SApple OSS Distributions 	kern_return_t kr;
128*94d3b452SApple OSS Distributions 	mach_port_t exc_port = *(mach_port_t *)arg;
129*94d3b452SApple OSS Distributions 
130*94d3b452SApple OSS Distributions 	/* Handle exceptions on exc_port */
131*94d3b452SApple OSS Distributions 	kr = mach_msg_server_once(mach_exc_server, 4096, exc_port, 0);
132*94d3b452SApple OSS Distributions 	T_QUIET; T_EXPECT_MACH_SUCCESS(kr, "mach_msg_server_once");
133*94d3b452SApple OSS Distributions 
134*94d3b452SApple OSS Distributions 	return NULL;
135*94d3b452SApple OSS Distributions }
136*94d3b452SApple OSS Distributions 
137*94d3b452SApple OSS Distributions #define kGUARD_EXC_EXCEPTION_BEHAVIOR_ENFORCE 6
138*94d3b452SApple OSS Distributions static void
reply_port_defense(const bool thirdparty_hardened,int test_index,mach_exception_data_type_t expected_exception_code,bool triggers_exception)139*94d3b452SApple OSS Distributions reply_port_defense(const bool thirdparty_hardened, int test_index, mach_exception_data_type_t expected_exception_code, bool triggers_exception)
140*94d3b452SApple OSS Distributions {
141*94d3b452SApple OSS Distributions 	int ret = 0;
142*94d3b452SApple OSS Distributions 
143*94d3b452SApple OSS Distributions 	uint32_t task_exc_guard = 0;
144*94d3b452SApple OSS Distributions 	size_t te_size = sizeof(&task_exc_guard);
145*94d3b452SApple OSS Distributions 
146*94d3b452SApple OSS Distributions 	/* Test that the behavior is the same between these two */
147*94d3b452SApple OSS Distributions 	char *test_prog_name = thirdparty_hardened ?
148*94d3b452SApple OSS Distributions 	    "./reply_port_defense_client_3P_hardened" : "./reply_port_defense_client";
149*94d3b452SApple OSS Distributions 	char *child_args[MAX_ARGV];
150*94d3b452SApple OSS Distributions 	pid_t client_pid = 0;
151*94d3b452SApple OSS Distributions 	posix_spawnattr_t attrs;
152*94d3b452SApple OSS Distributions 
153*94d3b452SApple OSS Distributions 	pthread_t s_exc_thread;
154*94d3b452SApple OSS Distributions 	mach_port_t exc_port;
155*94d3b452SApple OSS Distributions 
156*94d3b452SApple OSS Distributions 	T_LOG("Check if task_exc_guard exception has been enabled\n");
157*94d3b452SApple OSS Distributions 	ret = sysctlbyname("kern.task_exc_guard_default", &task_exc_guard, &te_size, NULL, 0);
158*94d3b452SApple OSS Distributions 	T_ASSERT_EQ(ret, 0, "sysctlbyname");
159*94d3b452SApple OSS Distributions 
160*94d3b452SApple OSS Distributions 	if (!(task_exc_guard & TASK_EXC_GUARD_MP_DELIVER)) {
161*94d3b452SApple OSS Distributions 		T_SKIP("task_exc_guard exception is not enabled");
162*94d3b452SApple OSS Distributions 	}
163*94d3b452SApple OSS Distributions 
164*94d3b452SApple OSS Distributions 	exc_port = alloc_exception_port();
165*94d3b452SApple OSS Distributions 	T_QUIET; T_ASSERT_NE(exc_port, MACH_PORT_NULL, "Create a new exception port");
166*94d3b452SApple OSS Distributions 
167*94d3b452SApple OSS Distributions 	/* Create exception serving thread */
168*94d3b452SApple OSS Distributions 	ret = pthread_create(&s_exc_thread, NULL, exception_server_thread, &exc_port);
169*94d3b452SApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_SUCCESS(ret, "pthread_create exception_server_thread");
170*94d3b452SApple OSS Distributions 
171*94d3b452SApple OSS Distributions 	/* Initialize posix_spawn attributes */
172*94d3b452SApple OSS Distributions 	posix_spawnattr_init(&attrs);
173*94d3b452SApple OSS Distributions 
174*94d3b452SApple OSS Distributions 	/*
175*94d3b452SApple OSS Distributions 	 * It is allowed for us to set an exception port because we are entitled test process.
176*94d3b452SApple OSS Distributions 	 * If you are using this code as an example for platform binaries,
177*94d3b452SApple OSS Distributions 	 * use `EXCEPTION_IDENTITY_PROTECTED` instead of `EXCEPTION_DEFAULT`
178*94d3b452SApple OSS Distributions 	 */
179*94d3b452SApple OSS Distributions 	int err = posix_spawnattr_setexceptionports_np(&attrs, EXC_MASK_GUARD | EXC_MASK_CORPSE_NOTIFY, exc_port,
180*94d3b452SApple OSS Distributions 	    (exception_behavior_t) (EXCEPTION_IDENTITY_PROTECTED | MACH_EXCEPTION_CODES), 0);
181*94d3b452SApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_SUCCESS(err, "posix_spawnattr_setflags");
182*94d3b452SApple OSS Distributions 
183*94d3b452SApple OSS Distributions 	child_args[0] = test_prog_name;
184*94d3b452SApple OSS Distributions 	char test_num[10];
185*94d3b452SApple OSS Distributions 	sprintf(test_num, "%d", test_index);
186*94d3b452SApple OSS Distributions 	child_args[1] = test_num;
187*94d3b452SApple OSS Distributions 	child_args[2] = NULL;
188*94d3b452SApple OSS Distributions 
189*94d3b452SApple OSS Distributions 	T_LOG("========== Spawning new child ==========");
190*94d3b452SApple OSS Distributions 	err = posix_spawn(&client_pid, child_args[0], NULL, &attrs, &child_args[0], environ);
191*94d3b452SApple OSS Distributions 	T_ASSERT_POSIX_SUCCESS(err, "posix_spawn reply_port_defense_client = %d", client_pid);
192*94d3b452SApple OSS Distributions 
193*94d3b452SApple OSS Distributions 	int child_status;
194*94d3b452SApple OSS Distributions 	/* Wait for child and check for exception */
195*94d3b452SApple OSS Distributions 	if (-1 == waitpid(-1, &child_status, 0)) {
196*94d3b452SApple OSS Distributions 		T_FAIL("%s waitpid: child", strerror(errno));
197*94d3b452SApple OSS Distributions 	}
198*94d3b452SApple OSS Distributions 	if (WIFEXITED(child_status) && WEXITSTATUS(child_status)) {
199*94d3b452SApple OSS Distributions 		T_FAIL("Child exited with status = 0x%x", child_status);
200*94d3b452SApple OSS Distributions 	}
201*94d3b452SApple OSS Distributions 	sleep(1);
202*94d3b452SApple OSS Distributions 	kill(1, SIGKILL);
203*94d3b452SApple OSS Distributions 	if (triggers_exception) {
204*94d3b452SApple OSS Distributions 		ret = pthread_join(s_exc_thread, NULL);
205*94d3b452SApple OSS Distributions 		T_QUIET; T_ASSERT_POSIX_SUCCESS(ret, "pthread_join");
206*94d3b452SApple OSS Distributions 	}
207*94d3b452SApple OSS Distributions 
208*94d3b452SApple OSS Distributions 	mach_port_deallocate(mach_task_self(), exc_port);
209*94d3b452SApple OSS Distributions 
210*94d3b452SApple OSS Distributions 	T_LOG("Exception code: Received code = 0x%llx Expected code = 0x%llx", received_exception_code, expected_exception_code);
211*94d3b452SApple OSS Distributions 	T_EXPECT_EQ(received_exception_code, expected_exception_code, "Exception code: Received == Expected");
212*94d3b452SApple OSS Distributions }
213*94d3b452SApple OSS Distributions 
214*94d3b452SApple OSS Distributions T_DECL(reply_port_defense,
215*94d3b452SApple OSS Distributions     "Test reply port semantics violations",
216*94d3b452SApple OSS Distributions     T_META_IGNORECRASHES(".*reply_port_defense_client.*"),
217*94d3b452SApple OSS Distributions     T_META_CHECK_LEAKS(false)) {
218*94d3b452SApple OSS Distributions 	bool triggers_exception = true;
219*94d3b452SApple OSS Distributions 	/* The first test is setup as moving immovable receive right of a reply port. */
220*94d3b452SApple OSS Distributions 	reply_port_defense(true, 0, kGUARD_EXC_IMMOVABLE, triggers_exception);
221*94d3b452SApple OSS Distributions 	reply_port_defense(false, 0, kGUARD_EXC_IMMOVABLE, triggers_exception);
222*94d3b452SApple OSS Distributions 
223*94d3b452SApple OSS Distributions 	int rp_defense_max_test_idx = 3;
224*94d3b452SApple OSS Distributions 	/* Run the reply_port_defense tests 1, 2, and 3 */
225*94d3b452SApple OSS Distributions 	mach_exception_data_type_t expected_exception_code = kGUARD_EXC_INVALID_RIGHT;
226*94d3b452SApple OSS Distributions 	for (int i = 1; i <= rp_defense_max_test_idx; i++) {
227*94d3b452SApple OSS Distributions 		reply_port_defense(true, i, expected_exception_code, triggers_exception);
228*94d3b452SApple OSS Distributions 		reply_port_defense(false, i, expected_exception_code, triggers_exception);
229*94d3b452SApple OSS Distributions 	}
230*94d3b452SApple OSS Distributions }
231*94d3b452SApple OSS Distributions 
232*94d3b452SApple OSS Distributions 
233*94d3b452SApple OSS Distributions T_DECL(test_move_provisional_reply_port,
234*94d3b452SApple OSS Distributions     "provisional reply ports are immovable",
235*94d3b452SApple OSS Distributions     T_META_IGNORECRASHES(".*reply_port_defense_client.*"),
236*94d3b452SApple OSS Distributions     T_META_CHECK_LEAKS(false)) {
237*94d3b452SApple OSS Distributions 	int test_num = 4;
238*94d3b452SApple OSS Distributions 	mach_exception_data_type_t expected_exception_code = 0;
239*94d3b452SApple OSS Distributions 	bool triggers_exception = false;
240*94d3b452SApple OSS Distributions 	reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
241*94d3b452SApple OSS Distributions 	reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
242*94d3b452SApple OSS Distributions }
243*94d3b452SApple OSS Distributions 
244*94d3b452SApple OSS Distributions 
245*94d3b452SApple OSS Distributions T_DECL(test_unentitled_thread_set_exception_ports,
246*94d3b452SApple OSS Distributions     "thread_set_exception_ports should fail without an entitlement",
247*94d3b452SApple OSS Distributions     T_META_IGNORECRASHES(".*reply_port_defense_client.*"),
248*94d3b452SApple OSS Distributions     T_META_CHECK_LEAKS(false)) {
249*94d3b452SApple OSS Distributions 	int test_num = 5;
250*94d3b452SApple OSS Distributions 	mach_exception_data_type_t expected_exception_code = kGUARD_EXC_EXCEPTION_BEHAVIOR_ENFORCE;
251*94d3b452SApple OSS Distributions 	bool triggers_exception = true;
252*94d3b452SApple OSS Distributions 
253*94d3b452SApple OSS Distributions #if TARGET_OS_OSX
254*94d3b452SApple OSS Distributions 	/*
255*94d3b452SApple OSS Distributions 	 * CS_CONFIG_GET_OUT_OF_MY_WAY (enabled via AMFI boot-args)
256*94d3b452SApple OSS Distributions 	 * disables this security feature. This boot-arg previously
257*94d3b452SApple OSS Distributions 	 * caused a headache for developers on macos, who frequently use it for
258*94d3b452SApple OSS Distributions 	 * testing purposes, because all of their 3rd party apps will
259*94d3b452SApple OSS Distributions 	 * crash due to being treated as platform code. Unfortunately
260*94d3b452SApple OSS Distributions 	 * BATS runs with this boot-arg enabled.
261*94d3b452SApple OSS Distributions 	 */
262*94d3b452SApple OSS Distributions 	code_signing_config_t cs_config = 0;
263*94d3b452SApple OSS Distributions 	size_t cs_config_size = sizeof(cs_config);
264*94d3b452SApple OSS Distributions 	sysctlbyname("security.codesigning.config", &cs_config, &cs_config_size, NULL, 0);
265*94d3b452SApple OSS Distributions 	if (cs_config & CS_CONFIG_GET_OUT_OF_MY_WAY) {
266*94d3b452SApple OSS Distributions 		expected_exception_code = 0;
267*94d3b452SApple OSS Distributions 		triggers_exception = false;
268*94d3b452SApple OSS Distributions 		T_LOG("task identity security policy for thread_set_exception_ports"
269*94d3b452SApple OSS Distributions 		    " disabled due to AMFI boot-args.");
270*94d3b452SApple OSS Distributions 	} else
271*94d3b452SApple OSS Distributions #endif /* TARGET_OS_OSX */
272*94d3b452SApple OSS Distributions 	{
273*94d3b452SApple OSS Distributions 		T_LOG("task identity security policy for thread_set_exception_ports enabled");
274*94d3b452SApple OSS Distributions 	}
275*94d3b452SApple OSS Distributions 
276*94d3b452SApple OSS Distributions 	reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
277*94d3b452SApple OSS Distributions 	reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
278*94d3b452SApple OSS Distributions }
279*94d3b452SApple OSS Distributions 
280*94d3b452SApple OSS Distributions T_DECL(test_unentitled_thread_set_state,
281*94d3b452SApple OSS Distributions     "thread_set_state should fail without an entitlement",
282*94d3b452SApple OSS Distributions     T_META_IGNORECRASHES(".*reply_port_defense_client.*"),
283*94d3b452SApple OSS Distributions     T_META_CHECK_LEAKS(false)) {
284*94d3b452SApple OSS Distributions 	int test_num = 6;
285*94d3b452SApple OSS Distributions 	mach_exception_data_type_t expected_exception_code = (mach_exception_data_type_t)kGUARD_EXC_THREAD_SET_STATE;
286*94d3b452SApple OSS Distributions 	bool triggers_exception = true;
287*94d3b452SApple OSS Distributions 	reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
288*94d3b452SApple OSS Distributions 	reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
289*94d3b452SApple OSS Distributions }
290