[llvm-bugs] [Bug 27790] New: sanitizer dlopen interception clobbers RUNPATH

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 17 10:06:48 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27790

            Bug ID: 27790
           Summary: sanitizer dlopen interception clobbers RUNPATH
           Product: compiler-rt
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: compiler-rt
          Assignee: unassignedbugs at nondot.org
          Reporter: francisjricci at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

dlopen() uses the RUNPATH of the dso which calls it. This means that when a
shared sanitizer dso intercepts dlopen, the RUNPATH of the sanitizer dso will
be used instead of the RUNPATH of the dso being intercepted.

Repro steps:
clang-3.8 test.c -Wl,-rpath,'$ORIGIN' -Wl,--enable-new-dtags -ldl -o clean
clang-3.8 test.c -Wl,-rpath,'$ORIGIN' -Wl,--enable-new-dtags -ldl
-fsanitize=address -o sanitized_static
clang-3.8 test.c -Wl,-rpath,'$ORIGIN' -Wl,--enable-new-dtags -ldl
-fsanitize=address -shared-libasan -o sanitized_dynamic
clang-3.8 foo.c -shared -o foo.so

Note that executing clean and sanitized_static will succeed, while executing
sanitized_dynamic will fail.

foo.c:

int foo = 0;

test.c:

#include <dlfcn.h>

int main() {
  if (dlopen("foo.so", RTLD_NOW)) {
    return 0;
  }

  return 1;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160517/29baaa93/attachment.html>


More information about the llvm-bugs mailing list