[PATCH] D44339: [asan] poison_heap=0 should not disable __asan_handle_no_return.
Evgenii Stepanov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 12 14:51:26 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327337: [asan] poison_heap=0 should not disable __asan_handle_no_return. (authored by eugenis, committed by ).
Herald added a subscriber: delcypher.
Changed prior to commit:
https://reviews.llvm.org/D44339?vs=137872&id=138094#toc
Repository:
rL LLVM
https://reviews.llvm.org/D44339
Files:
compiler-rt/trunk/lib/asan/asan_poisoning.cc
compiler-rt/trunk/lib/asan/asan_poisoning.h
compiler-rt/trunk/test/asan/TestCases/handle_noreturn_bug.cc
Index: compiler-rt/trunk/test/asan/TestCases/handle_noreturn_bug.cc
===================================================================
--- compiler-rt/trunk/test/asan/TestCases/handle_noreturn_bug.cc
+++ compiler-rt/trunk/test/asan/TestCases/handle_noreturn_bug.cc
@@ -0,0 +1,13 @@
+// Regression test: __asan_handle_no_return should unpoison stack even with poison_heap=0.
+// RUN: %clangxx_asan -O0 %s -o %t && \
+// RUN: %env_asan_opts=poison_heap=1 %run %t && \
+// RUN: %env_asan_opts=poison_heap=0 %run %t
+
+#include <sanitizer/asan_interface.h>
+
+int main(int argc, char **argv) {
+ int x[2];
+ int * volatile p = &x[0];
+ __asan_handle_no_return();
+ int volatile z = p[2];
+}
Index: compiler-rt/trunk/lib/asan/asan_poisoning.cc
===================================================================
--- compiler-rt/trunk/lib/asan/asan_poisoning.cc
+++ compiler-rt/trunk/lib/asan/asan_poisoning.cc
@@ -32,7 +32,7 @@
}
void PoisonShadow(uptr addr, uptr size, u8 value) {
- if (!CanPoisonMemory()) return;
+ if (value && !CanPoisonMemory()) return;
CHECK(AddrIsAlignedByGranularity(addr));
CHECK(AddrIsInMem(addr));
CHECK(AddrIsAlignedByGranularity(addr + size));
Index: compiler-rt/trunk/lib/asan/asan_poisoning.h
===================================================================
--- compiler-rt/trunk/lib/asan/asan_poisoning.h
+++ compiler-rt/trunk/lib/asan/asan_poisoning.h
@@ -38,7 +38,7 @@
// performance-critical code with care.
ALWAYS_INLINE void FastPoisonShadow(uptr aligned_beg, uptr aligned_size,
u8 value) {
- DCHECK(CanPoisonMemory());
+ DCHECK(!value || CanPoisonMemory());
uptr shadow_beg = MEM_TO_SHADOW(aligned_beg);
uptr shadow_end = MEM_TO_SHADOW(
aligned_beg + aligned_size - SHADOW_GRANULARITY) + 1;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44339.138094.patch
Type: text/x-patch
Size: 1802 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180312/053a8ffc/attachment.bin>
More information about the llvm-commits
mailing list