1*27b03b36SApple OSS Distributions #include <errno.h> 2*27b03b36SApple OSS Distributions #include <pthread.h> 3*27b03b36SApple OSS Distributions #include <signal.h> 4*27b03b36SApple OSS Distributions #include <stdio.h> 5*27b03b36SApple OSS Distributions #include <string.h> 6*27b03b36SApple OSS Distributions #include <unistd.h> 7*27b03b36SApple OSS Distributions 8*27b03b36SApple OSS Distributions #include <mach/mach.h> 9*27b03b36SApple OSS Distributions #include <mach/mach_traps.h> 10*27b03b36SApple OSS Distributions #include <mach/mach_types.h> 11*27b03b36SApple OSS Distributions 12*27b03b36SApple OSS Distributions #include <darwintest.h> 13*27b03b36SApple OSS Distributions #include <darwintest_utils.h> 14*27b03b36SApple OSS Distributions 15*27b03b36SApple OSS Distributions #include <sys/kern_debug.h> 16*27b03b36SApple OSS Distributions 17*27b03b36SApple OSS Distributions T_GLOBAL_META( 18*27b03b36SApple OSS Distributions T_META_NAMESPACE("xnu.debug"), 19*27b03b36SApple OSS Distributions T_META_RADAR_COMPONENT_NAME("xnu"), 20*27b03b36SApple OSS Distributions T_META_RADAR_COMPONENT_VERSION("arm"), 21*27b03b36SApple OSS Distributions T_META_OWNER("joster"), 22*27b03b36SApple OSS Distributions T_META_ENABLED(FALSE) 23*27b03b36SApple OSS Distributions ); 24*27b03b36SApple OSS Distributions 25*27b03b36SApple OSS Distributions T_DECL(debug_enable_syscall_rejection, 26*27b03b36SApple OSS Distributions "Verify that syscall rejection works") 27*27b03b36SApple OSS Distributions { 28*27b03b36SApple OSS Distributions syscall_rejection_selector_t masks[] = { 29*27b03b36SApple OSS Distributions SYSCALL_REJECTION_ALLOW(SYSCALL_REJECTION_ALL), 30*27b03b36SApple OSS Distributions SYSCALL_REJECTION_DENY(2) 31*27b03b36SApple OSS Distributions }; 32*27b03b36SApple OSS Distributions 33*27b03b36SApple OSS Distributions int ret = debug_syscall_reject(masks, 2); 34*27b03b36SApple OSS Distributions 35*27b03b36SApple OSS Distributions T_WITH_ERRNO; T_ASSERT_POSIX_SUCCESS(ret, "debug_syscall_reject"); 36*27b03b36SApple OSS Distributions 37*27b03b36SApple OSS Distributions ret = chdir("/tmp"); 38*27b03b36SApple OSS Distributions 39*27b03b36SApple OSS Distributions printf("chdir: %i\n", ret); 40*27b03b36SApple OSS Distributions } 41