[compiler-rt] r185621 - [ASan] Do not protect the malloc zone created by malloc_zone_create() on Snow Leopard and earlier systems.
Alexander Potapenko
glider at google.com
Thu Jul 4 03:16:12 PDT 2013
Author: glider
Date: Thu Jul 4 05:16:12 2013
New Revision: 185621
URL: http://llvm.org/viewvc/llvm-project?rev=185621&view=rev
Log:
[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
Modified:
compiler-rt/trunk/lib/asan/asan_malloc_mac.cc
Modified: compiler-rt/trunk/lib/asan/asan_malloc_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_malloc_mac.cc?rev=185621&r1=185620&r2=185621&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_malloc_mac.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_malloc_mac.cc Thu Jul 4 05:16:12 2013
@@ -50,9 +50,12 @@ INTERCEPTOR(malloc_zone_t *, malloc_crea
&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;
}
More information about the llvm-commits
mailing list