execve("/proc/self/exe") will not work if the binary relies on
$EXEC_ORIGIN in an rpath. Query AT_EXECFN instead, which will give the
same string that the current binary was exec'd with.
Details
Details
Diff Detail
Diff Detail
- Repository
- rCRT Compiler Runtime
Event Timeline
Comment Actions
I thought it was only possible on PPC, but I can abuse the fact that MSAN re-execs on unlimited stacks. Test included.
test/msan/Linux/reexec_unlimited_stack.cc | ||
---|---|---|
17 | How this test triggers changed code? |
test/msan/Linux/reexec_unlimited_stack.cc | ||
---|---|---|
17 | The idea is that the ulimit -s unlimited makes msan re-exec on startup. Currently this overwrites AT_EXECFN with /proc/self/exe. With this change it's preserved. |
Comment Actions
$EXEC_ORIGIN ($ORIGIN without tracing the symlink) does not exist in vanilla glibc https://sourceware.org/ml/libc-alpha/2017-10/msg01109.html
This breaks TSanitizer-x86_64-Test-Nolibc as getauxval is a glibc symbol, which can be fixed by https://reviews.llvm.org/D54160
ld.lld: error: undefined symbol: getauxval >>> referenced by sanitizer_linux.cc:646 (../projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc:646) >>> sanitizer_linux.cc.o:(__sanitizer::ReExec()) in archive libRTSanitizerCommon.test.nolibc.x86_64.a
How this test triggers changed code?