[PATCH] D30504: [sanitizer] Bail out with warning if user dlopens shared library with RTLD_DEEPBIND flag

Maxim Ostapenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 1 11:59:50 PST 2017


m.ostapenko added inline comments.


================
Comment at: lib/sanitizer_common/sanitizer_common.cc:480
+void CheckNoDeepBind(int flag) {
+  if (flag & RTLD_DEEPBIND) {
+    Report("You are trying to dlopen a shared library with RTLD_DEEPBIND flag"
----------------
kubamracek wrote:
> This will not compile on macOS (RTLD_DEEPBIND is not defined there).
Thanks, will move this to sanitizer_linux. cc.


================
Comment at: lib/sanitizer_common/sanitizer_common.cc:485
+           "). If you want to run your library under sanitizers please remove "
+           "RTLD_DEEPBIND from dlopen flags.\n");
+    Die();
----------------
ygribov wrote:
> Does it make sense to print backtrace?
Perhaps. At least we should print library name here. 


================
Comment at: test/sanitizer_common/TestCases/Posix/deepbind.cc:1
+// RUN: %clangxx -DSHARED_LIB %s -fPIC -shared -o %t-so.so
+// RUN: %clangxx %s -o %t && %run %t 2>&1
----------------
ygribov wrote:
> Do you need shlib at all? You don't care if `dlopen` succeeds so can call it with arbitrary path.
Just wanted to make sure that without deepbind everything works as expected. I can drop this for sure. 


================
Comment at: test/sanitizer_common/TestCases/Posix/deepbind.cc:4
+// RUN: %run not %t 1 2>&1 | FileCheck %s --check-prefix CHECK-DEEPBIND
+// UNSUPPORTED: lsan, android
+
----------------
ygribov wrote:
> Android does not have it?
AFAIK Android doesn't intercept dlopen. 


Repository:
  rL LLVM

https://reviews.llvm.org/D30504





More information about the llvm-commits mailing list