libsanitizer: add flag to control default value of calls forwarding. 86/210786/15
authorSlava Barinov <v.barinov@samsung.com>
Wed, 3 Jul 2019 13:21:19 +0000 (16:21 +0300)
committerDongkyun Son <dongkyun.s@samsung.com>
Sat, 27 Jul 2019 16:41:27 +0000 (16:41 +0000)
    * libsanitizer/sanitizer_common/sanitizer_flags.inc: declare flag
    enable_interceptors
    * libsanitizer/asan/asan_interceptors.cc: disable interceptors if
    needed
    * libsanitizer/asan/asan_flags.cc: report if interceptors are
    disabled

Change-Id: I481c519a7568d3b56a9bfa757994aa3b3c2a94d1
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
Signed-off-by: Andrey Drobyshev <a.drobyshev@samsung.com>
libsanitizer/asan/asan_flags.cc
libsanitizer/asan/asan_interceptors.cc
libsanitizer/sanitizer_common/sanitizer_flags.inc

index 6639841..9f7b3db 100644 (file)
@@ -19,6 +19,7 @@
 #include "sanitizer_common/sanitizer_common.h"
 #include "sanitizer_common/sanitizer_flags.h"
 #include "sanitizer_common/sanitizer_flag_parser.h"
+#include "sanitizer_common/sanitizer_forward_calls.h"
 #include "ubsan/ubsan_flags.h"
 #include "ubsan/ubsan_platform.h"
 
@@ -172,6 +173,12 @@ void InitializeFlags() {
     Report("WARNING: strchr* interceptors are enabled even though "
            "replace_str=0. Use intercept_strchr=0 to disable them.");
   }
+#if SANITIZER_CALLS_FORWARDING
+  if (!common_flags()->enable_interceptors) {
+    VReport(2, "WARNING: glibc interceptors deactivated, use "
+               "enable_interceptors=1 to enable them.\n");
+  }
+#endif
 }
 
 }  // namespace __asan
index 1b8ab4a..b5915af 100644 (file)
@@ -955,6 +955,8 @@ void InitializeAsanInterceptors() {
 #if SANITIZER_CALLS_FORWARDING
   InitializeMallocInterceptors();
   InitializeNewDeleteInterceptors();
+  if (!common_flags()->enable_interceptors)
+    __sanitizer_disable_interceptors();
 #endif
 
   VReport(1, "AddressSanitizer: libc interceptors initialized\n");
index 47f812a..a80c993 100644 (file)
@@ -261,3 +261,5 @@ COMMON_FLAG(bool, print_cmdline, false, "Print command line on crash "
             "(asan, ubsan and lsan only).")
 COMMON_FLAG(bool, html_cov_report, false, "Generate html coverage report.")
 COMMON_FLAG(const char *, sancov_path, "sancov", "Sancov tool location.")
+COMMON_FLAG(bool, enable_interceptors, true,
+            "If unset, uses glibc calls forwarding around interceptors.")