[compiler-rt] r366126 - [TSan] Improve handling of stack pointer mangling in {set, long}jmp, pt.9
Julian Lettner via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 15 13:22:27 PDT 2019
Author: yln
Date: Mon Jul 15 13:22:27 2019
New Revision: 366126
URL: http://llvm.org/viewvc/llvm-project?rev=366126&view=rev
Log:
[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.
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc?rev=366126&r1=366125&r2=366126&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc Mon Jul 15 13:22:27 2019
@@ -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 at 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;
More information about the llvm-commits
mailing list