Skip to content

Commit 19bbbcb

Browse files
authored
[sanitizer_common] Change allocator base in test case for compatibili… (#93234)
…ty with high-entropy ASLR With high-entropy ASLR (e.g., 32-bits == 16TB), the allocator base of 0x700000000000 (112TB) may collide with the placement of the libraries (e.g., on Linux, the mmap base could be 128TB - 16TB == 112TB). This results in a segfault in the test case. This patch moves the allocator base below the PIE program segment, inspired by fb77ca0. As per that patch: 1) we are leaving the old behavior for Apple 2) since ASLR cannot be set above 32-bits for x86-64 Linux, we expect this new layout to be durable. Note that this is only changing a test case, not the behavior of sanitizers. Sanitizers have their own settings for initializing the allocator base. Reproducer: 1. ninja check-sanitizer # Just to build the test binary needed below; no need to actually run the tests here 2. sudo sysctl vm.mmap_rnd_bits=32 # Increase ASLR entropy 3. for f in `seq 1 10000`; do echo $f; GTEST_FILTER=*SizeClassAllocator64Dense ./projects/compiler-rt/lib/sanitizer_common/tests/Sanitizer-x86_64-Test > /tmp/x; if [ $? -ne 0 ]; then cat /tmp/x; fi; done
1 parent b186142 commit 19bbbcb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,17 @@ const uptr kAllocatorSpace = ~(uptr)0;
6969
const uptr kAllocatorSize = 0x2000000000ULL; // 128G.
7070
static const u64 kAddressSpaceSize = 1ULL << 38;
7171
typedef VeryDenseSizeClassMap SizeClassMap;
72-
#else
72+
# elif SANITIZER_APPLE
7373
static const uptr kAllocatorSpace = 0x700000000000ULL;
7474
static const uptr kAllocatorSize = 0x010000000000ULL; // 1T.
7575
static const u64 kAddressSpaceSize = 1ULL << 47;
7676
typedef DefaultSizeClassMap SizeClassMap;
77-
#endif
77+
# else
78+
static const uptr kAllocatorSpace = 0x500000000000ULL;
79+
static const uptr kAllocatorSize = 0x010000000000ULL; // 1T.
80+
static const u64 kAddressSpaceSize = 1ULL << 47;
81+
typedef DefaultSizeClassMap SizeClassMap;
82+
# endif
7883

7984
template <typename AddressSpaceViewTy>
8085
struct AP64 { // Allocator Params. Short name for shorter demangled names..

0 commit comments

Comments
 (0)