[compiler-rt] r299188 - [asan] Move AsanCheckDynamicRTPrereqs check under flag

Maxim Ostapenko via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 30 23:36:37 PDT 2017


Author: chefmax
Date: Fri Mar 31 01:36:37 2017
New Revision: 299188

URL: http://llvm.org/viewvc/llvm-project?rev=299188&view=rev
Log:
[asan] Move AsanCheckDynamicRTPrereqs check under flag

The patch addresses https://github.com/google/sanitizers/issues/786. Currently AsanCheckDynamicRTPrereqs prevents
dynamic ASan runtime from running in some important environments e.g. cowbuilder and fakeroot that may also work with interposition.
Let's allow users to switch off the check given that they know what they do.

Differential Revision: https://reviews.llvm.org/D31420

Modified:
    compiler-rt/trunk/lib/asan/asan_flags.inc
    compiler-rt/trunk/lib/asan/asan_linux.cc
    compiler-rt/trunk/test/asan/TestCases/Linux/asan_dlopen_test.cc

Modified: compiler-rt/trunk/lib/asan/asan_flags.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_flags.inc?rev=299188&r1=299187&r2=299188&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_flags.inc (original)
+++ compiler-rt/trunk/lib/asan/asan_flags.inc Fri Mar 31 01:36:37 2017
@@ -158,3 +158,6 @@ ASAN_FLAG(bool, allocator_frees_and_retu
           "realloc(p, 0) is equivalent to free(p) by default (Same as the "
           "POSIX standard). If set to false, realloc(p, 0) will return a "
           "pointer to an allocated space which can not be used.")
+ASAN_FLAG(bool, verify_asan_link_order, true,
+          "Check position of ASan runtime in library list (needs to be disabled"
+          " when other library has to be preloaded system-wide)")

Modified: compiler-rt/trunk/lib/asan/asan_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_linux.cc?rev=299188&r1=299187&r2=299188&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_linux.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_linux.cc Fri Mar 31 01:36:37 2017
@@ -111,7 +111,7 @@ static void ReportIncompatibleRT() {
 }
 
 void AsanCheckDynamicRTPrereqs() {
-  if (!ASAN_DYNAMIC)
+  if (!ASAN_DYNAMIC || !flags()->verify_asan_link_order)
     return;
 
   // Ensure that dynamic RT is the first DSO in the list

Modified: compiler-rt/trunk/test/asan/TestCases/Linux/asan_dlopen_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/asan_dlopen_test.cc?rev=299188&r1=299187&r2=299188&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/asan_dlopen_test.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/asan_dlopen_test.cc Fri Mar 31 01:36:37 2017
@@ -2,6 +2,8 @@
 //
 // RUN: %clangxx %s -DRT=\"%shared_libasan\" -o %t -ldl
 // RUN: not %run %t 2>&1 | FileCheck %s
+// RUN: %env_asan_opts=verify_asan_link_order=true not %run %t 2>&1 | FileCheck %s
+// RUN: %env_asan_opts=verify_asan_link_order=false %run %t 2>&1
 // REQUIRES: asan-dynamic-runtime
 // XFAIL: android
 




More information about the llvm-commits mailing list