diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-03-17 23:00:53 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-03-17 23:00:53 +0000 |
commit | d400b58b60028b66eee1ae751fc4983a07946275 (patch) | |
tree | 9d0fa3e8914b318787dc8e2f87a09fe56c2489f0 | |
parent | b172c62c0c69194327fe52f0cc507ec7fee0df09 (diff) | |
parent | af2f109a9c6371bf7f7a5a88ba963b0cd1413357 (diff) | |
download | bionic-android12-qpr3-s6-release.tar.gz |
Snap for 8316345 from af2f109a9c6371bf7f7a5a88ba963b0cd1413357 to sc-qpr3-releaseandroid-12.1.0_r9android-12.1.0_r8android-12.1.0_r7android-12.1.0_r22android-12.1.0_r21android-12.1.0_r20android-12.1.0_r19android-12.1.0_r11android-12.1.0_r10android12-qpr3-s7-releaseandroid12-qpr3-s6-releaseandroid12-qpr3-s5-releaseandroid12-qpr3-s4-releaseandroid12-qpr3-s3-releaseandroid12-qpr3-s2-releaseandroid12-qpr3-s1-releaseandroid12-qpr3-release
Change-Id: I63d045c54b64f785a1cc95e1cc2d8e40f551f03c
-rw-r--r-- | libc/bionic/pthread_create.cpp | 5 | ||||
-rw-r--r-- | libc/platform/bionic/pac.h | 46 |
2 files changed, 3 insertions, 48 deletions
diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp index 08fb187dc..121b26f82 100644 --- a/libc/bionic/pthread_create.cpp +++ b/libc/bionic/pthread_create.cpp @@ -45,7 +45,6 @@ #include "private/bionic_defs.h" #include "private/bionic_globals.h" #include "platform/bionic/macros.h" -#include "platform/bionic/pac.h" #include "private/bionic_ssp.h" #include "private/bionic_systrace.h" #include "private/bionic_tls.h" @@ -332,9 +331,11 @@ void __set_stack_and_tls_vma_name(bool is_main_thread) { extern "C" int __rt_sigprocmask(int, const sigset64_t*, sigset64_t*, size_t); __attribute__((no_sanitize("hwaddress"))) +#ifdef __aarch64__ // This function doesn't return, but it does appear in stack traces. Avoid using return PAC in this // function because we may end up resetting IA, which may confuse unwinders due to mismatching keys. -__BIONIC_DISABLE_PAUTH +__attribute__((target("branch-protection=bti"))) +#endif static int __pthread_start(void* arg) { pthread_internal_t* thread = reinterpret_cast<pthread_internal_t*>(arg); diff --git a/libc/platform/bionic/pac.h b/libc/platform/bionic/pac.h index 111460818..34efc48ae 100644 --- a/libc/platform/bionic/pac.h +++ b/libc/platform/bionic/pac.h @@ -29,7 +29,6 @@ #pragma once #include <stddef.h> -#include <sys/prctl.h> inline uintptr_t __bionic_clear_pac_bits(uintptr_t ptr) { #if defined(__aarch64__) @@ -41,48 +40,3 @@ inline uintptr_t __bionic_clear_pac_bits(uintptr_t ptr) { return ptr; #endif } - -#ifdef __aarch64__ -// The default setting for branch-protection enables both PAC and BTI, so by -// overriding it to only enable BTI we disable PAC. -#define __BIONIC_DISABLE_PAUTH __attribute__((target("branch-protection=bti"))) -#else -#define __BIONIC_DISABLE_PAUTH -#endif - -#ifdef __aarch64__ - -#ifndef PR_PAC_SET_ENABLED_KEYS -#define PR_PAC_SET_ENABLED_KEYS 60 -#endif - -#ifndef PR_PAC_GET_ENABLED_KEYS -#define PR_PAC_GET_ENABLED_KEYS 61 -#endif - -// Disable PAC (i.e. make the signing and authentication instructions into no-ops) for the lifetime -// of this object. -class ScopedDisablePAC { - int prev_enabled_keys_; - - public: - // Disabling IA will invalidate the return address in this function if it is signed, so we need to - // make sure that this function does not sign its return address. Likewise for the destructor. - __BIONIC_DISABLE_PAUTH - ScopedDisablePAC() { - // These prctls will fail (resulting in a no-op, the intended behavior) if PAC is not supported. - prev_enabled_keys_ = prctl(PR_PAC_GET_ENABLED_KEYS, 0, 0, 0, 0); - prctl(PR_PAC_SET_ENABLED_KEYS, prev_enabled_keys_, 0, 0, 0); - } - - __BIONIC_DISABLE_PAUTH - ~ScopedDisablePAC() { - prctl(PR_PAC_SET_ENABLED_KEYS, prev_enabled_keys_, prev_enabled_keys_, 0, 0); - } -}; -#else -struct ScopedDisablePAC { - // Silence unused variable warnings in non-aarch64 builds. - ScopedDisablePAC() {} -}; -#endif |