1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <darwintest.h>
5 #include <spawn.h>
6 #include <mach/mach.h>
7 #include <sys/sysctl.h>
8 #include <sys/csr.h>
9 #include <signal.h>
10 #include "excserver_protect_state.h"
11 #include "../osfmk/mach/port.h"
12 #include "../osfmk/kern/exc_guard.h"
13 #include "exc_helpers.h"
14 #include <sys/code_signing.h>
15 #include "cs_helpers.h"
16 #include <TargetConditionals.h>
17 #include "ipc/ipc_utils.h"
18
19 #define MAX_ARGV 3
20
21 extern char **environ;
22 static mach_exception_data_type_t received_exception_code = 0;
23 static exception_type_t exception_taken = 0;
24
25 /*
26 * This test infrastructure is inspired from imm_pinned_control_port.c.
27 * It verifies no reply port security semantics are violated.
28 *
29 * 1. The rcv right of the port would be marked immovable.
30 */
31 T_GLOBAL_META(
32 T_META_NAMESPACE("xnu.ipc"),
33 T_META_RADAR_COMPONENT_NAME("xnu"),
34 T_META_RADAR_COMPONENT_VERSION("IPC"),
35 T_META_TIMEOUT(10),
36 T_META_RUN_CONCURRENTLY(TRUE));
37
38 static bool
check_current_cs_flags(code_signing_config_t expected_cs_config)39 check_current_cs_flags(code_signing_config_t expected_cs_config)
40 {
41 code_signing_config_t cur_cs_config = 0;
42 size_t cs_config_size = sizeof(cur_cs_config);
43 sysctlbyname("security.codesigning.config", &cur_cs_config, &cs_config_size, NULL, 0);
44 return cur_cs_config & expected_cs_config;
45 }
46
47 static bool
unrestricted_debugging()48 unrestricted_debugging()
49 {
50 /* AMFI often disables security features if debugging is unrestricted */
51 bool unrestricted_debugging = check_current_cs_flags(CS_CONFIG_UNRESTRICTED_DEBUGGING);
52 if (unrestricted_debugging) {
53 T_LOG("UNRESTRICTED DEBUGGING");
54 }
55 return unrestricted_debugging;
56 }
57
58 static bool
sip_disabled()59 sip_disabled()
60 {
61 #if XNU_TARGET_OS_OSX || XNU_TARGET_OS_BRIDGE
62 /* SIP can only be disabled on macOS */
63 bool sip_disabled = csr_check(CSR_ALLOW_UNRESTRICTED_FS) != 0;
64 if (sip_disabled) {
65 T_LOG("SIP DISABLED");
66 }
67 return sip_disabled;
68 #else
69 return false;
70 #endif
71 }
72
73 static bool
is_release_kernel()74 is_release_kernel()
75 {
76 int kernel_type = 0;
77 size_t kernel_type_size = sizeof(kernel_type);
78 int r;
79 r = sysctlbyname("kern.development", &kernel_type, &kernel_type_size, NULL, 0);
80 if (r < 0) {
81 T_WITH_ERRNO;
82 T_SKIP("could not find \"kern.development\" sysctl");
83 }
84 return kernel_type == 0;
85 }
86
87
88
89 static mach_port_t
alloc_exception_port(void)90 alloc_exception_port(void)
91 {
92 kern_return_t kret;
93 mach_port_t exc_port = MACH_PORT_NULL;
94 mach_port_t task = mach_task_self();
95
96 kret = mach_port_allocate(task, MACH_PORT_RIGHT_RECEIVE, &exc_port);
97 T_QUIET; T_EXPECT_MACH_SUCCESS(kret, "mach_port_allocate exc_port");
98
99 kret = mach_port_insert_right(task, exc_port, exc_port, MACH_MSG_TYPE_MAKE_SEND);
100 T_QUIET; T_EXPECT_MACH_SUCCESS(kret, "mach_port_insert_right exc_port");
101
102 return exc_port;
103 }
104
105 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)106 catch_mach_exception_raise_state(mach_port_t exception_port,
107 exception_type_t exception,
108 const mach_exception_data_t code,
109 mach_msg_type_number_t code_count,
110 int * flavor,
111 const thread_state_t old_state,
112 mach_msg_type_number_t old_state_count,
113 thread_state_t new_state,
114 mach_msg_type_number_t * new_state_count)
115 {
116 #pragma unused(exception_port, exception, code, code_count, flavor, old_state, old_state_count, new_state, new_state_count)
117 T_FAIL("Unsupported catch_mach_exception_raise_state");
118 return KERN_NOT_SUPPORTED;
119 }
120
121 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)122 catch_mach_exception_raise_state_identity(mach_port_t exception_port,
123 mach_port_t thread,
124 mach_port_t task,
125 exception_type_t exception,
126 mach_exception_data_t code,
127 mach_msg_type_number_t code_count,
128 int * flavor,
129 thread_state_t old_state,
130 mach_msg_type_number_t old_state_count,
131 thread_state_t new_state,
132 mach_msg_type_number_t * new_state_count)
133 {
134 #pragma unused(exception_port, thread, task, exception, code, code_count, flavor, old_state, old_state_count, new_state, new_state_count)
135 T_FAIL("Unsupported catch_mach_exception_raise_state_identity");
136 return KERN_NOT_SUPPORTED;
137 }
138
139 kern_return_t
catch_mach_exception_raise_state_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,__unused int * flavor,__unused thread_state_t old_state,__unused mach_msg_type_number_t old_state_count,__unused thread_state_t new_state,__unused mach_msg_type_number_t * new_state_count)140 catch_mach_exception_raise_state_identity_protected(
141 __unused mach_port_t exception_port,
142 uint64_t thread_id,
143 mach_port_t task_id_token,
144 exception_type_t exception,
145 mach_exception_data_t codes,
146 mach_msg_type_number_t codeCnt,
147 __unused int * flavor,
148 __unused thread_state_t old_state,
149 __unused mach_msg_type_number_t old_state_count,
150 __unused thread_state_t new_state,
151 __unused mach_msg_type_number_t * new_state_count)
152 {
153 #pragma unused(exception_port, thread_id, task_id_token, exception, codes, codeCnt)
154
155 T_FAIL("Unsupported catch_mach_exception_raise_state_identity_protected");
156 return KERN_NOT_SUPPORTED;
157 }
158
159 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)160 catch_mach_exception_raise_identity_protected(
161 __unused mach_port_t exception_port,
162 uint64_t thread_id,
163 mach_port_t task_id_token,
164 exception_type_t exception,
165 mach_exception_data_t codes,
166 mach_msg_type_number_t codeCnt)
167 {
168 #pragma unused(exception_port, thread_id, task_id_token)
169
170 T_ASSERT_GT_UINT(codeCnt, 1, "CodeCnt");
171
172 T_LOG("Caught %d codes", codeCnt);
173 T_LOG("Caught exception type: %d code[0]: 0x%llx code[1]:0x%llx", exception, codes[0], codes[1]);
174 exception_taken = exception;
175 if (exception == EXC_GUARD) {
176 received_exception_code = EXC_GUARD_DECODE_GUARD_FLAVOR((uint64_t)codes[0]);
177 } else {
178 T_FAIL("Unexpected exception");
179 }
180 return KERN_SUCCESS;
181 }
182
183 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)184 catch_mach_exception_raise(mach_port_t exception_port,
185 mach_port_t thread,
186 mach_port_t task,
187 exception_type_t exception,
188 mach_exception_data_t code,
189 mach_msg_type_number_t code_count)
190 {
191 #pragma unused(exception_port, thread, task, exception, code, code_count)
192 T_FAIL("Unsupported catch_mach_exception_raise_state_identity");
193 return KERN_NOT_SUPPORTED;
194 }
195
196 static void *
exception_server_thread(void * arg)197 exception_server_thread(void *arg)
198 {
199 kern_return_t kr;
200 mach_port_t exc_port = *(mach_port_t *)arg;
201
202 /* Handle exceptions on exc_port */
203 kr = mach_msg_server_once(mach_exc_server, 4096, exc_port, 0);
204 T_QUIET; T_EXPECT_MACH_SUCCESS(kr, "mach_msg_server_once");
205
206 return NULL;
207 }
208
209 static void
reply_port_defense(const bool thirdparty_hardened,int test_index,mach_exception_data_type_t expected_exception_code,bool triggers_exception)210 reply_port_defense(const bool thirdparty_hardened, int test_index, mach_exception_data_type_t expected_exception_code, bool triggers_exception)
211 {
212 /* reset exception code before running this test */
213 received_exception_code = 0;
214 int ret = 0;
215
216 uint32_t task_exc_guard = 0;
217 size_t te_size = sizeof(&task_exc_guard);
218
219 /* Test that the behavior is the same between these two */
220 char *test_prog_name = thirdparty_hardened ?
221 "./reply_port_defense_client_3P_hardened" : "./reply_port_defense_client";
222 char *child_args[MAX_ARGV];
223 pid_t client_pid = 0;
224 posix_spawnattr_t attrs;
225
226 pthread_t s_exc_thread;
227 mach_port_t exc_port;
228
229 T_LOG("Check if task_exc_guard exception has been enabled\n");
230 ret = sysctlbyname("kern.task_exc_guard_default", &task_exc_guard, &te_size, NULL, 0);
231 T_ASSERT_EQ(ret, 0, "sysctlbyname");
232
233 if (!(task_exc_guard & TASK_EXC_GUARD_MP_DELIVER)) {
234 T_SKIP("task_exc_guard exception is not enabled");
235 }
236
237 exc_port = alloc_exception_port();
238 T_QUIET; T_ASSERT_NE(exc_port, MACH_PORT_NULL, "Create a new exception port");
239
240 /* Create exception serving thread */
241 ret = pthread_create(&s_exc_thread, NULL, exception_server_thread, &exc_port);
242 T_QUIET; T_ASSERT_POSIX_SUCCESS(ret, "pthread_create exception_server_thread");
243
244 /* Initialize posix_spawn attributes */
245 posix_spawnattr_init(&attrs);
246
247 /*
248 * It is allowed for us to set an exception port because we are entitled test process.
249 * If you are using this code as an example for platform binaries,
250 * use `EXCEPTION_IDENTITY_PROTECTED` instead of `EXCEPTION_DEFAULT`
251 */
252 int err = posix_spawnattr_setexceptionports_np(&attrs, EXC_MASK_GUARD, exc_port,
253 (exception_behavior_t) (EXCEPTION_IDENTITY_PROTECTED | MACH_EXCEPTION_CODES), 0);
254 T_QUIET; T_ASSERT_POSIX_SUCCESS(err, "posix_spawnattr_setflags");
255
256 child_args[0] = test_prog_name;
257 char test_num[10];
258 sprintf(test_num, "%d", test_index);
259 child_args[1] = test_num;
260 child_args[2] = NULL;
261
262 T_LOG("========== Spawning new child ==========");
263 err = posix_spawn(&client_pid, child_args[0], NULL, &attrs, &child_args[0], environ);
264 T_ASSERT_POSIX_SUCCESS(err, "posix_spawn reply_port_defense_client = %d", client_pid);
265
266 int child_status;
267 /* Wait for child and check for exception */
268 if (-1 == waitpid(-1, &child_status, 0)) {
269 T_FAIL("%s waitpid: child", strerror(errno));
270 }
271 if (WIFEXITED(child_status) && WEXITSTATUS(child_status)) {
272 T_FAIL("Child exited with status = 0x%x", child_status);
273 }
274 sleep(1);
275 kill(1, SIGKILL);
276 if (triggers_exception) {
277 ret = pthread_join(s_exc_thread, NULL);
278 T_QUIET; T_ASSERT_POSIX_SUCCESS(ret, "pthread_join");
279 }
280
281 mach_port_deallocate(mach_task_self(), exc_port);
282
283 T_LOG("Exception code: Received code = 0x%llx Expected code = 0x%llx", received_exception_code, expected_exception_code);
284 T_EXPECT_EQ(received_exception_code, expected_exception_code, "Exception code: Received == Expected");
285 }
286
287 T_DECL(reply_port_defense,
288 "Test reply port semantics violations",
289 T_META_IGNORECRASHES(".*reply_port_defense_client.*"),
290 T_META_CHECK_LEAKS(false),
291 T_META_TAG_VM_PREFERRED,
292 T_META_ENABLED(!TARGET_OS_OSX && !TARGET_OS_BRIDGE)) {
293 if (ipc_hardening_disabled()) {
294 T_SKIP("hardening disabled due to boot-args");
295 }
296 bool triggers_exception = true;
297 mach_exception_data_type_t expected_exception_code = kGUARD_EXC_IMMOVABLE;
298 int test_num = 0;
299 int rp_defense_max_test_idx = 3;
300 /* Run the reply_port_defense tests 0, 1, 2 */
301 for (int i = test_num; i < rp_defense_max_test_idx; i++) {
302 reply_port_defense(true, i, expected_exception_code, triggers_exception);
303 reply_port_defense(false, i, expected_exception_code, triggers_exception);
304 }
305 reply_port_defense(true, 3, kGUARD_EXC_INVALID_RIGHT, triggers_exception);
306 reply_port_defense(false, 3, kGUARD_EXC_INVALID_RIGHT, triggers_exception);
307 }
308
309 T_DECL(test_unentitled_thread_set_exception_ports,
310 "thread_set_exception_ports should fail without an entitlement",
311 T_META_IGNORECRASHES(".*reply_port_defense_client.*"),
312 T_META_CHECK_LEAKS(false)) {
313 int test_num = 5;
314 mach_exception_data_type_t expected_exception_code = kGUARD_EXC_EXCEPTION_BEHAVIOR_ENFORCE;
315 bool triggers_exception = true;
316
317 if (ipc_hardening_disabled()) {
318 T_SKIP("hardening disabled due to boot-args");
319 }
320
321 reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
322 // reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
323 }
324
325 T_DECL(test_unentitled_thread_set_state,
326 "thread_set_state should fail without an entitlement",
327 T_META_IGNORECRASHES(".*reply_port_defense_client.*"),
328 T_META_CHECK_LEAKS(false),
329 T_META_ENABLED(false /* rdar://133955889 */))
330 {
331 int test_num = 6;
332 if (ipc_hardening_disabled()) {
333 T_SKIP("hardening disabled due to boot-args");
334 }
335 mach_exception_data_type_t expected_exception_code = kGUARD_EXC_THREAD_SET_STATE;
336 bool triggers_exception = true;
337
338 reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
339 reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
340 }
341
342 T_DECL(unentitled_set_exception_ports_pass,
343 "set_exception_ports should succeed",
344 T_META_IGNORECRASHES(".*reply_port_defense_client.*"),
345 T_META_CHECK_LEAKS(false)) {
346 int test_num = 7;
347 if (ipc_hardening_disabled()) {
348 T_SKIP("hardening disabled due to boot-args");
349 }
350 mach_exception_data_type_t expected_exception_code = kGUARD_EXC_NONE;
351 bool triggers_exception = false;
352 reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
353 reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
354 }
355
356
357 T_DECL(kobject_reply_port_defense,
358 "sending messages to kobjects without a proper reply port should crash",
359 T_META_IGNORECRASHES(".*reply_port_defense_client.*"),
360 T_META_TAG_VM_PREFERRED,
361 T_META_CHECK_LEAKS(false),
362 T_META_ENABLED(!TARGET_OS_OSX && !TARGET_OS_BRIDGE)) { /* disable on macOS due to BATS boot-args */
363 if (ipc_hardening_disabled()) {
364 T_SKIP("hardening disabled due to boot-args");
365 }
366 int test_num = 9;
367 mach_exception_data_type_t expected_exception_code = kGUARD_EXC_KOBJECT_REPLY_PORT_SEMANTICS;
368 bool triggers_exception = true;
369
370 reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
371 reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
372 }
373
374 T_DECL(test_alloc_weak_reply_port,
375 "1p is not allowed to create weak reply ports",
376 T_META_IGNORECRASHES(".*reply_port_defense_client.*"),
377 T_META_CHECK_LEAKS(false)) {
378 if (ipc_hardening_disabled()) {
379 T_SKIP("hardening disabled due to boot-args");
380 }
381
382 int test_num = 10;
383 mach_exception_data_type_t expected_exception_code;
384 bool triggers_exception = true;
385
386 #if TARGET_OS_OSX || TARGET_OS_BRIDGE
387 expected_exception_code = kGUARD_EXC_PROVISIONAL_REPLY_PORT;
388 #else
389 expected_exception_code = kGUARD_EXC_INVALID_MPO_ENTITLEMENT;
390 #endif /* TARGET_OS_OSX || TARGET_OS_BRIDGE */
391
392 /* rdar://136996362 (iOS+ telemetry for restricting 1P usage of provisional reply port) */
393 reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
394 reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
395 }
396
397 T_DECL(test_move_service_port,
398 "service ports are immovable",
399 T_META_IGNORECRASHES(".*reply_port_defense_client.*"),
400 T_META_CHECK_LEAKS(false)) {
401 int test_num = 11;
402 mach_exception_data_type_t expected_exception_code = kGUARD_EXC_SERVICE_PORT_VIOLATION_FATAL;
403 bool triggers_exception = true;
404
405 reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
406 reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
407 }
408
409
410 T_DECL(test_notification_policy,
411 "registering notifications on an mktimer crashes",
412 T_META_IGNORECRASHES(".*reply_port_defense_client.*"),
413 T_META_CHECK_LEAKS(false),
414 T_META_TAG_VM_PREFERRED,
415 T_META_ENABLED(!TARGET_OS_OSX && !TARGET_OS_BRIDGE)) { /* disable on macOS due to BATS boot-args */
416 if (ipc_hardening_disabled()) {
417 T_SKIP("hardening disabled due to boot-args");
418 }
419
420 mach_exception_data_type_t expected_exception_code = kGUARD_EXC_INVALID_NOTIFICATION_REQ;
421 bool triggers_exception = true;
422
423 int test_num = 12;
424 reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
425 reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
426
427 test_num = 13;
428 reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
429 reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
430
431 test_num = 14;
432 reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
433 reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
434 }
435
436
437 T_DECL(test_reply_port_extract_right_disallowed,
438 "mach_port_extract_right disallowed on reply port",
439 T_META_IGNORECRASHES(".*reply_port_defense_client.*"),
440 T_META_CHECK_LEAKS(false)) {
441 if (ipc_hardening_disabled()) {
442 T_SKIP("hardening disabled due to boot-args");
443 }
444
445 int test_num = 15;
446 mach_exception_data_type_t expected_exception_code = kGUARD_EXC_INVALID_RIGHT;
447 bool triggers_exception = true;
448
449 reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
450 reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
451 }
452
453 T_DECL(test_mach_task_self_send_movability,
454 "mach_task_self is immovable unless you have called ",
455 T_META_IGNORECRASHES(".*reply_port_defense_client.*"),
456 T_META_CHECK_LEAKS(false)) {
457 if (ipc_hardening_disabled()) {
458 T_SKIP("hardening disabled due to boot-args");
459 }
460
461 int test_num = 16;
462 mach_exception_data_type_t expected_exception_code = kGUARD_EXC_IMMOVABLE;
463 bool triggers_exception = true;
464
465 if (sip_disabled() || unrestricted_debugging()) {
466 /*
467 * see `proc_check_get_movable_control_port`:
468 * enforcement is always controlled by entitlements and
469 * unrestricted debugging boot-arg
470 * or if SIP is disabled
471 */
472 expected_exception_code = 0;
473 triggers_exception = false;
474 }
475
476 /*
477 * it should fail on reply_port_defense_client_3P_hardened because it doesn't
478 * have com.apple.security.get-movable-control-port
479 */
480 reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
481 test_num = 17; /* These tests crash the same way */
482 reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
483
484 /*
485 * it should succeed on reply_port_defense_client because it
486 * has com.apple.security.get-movable-control-port
487 */
488 test_num = 16;
489 expected_exception_code = 0;
490 triggers_exception = false;
491 reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
492 test_num = 17;
493 reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
494 }
495
496
497 T_DECL(test_send_immovability,
498 "ensure that send immovability is set on ports, even if they are not copied out",
499 T_META_IGNORECRASHES(".*reply_port_defense_client.*"),
500 T_META_CHECK_LEAKS(false)) {
501 /* attempt to move ports created by mach port construct */
502
503
504 /* test_move_newly_constructed_port_immovable_send */
505 int test_num = 18;
506 mach_exception_data_type_t expected_exception_code = kGUARD_EXC_IMMOVABLE;
507 bool triggers_exception = true;
508 reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
509 reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
510
511 /* test_move_special_reply_port */
512 test_num = 19;
513 expected_exception_code = kGUARD_EXC_IMMOVABLE;
514 triggers_exception = true;
515 reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
516 reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
517 }
518
519 T_DECL(test_reply_port_header_disposition,
520 "Ensure only make_send_once is allowed for reply port",
521 T_META_IGNORECRASHES(".*reply_port_defense_client.*"),
522 T_META_CHECK_LEAKS(false),
523 T_META_ENABLED(!TARGET_OS_OSX && !TARGET_OS_BRIDGE)) {
524 #if TARGET_OS_OSX || TARGET_OS_BRIDGE
525 T_SKIP("disabled on macos");
526 #endif
527 int test_num = 20;
528 mach_exception_data_type_t expected_exception_code = kGUARD_EXC_SEND_INVALID_REPLY;
529 bool triggers_exception = true;
530
531 reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
532 reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
533 }
534
535 T_DECL(test_service_port_as_exception_port,
536 "Ensure both service and weak service port can be used as exception port",
537 T_META_IGNORECRASHES(".*reply_port_defense_client.*"),
538 T_META_CHECK_LEAKS(false)) {
539 int test_num = 21;
540 mach_exception_data_type_t expected_exception_code = kGUARD_EXC_NONE;
541 bool triggers_exception = false;
542
543 reply_port_defense(true, test_num, expected_exception_code, triggers_exception);
544 reply_port_defense(false, test_num, expected_exception_code, triggers_exception);
545 }
546