[PATCH] D23481: [Asan] Unpoison red zones even if use-after-scope was disabled with runtime flag

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 16 09:32:08 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL278818: [Asan] Unpoison red zones even if use-after-scope was disabled with runtime flag (authored by vitalybuka).

Changed prior to commit:
  https://reviews.llvm.org/D23481?vs=68097&id=68201#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23481

Files:
  llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/trunk/test/Instrumentation/AddressSanitizer/lifetime-uar-uas.ll
  llvm/trunk/test/Instrumentation/AddressSanitizer/lifetime.ll

Index: llvm/trunk/test/Instrumentation/AddressSanitizer/lifetime-uar-uas.ll
===================================================================
--- llvm/trunk/test/Instrumentation/AddressSanitizer/lifetime-uar-uas.ll
+++ llvm/trunk/test/Instrumentation/AddressSanitizer/lifetime-uar-uas.ll
@@ -28,9 +28,9 @@
   ; CHECK-UAS: call void @__asan_poison_stack_memory(i64 %{{[^ ]+}}, i64 1)
 
   ; Unpoison memory at function exit in UAS mode.
-  ; CHECK-UAS: call void @__asan_unpoison_stack_memory(i64 %{{[^ ]+}}, i64 64)
-  ; CHECK-UAS: ret void
-
+  ; CHECK-UAS: store i64 0
+  ; CHECK-UAS-NEXT: call void @__asan_unpoison_stack_memory(i64 %{{[^ ]+}}, i64 64)
+  ; CHECK-UAS: ret i32 0
   ret i32 0
 }
 
Index: llvm/trunk/test/Instrumentation/AddressSanitizer/lifetime.ll
===================================================================
--- llvm/trunk/test/Instrumentation/AddressSanitizer/lifetime.ll
+++ llvm/trunk/test/Instrumentation/AddressSanitizer/lifetime.ll
@@ -108,7 +108,11 @@
   ; CHECK: __asan_poison_stack_memory
 
   ret void
-  ; CHECK: __asan_unpoison_stack_memory
+  ; CHECK: store i64 0
+  ; CHECK: store i64 0
+  ; CHECK: store i64 0
+  ; CHECK: store i32 0
+  ; CHECK-NEXT: __asan_unpoison_stack_memory
 }
 
 define void @zero_sized(i64 %a) #0 {
Index: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -2186,12 +2186,13 @@
   poisonRedZones(L.ShadowBytes, IRB, ShadowBase, true);
 
   auto UnpoisonStack = [&](IRBuilder<> &IRB) {
+    // Do this always as poisonAlloca can be disabled with
+    // detect_stack_use_after_scope=0.
+    poisonRedZones(L.ShadowBytes, IRB, ShadowBase, false);
     if (HavePoisonedStaticAllocas) {
       // If we poisoned some allocas in llvm.lifetime analysis,
       // unpoison whole stack frame now.
       poisonAlloca(LocalStackBase, LocalStackSize, IRB, false);
-    } else {
-      poisonRedZones(L.ShadowBytes, IRB, ShadowBase, false);
     }
   };
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23481.68201.patch
Type: text/x-patch
Size: 2132 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160816/dea32716/attachment.bin>


More information about the llvm-commits mailing list