[compiler-rt] 99fc4d3 - [msan] Remove non-working MSAN_LINUX_X86_64_OLD_MAPPING
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 30 19:43:23 PST 2022
Author: Fangrui Song
Date: 2022-12-30T19:43:19-08:00
New Revision: 99fc4d3d1636c81dad5b9c9c4537347c44fa5065
URL: https://github.com/llvm/llvm-project/commit/99fc4d3d1636c81dad5b9c9c4537347c44fa5065
DIFF: https://github.com/llvm/llvm-project/commit/99fc4d3d1636c81dad5b9c9c4537347c44fa5065.diff
LOG: [msan] Remove non-working MSAN_LINUX_X86_64_OLD_MAPPING
r249754 (2015) added this macro (not set anywhere) for an escape hatch.
This old layout has been non-working for many years (Linux
arch/x86/include/asm/elf.h ELF_ET_DYN_BASE is outside the APP range):
FATAL: Code 0x558547327980 is out of application range. Non-PIE build?
FATAL: MemorySanitizer can not mmap the shadow memory.
FATAL: Make sure to compile with -fPIE and to link with -pie.
FATAL: Disabling ASLR is known to cause this error.
FATAL: If running under GDB, try 'set disable-randomization off'.
Non-pie doesn't work either.
Added:
Modified:
compiler-rt/lib/msan/msan.h
compiler-rt/lib/msan/msan_allocator.cpp
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/msan/msan.h b/compiler-rt/lib/msan/msan.h
index 3d53f90b9a60f..5d8ea52668abe 100644
--- a/compiler-rt/lib/msan/msan.h
+++ b/compiler-rt/lib/msan/msan.h
@@ -170,19 +170,6 @@ const MappingDesc kMemoryLayout[] = {
#elif SANITIZER_NETBSD || (SANITIZER_LINUX && SANITIZER_WORDSIZE == 64)
-#ifdef MSAN_LINUX_X86_64_OLD_MAPPING
-// Requires PIE binary and ASLR enabled.
-// Main thread stack and DSOs at 0x7f0000000000 (sometimes 0x7e0000000000).
-// Heap at 0x600000000000.
-const MappingDesc kMemoryLayout[] = {
- {0x000000000000ULL, 0x200000000000ULL, MappingDesc::INVALID, "invalid"},
- {0x200000000000ULL, 0x400000000000ULL, MappingDesc::SHADOW, "shadow"},
- {0x400000000000ULL, 0x600000000000ULL, MappingDesc::ORIGIN, "origin"},
- {0x600000000000ULL, 0x800000000000ULL, MappingDesc::APP, "app"}};
-
-#define MEM_TO_SHADOW(mem) (((uptr)(mem)) & ~0x400000000000ULL)
-#define SHADOW_TO_ORIGIN(mem) (((uptr)(mem)) + 0x200000000000ULL)
-#else // MSAN_LINUX_X86_64_OLD_MAPPING
// All of the following configurations are supported.
// ASLR disabled: main executable and DSOs at 0x555550000000
// PIE and ASLR: main executable and DSOs at 0x7f0000000000
@@ -203,7 +190,6 @@ const MappingDesc kMemoryLayout[] = {
{0x700000000000ULL, 0x800000000000ULL, MappingDesc::APP, "app-3"}};
#define MEM_TO_SHADOW(mem) (((uptr)(mem)) ^ 0x500000000000ULL)
#define SHADOW_TO_ORIGIN(mem) (((uptr)(mem)) + 0x100000000000ULL)
-#endif // MSAN_LINUX_X86_64_OLD_MAPPING
#else
#error "Unsupported platform"
diff --git a/compiler-rt/lib/msan/msan_allocator.cpp b/compiler-rt/lib/msan/msan_allocator.cpp
index 051a9cbed549e..53f47bde67f39 100644
--- a/compiler-rt/lib/msan/msan_allocator.cpp
+++ b/compiler-rt/lib/msan/msan_allocator.cpp
@@ -59,8 +59,7 @@ struct AP32 {
};
typedef SizeClassAllocator32<AP32> PrimaryAllocator;
#elif defined(__x86_64__)
-#if SANITIZER_NETBSD || \
- (SANITIZER_LINUX && !defined(MSAN_LINUX_X86_64_OLD_MAPPING))
+#if SANITIZER_NETBSD || SANITIZER_LINUX
static const uptr kAllocatorSpace = 0x700000000000ULL;
#else
static const uptr kAllocatorSpace = 0x600000000000ULL;
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index e9939c9cbe1ea..ff65400c62e44 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -396,17 +396,10 @@ static const MemoryMapParams Linux_I386_MemoryMapParams = {
// x86_64 Linux
static const MemoryMapParams Linux_X86_64_MemoryMapParams = {
-#ifdef MSAN_LINUX_X86_64_OLD_MAPPING
- 0x400000000000, // AndMask
- 0, // XorMask (not used)
- 0, // ShadowBase (not used)
- 0x200000000000, // OriginBase
-#else
0, // AndMask (not used)
0x500000000000, // XorMask
0, // ShadowBase (not used)
0x100000000000, // OriginBase
-#endif
};
// mips64 Linux
More information about the llvm-commits
mailing list