diff options
author | Serge Guelton <sguelton@redhat.com> | 2019-07-20 12:01:18 +0000 |
---|---|---|
committer | Serge Guelton <sguelton@redhat.com> | 2019-07-20 12:01:18 +0000 |
commit | cbd28cd05bb11e9d76d71c6cc2d38d89dbb1fe1a (patch) | |
tree | 9f509b0183586dc67c816de147adab0b53bdac0a /compiler-rt/lib/interception | |
parent | fc0d766511e9c77ccf54bd5bfd8bed342ca6dd18 (diff) | |
download | bcm5719-llvm-cbd28cd05bb11e9d76d71c6cc2d38d89dbb1fe1a.tar.gz bcm5719-llvm-cbd28cd05bb11e9d76d71c6cc2d38d89dbb1fe1a.zip |
Fix asan infinite loop on undefined symbol
Fix llvm#39641
Recommit of r366413
Differential Revision: https://reviews.llvm.org/D63877
llvm-svn: 366632
Diffstat (limited to 'compiler-rt/lib/interception')
-rw-r--r-- | compiler-rt/lib/interception/interception_linux.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler-rt/lib/interception/interception_linux.cc b/compiler-rt/lib/interception/interception_linux.cc index d07f060b5b6..4b27102a159 100644 --- a/compiler-rt/lib/interception/interception_linux.cc +++ b/compiler-rt/lib/interception/interception_linux.cc @@ -33,7 +33,7 @@ static int StrCmp(const char *s1, const char *s2) { } #endif -static void *GetFuncAddr(const char *name) { +static void *GetFuncAddr(const char *name, uptr wrapper_addr) { #if SANITIZER_NETBSD // FIXME: Find a better way to handle renames if (StrCmp(name, "sigaction")) @@ -47,13 +47,18 @@ static void *GetFuncAddr(const char *name) { // want the address of the real definition, though, so look it up using // RTLD_DEFAULT. addr = dlsym(RTLD_DEFAULT, name); + + // In case `name' is not loaded, dlsym ends up finding the actual wrapper. + // We don't want to intercept the wrapper and have it point to itself. + if ((uptr)addr == wrapper_addr) + addr = nullptr; } return addr; } bool InterceptFunction(const char *name, uptr *ptr_to_real, uptr func, uptr wrapper) { - void *addr = GetFuncAddr(name); + void *addr = GetFuncAddr(name, wrapper); *ptr_to_real = (uptr)addr; return addr && (func == wrapper); } |