[msan] Remove non-working MSAN_LINUX_X86_64_OLD_MAPPING
authorFangrui Song <i@maskray.me>
Sat, 31 Dec 2022 03:43:19 +0000 (19:43 -0800)
committerFangrui Song <i@maskray.me>
Sat, 31 Dec 2022 03:43:19 +0000 (19:43 -0800)
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.

compiler-rt/lib/msan/msan.h
compiler-rt/lib/msan/msan_allocator.cpp
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

index 3d53f90..5d8ea52 100644 (file)
@@ -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"
index 051a9cb..53f47bd 100644 (file)
@@ -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;
index e9939c9..ff65400 100644 (file)
@@ -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