diff options
-rw-r--r-- | compiler-rt/lib/asan/asan_interceptors.cc | 2 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_mapping.h | 12 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_poisoning.cc | 11 |
3 files changed, 14 insertions, 11 deletions
diff --git a/compiler-rt/lib/asan/asan_interceptors.cc b/compiler-rt/lib/asan/asan_interceptors.cc index db812072080..b0c9a5eee3f 100644 --- a/compiler-rt/lib/asan/asan_interceptors.cc +++ b/compiler-rt/lib/asan/asan_interceptors.cc @@ -64,7 +64,7 @@ namespace __asan { // Instruments read/write access to a single byte in memory. // On error calls __asan_report_error, which aborts the program. static NOINLINE void AccessAddress(uintptr_t address, bool isWrite) { - if (__asan_address_is_poisoned((void*)address)) { + if (AddressIsPoisoned(address)) { GET_BP_PC_SP; __asan_report_error(pc, bp, sp, address, isWrite, /* access_size */ 1); } diff --git a/compiler-rt/lib/asan/asan_mapping.h b/compiler-rt/lib/asan/asan_mapping.h index 63aba10a22f..4824bf109b2 100644 --- a/compiler-rt/lib/asan/asan_mapping.h +++ b/compiler-rt/lib/asan/asan_mapping.h @@ -95,6 +95,18 @@ static inline bool AddrIsAlignedByGranularity(uintptr_t a) { return (a & (SHADOW_GRANULARITY - 1)) == 0; } +static inline bool AddressIsPoisoned(uintptr_t a) { + const size_t kAccessSize = 1; + uint8_t *shadow_address = (uint8_t*)MemToShadow(a); + int8_t shadow_value = *shadow_address; + if (shadow_value) { + uint8_t last_accessed_byte = (a & (SHADOW_GRANULARITY - 1)) + + kAccessSize - 1; + return (last_accessed_byte >= shadow_value); + } + return false; +} + } // namespace __asan #endif // ASAN_MAPPING_H diff --git a/compiler-rt/lib/asan/asan_poisoning.cc b/compiler-rt/lib/asan/asan_poisoning.cc index dab1bf904d0..69ee34aae50 100644 --- a/compiler-rt/lib/asan/asan_poisoning.cc +++ b/compiler-rt/lib/asan/asan_poisoning.cc @@ -147,14 +147,5 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size) { } bool __asan_address_is_poisoned(void const volatile *addr) { - const size_t kAccessSize = 1; - uintptr_t address = (uintptr_t)addr; - uint8_t *shadow_address = (uint8_t*)MemToShadow(address); - int8_t shadow_value = *shadow_address; - if (shadow_value) { - uint8_t last_accessed_byte = (address & (SHADOW_GRANULARITY - 1)) - + kAccessSize - 1; - return (last_accessed_byte >= shadow_value); - } - return false; + return __asan::AddressIsPoisoned((uintptr_t)addr); } |