diff options
author | Alexander Potapenko <glider@google.com> | 2013-07-04 10:16:12 +0000 |
---|---|---|
committer | Alexander Potapenko <glider@google.com> | 2013-07-04 10:16:12 +0000 |
commit | d0c91acb58cfa04a43094a6d4be1b02da41b7c3a (patch) | |
tree | 592ce8f063e1ed5eb1ffa568570300f4ab39d406 /compiler-rt/lib/asan/asan_malloc_mac.cc | |
parent | 39f7488294bf2bbe6d9babd681bddcd854198239 (diff) | |
download | bcm5719-llvm-d0c91acb58cfa04a43094a6d4be1b02da41b7c3a.tar.gz bcm5719-llvm-d0c91acb58cfa04a43094a6d4be1b02da41b7c3a.zip |
[ASan] Do not protect the malloc zone created by malloc_zone_create() on Snow Leopard and earlier systems.
Fixes https://code.google.com/p/address-sanitizer/issues/detail?id=208
llvm-svn: 185621
Diffstat (limited to 'compiler-rt/lib/asan/asan_malloc_mac.cc')
-rw-r--r-- | compiler-rt/lib/asan/asan_malloc_mac.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler-rt/lib/asan/asan_malloc_mac.cc b/compiler-rt/lib/asan/asan_malloc_mac.cc index 89e14714106..f9f08f0201c 100644 --- a/compiler-rt/lib/asan/asan_malloc_mac.cc +++ b/compiler-rt/lib/asan/asan_malloc_mac.cc @@ -50,9 +50,12 @@ INTERCEPTOR(malloc_zone_t *, malloc_create_zone, &stack, FROM_MALLOC); internal_memcpy(new_zone, &asan_zone, sizeof(asan_zone)); new_zone->zone_name = NULL; // The name will be changed anyway. - // Prevent the client app from overwriting the zone contents. - // Library functions that need to modify the zone will set PROT_WRITE on it. - mprotect(new_zone, allocated_size, PROT_READ); + if (GetMacosVersion() >= MACOS_VERSION_LION) { + // Prevent the client app from overwriting the zone contents. + // Library functions that need to modify the zone will set PROT_WRITE on it. + // This matches the behavior of malloc_create_zone() on OSX 10.7 and higher. + mprotect(new_zone, allocated_size, PROT_READ); + } return new_zone; } |