[TSan] Support pointer authentication in setjmp/longjmp interceptors

arm64e adds support for pointer authentication, which was adopted by
libplatform to harden setjmp/longjmp and friends.  We need to teach
the TSan interceptors for those functions about this.

Reviewed By: kubamracek

Differential Revision: https://reviews.llvm.org/D76257
This commit is contained in:
Julian Lettner 2020-03-16 11:27:15 -07:00
parent e009fad342
commit f8e8f0a603
1 changed files with 8 additions and 0 deletions

View File

@ -41,6 +41,10 @@
#include <errno.h>
#include <sched.h>
#if __has_feature(ptrauth_calls)
#include <ptrauth.h>
#endif
namespace __tsan {
#if !SANITIZER_GO
@ -274,6 +278,10 @@ void InitializePlatform() {
uptr ExtractLongJmpSp(uptr *env) {
uptr mangled_sp = env[LONG_JMP_SP_ENV_SLOT];
uptr sp = mangled_sp ^ longjmp_xor_key;
#if __has_feature(ptrauth_calls)
sp = (uptr)ptrauth_auth_data((void *)sp, ptrauth_key_asdb,
ptrauth_string_discriminator("sp"));
#endif
return sp;
}