Skip to content

Commit b45b55f

Browse files
committed
[compiler-rt] Fix interceptors with BTI and PAC
On AArch64 with BTI and/or PAC, we have to prefix the function body with the appropriate hints/checks. PACIASP is an implicit branch target identification instructions which is equivalent to BTI c.
1 parent 17162b6 commit b45b55f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

compiler-rt/lib/interception/interception.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ const interpose_substitution substitution_##func_name[] \
205205
ASM_TYPE_FUNCTION_STR "\n" \
206206
SANITIZER_STRINGIFY(TRAMPOLINE(func)) ":\n" \
207207
SANITIZER_STRINGIFY(CFI_STARTPROC) "\n" \
208+
SANITIZER_STRINGIFY(ASM_PAC_STARTPROC) "\n" \
208209
C_ASM_TAIL_CALL(SANITIZER_STRINGIFY(TRAMPOLINE(func)), \
209210
"__interceptor_" \
210211
SANITIZER_STRINGIFY(ASM_PREEMPTIBLE_SYM(func))) "\n" \

compiler-rt/lib/sanitizer_common/sanitizer_asm.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@
4242
# define CFI_RESTORE(reg)
4343
#endif
4444

45+
#if defined(__aarch64__)
46+
# define ASM_PAC_STARTPROC paciasp
47+
#else
48+
# define ASM_PAC_STARTPROC
49+
#endif
50+
4551
#if defined(__x86_64__) || defined(__i386__) || defined(__sparc__)
4652
# define ASM_TAIL_CALL jmp
4753
#elif defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
@@ -115,6 +121,7 @@
115121
ASM_TYPE_FUNCTION(__interceptor_trampoline_##name); \
116122
__interceptor_trampoline_##name: \
117123
CFI_STARTPROC; \
124+
ASM_PAC_STARTPROC; \
118125
ASM_TAIL_CALL ASM_PREEMPTIBLE_SYM(__interceptor_##name); \
119126
CFI_ENDPROC; \
120127
ASM_SIZE(__interceptor_trampoline_##name)

0 commit comments

Comments
 (0)