[PATCH] D23616: [Asan] Add __asan_memset_real to allow poisoning shadow directly from instrumented code

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 17 11:27:12 PDT 2016


vitalybuka updated this revision to Diff 68388.
vitalybuka added a comment.

clang format


https://reviews.llvm.org/D23616

Files:
  lib/asan/asan_interface_internal.h
  lib/asan/asan_poisoning.cc
  lib/asan/asan_rtl.cc
  lib/asan/asan_win_dll_thunk.cc

Index: lib/asan/asan_win_dll_thunk.cc
===================================================================
--- lib/asan/asan_win_dll_thunk.cc
+++ lib/asan/asan_win_dll_thunk.cc
@@ -261,6 +261,8 @@
 INTERFACE_FUNCTION(__asan_memset);
 INTERFACE_FUNCTION(__asan_memmove);
 
+INTERFACE_FUNCTION(__asan_memset_real);
+
 INTERFACE_FUNCTION(__asan_alloca_poison);
 INTERFACE_FUNCTION(__asan_allocas_unpoison);
 
Index: lib/asan/asan_rtl.cc
===================================================================
--- lib/asan/asan_rtl.cc
+++ lib/asan/asan_rtl.cc
@@ -264,6 +264,7 @@
   volatile int fake_condition = 0;  // prevent dead condition elimination.
   // __asan_report_* functions are noreturn, so we need a switch to prevent
   // the compiler from removing any of them.
+  // clang-format off
   switch (fake_condition) {
     case 1: __asan_report_load1(0); break;
     case 2: __asan_report_load2(0); break;
@@ -303,7 +304,9 @@
     case 37: __asan_unpoison_stack_memory(0, 0); break;
     case 38: __asan_region_is_poisoned(0, 0); break;
     case 39: __asan_describe_address(0); break;
+    case 40: __asan_memset_real(0, 0, 0); break;
   }
+  // clang-format on
 }
 
 static void asan_atexit() {
Index: lib/asan/asan_poisoning.cc
===================================================================
--- lib/asan/asan_poisoning.cc
+++ lib/asan/asan_poisoning.cc
@@ -314,6 +314,10 @@
   }
 }
 
+void __asan_memset_real(uptr addr, u8 c, uptr size) {
+  REAL(memset)((void *)addr, c, size);
+}
+
 void __asan_poison_stack_memory(uptr addr, uptr size) {
   if (!__asan_option_detect_stack_use_after_scope) return;
   VReport(1, "poisoning: %p %zx\n", (void *)addr, size);
Index: lib/asan/asan_interface_internal.h
===================================================================
--- lib/asan/asan_interface_internal.h
+++ lib/asan/asan_interface_internal.h
@@ -79,6 +79,10 @@
   SANITIZER_INTERFACE_ATTRIBUTE
   void __asan_after_dynamic_init();
 
+  // Calls real memset with no mapping or checks.
+  SANITIZER_INTERFACE_ATTRIBUTE
+  void __asan_memset_real(uptr addr, u8 value, uptr size);
+
   // These two functions are used by instrumented code in the
   // use-after-scope mode. They mark memory for local variables as
   // unaddressable when they leave scope and addressable before the


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23616.68388.patch
Type: text/x-patch
Size: 2296 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160817/9e49a960/attachment.bin>


More information about the llvm-commits mailing list