diff options
author | Yabin Cui <yabinc@google.com> | 2016-04-04 23:48:25 +0000 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2016-04-04 23:48:25 +0000 |
commit | e3f558ba141941363f32f996ba6f2b7d7b4a2ffb (patch) | |
tree | 633c5e92989ff7a73f15a2c2f83afa4887eac1ce | |
parent | 393b79ee00d5491ac720784ded3d00e229e204dc (diff) | |
download | bcm5719-llvm-e3f558ba141941363f32f996ba6f2b7d7b4a2ffb.tar.gz bcm5719-llvm-e3f558ba141941363f32f996ba6f2b7d7b4a2ffb.zip |
[tsan] Disable randomized address space on aarch64 linux.
Summary:
After patch https://lkml.org/lkml/2015/12/21/340 is introduced in
linux kernel, the random gap between stack and heap is increased
from 128M to 36G on 39-bit aarch64. And it is almost impossible
to cover this big range. So we need to disable randomized virtual
space on aarch64 linux.
Reviewers: llvm-commits, zatrazz, dvyukov, rengolin
Subscribers: aemerson, rengolin, tberghammer, danalbert, srhines
Differential Revision: http://reviews.llvm.org/D18526
llvm-svn: 265366
-rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc index 3e962fcf163..d85a53e0c0e 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc @@ -36,6 +36,7 @@ #include <string.h> #include <stdarg.h> #include <sys/mman.h> +#include <sys/personality.h> #include <sys/syscall.h> #include <sys/socket.h> #include <sys/time.h> @@ -291,6 +292,20 @@ void InitializePlatform() { SetAddressSpaceUnlimited(); reexec = true; } +#if defined(__aarch64__) + // After patch "arm64: mm: support ARCH_MMAP_RND_BITS." is introduced in + // linux kernel, the random gap between stack and mapped area is increased + // from 128M to 36G on 39-bit aarch64. As it is almost impossible to cover + // this big range, we should disable randomized virtual space on aarch64. + int old_personality = personality(0xffffffff); + if (old_personality != -1 && (old_personality & ADDR_NO_RANDOMIZE) == 0) { + VReport(1, "WARNING: Program is run with randomized virtual address " + "space, which wouldn't work with ThreadSanitizer.\n" + "Re-execing with fixed virtual address space.\n"); + CHECK_NE(personality(old_personality | ADDR_NO_RANDOMIZE), -1); + reexec = true; + } +#endif if (reexec) ReExec(); } |