<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - sanitizer dlopen interception clobbers RUNPATH"
   href="https://llvm.org/bugs/show_bug.cgi?id=27790">27790</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>sanitizer dlopen interception clobbers RUNPATH
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.8
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>francisjricci@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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;
}</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>