summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Lettner <jlettner@apple.com>2019-07-15 20:22:27 +0000
committerJulian Lettner <jlettner@apple.com>2019-07-15 20:22:27 +0000
commit86475d75a5f3f6c0664c02dadd5d8d21e49e0764 (patch)
treefa61f5531ca4a00bae4b473b927fab7891289c0d
parenta1e6f4e36818256f13b968d90555789378da081f (diff)
downloadcompiler-rt-86475d75a5f3f6c0664c02dadd5d8d21e49e0764.tar.gz
[TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.9
Switch over to computing the xor key in C, instead of assembly for Linux/AArch64. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@366126 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/tsan/rtl/tsan_platform_linux.cc27
1 files changed, 5 insertions, 22 deletions
diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc
index 0f23da0e8..db85d547b 100644
--- a/lib/tsan/rtl/tsan_platform_linux.cc
+++ b/lib/tsan/rtl/tsan_platform_linux.cc
@@ -302,26 +302,8 @@ void InitializePlatform() {
CHECK_NE(personality(old_personality | ADDR_NO_RANDOMIZE), -1);
reexec = true;
}
- // Initialize the guard pointer used in {sig}{set,long}jump.
- longjmp_xor_key = InitializeGuardPtr();
- // uptr old_value = longjmp_xor_key;
- // InitializeLongjmpXorKey();
- // CHECK_EQ(longjmp_xor_key, old_value);
- // If the above check fails for you, please contact me (jlettner@apple.com)
- // and let me know the values of the two differing keys. Please also set a
- // breakpoint on `InitializeGuardPtr` and `InitializeLongjmpXorKey` and tell
- // me the stack pointer (SP) values that go into the XOR operation (where we
- // derive the key):
- //
- // InitializeLongjmpXorKey:
- // uptr sp = (uptr)__builtin_frame_address(0);
- //
- // InitializeGuardPtr (in tsan_rtl_aarch64.S):
- // mov x0, sp
- // ...
- // eor x0, x0, x1
- //
- // Then feel free to comment out the call to `InitializeLongjmpXorKey`.
+ // Initialize the xor key used in {sig}{set,long}jump.
+ InitializeLongjmpXorKey();
#endif
if (reexec)
ReExec();
@@ -437,9 +419,10 @@ static void InitializeLongjmpXorKey() {
jmp_buf env;
REAL(_setjmp)(env);
- // 2. Retrieve mangled/vanilla SP.
+ // 2. Retrieve vanilla/mangled SP.
+ uptr sp;
+ asm("mov %0, %%sp" : "=r" (sp));
uptr mangled_sp = ((uptr *)&env)[LONG_JMP_SP_ENV_SLOT];
- uptr sp = (uptr)__builtin_frame_address(0);
// 3. xor SPs to obtain key.
longjmp_xor_key = mangled_sp ^ sp;