5 #if __has_feature(ptrauth_calls) && !defined(__OPEN_SOURCE)
9 #include <darwintest.h>
12 static volatile int pass
;
13 static sigjmp_buf jbuf
;
16 action(int signo
, struct __siginfo
*info
, void *uap
__attribute__((unused
)))
19 pass
= (signo
== SIGBUS
&& info
->si_addr
== heap
);
24 T_DECL(nxheap
, "Non-executable heap", T_META_CHECK_LEAKS(false), T_META_ASROOT(true))
26 struct sigaction sa
= {
27 .__sigaction_u
.__sa_sigaction
= action
,
28 .sa_flags
= SA_SIGINFO
,
31 T_ASSERT_POSIX_ZERO(sigaction(SIGBUS
, &sa
, NULL
), NULL
);
33 if (sigsetjmp(jbuf
, 0)) {
38 T_QUIET
; T_ASSERT_NOTNULL((heap
= malloc(1)), NULL
);
40 *heap
= (char)0xc3; // retq
41 #if __has_feature(ptrauth_calls) && !defined(__OPEN_SOURCE)
42 heap
= ptrauth_sign_unauthenticated(heap
, ptrauth_key_function_pointer
, 0);
44 ((void (*)(void))heap
)(); // call *%eax