From 81b49e969233ac5b9faf5c043bb0cc64bf9d6271 Mon Sep 17 00:00:00 2001 From: Tulio Magno Quites Machado Filho Date: Thu, 26 Apr 2018 10:41:43 -0300 Subject: Increase robustness of internal dlopen() by using RTLD_NOW [BZ #22766] Prevent random runtime crashes due to missing symbols caused by mixed libnss_* versions. [BZ #22766] * include/dlfcn.h [__libc_dl_open]: Replace RTLD_LAZY with RTLD_NOW. * sysdeps/gnu/unwind-resume.c (__lib_gcc_s_init): Replace __libc_dlopen_mode() using RTLD_NOW with __libc_dlopen. * sysdeps/nptl/unwind-forcedunwind.c: Likewise. Signed-off-by: Tulio Magno Quites Machado Filho Reviewed-by: Carlos O'Donell --- sysdeps/gnu/unwind-resume.c | 7 ++----- sysdeps/nptl/unwind-forcedunwind.c | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'sysdeps') diff --git a/sysdeps/gnu/unwind-resume.c b/sysdeps/gnu/unwind-resume.c index 7f9a1bf2c7..9283d925de 100644 --- a/sysdeps/gnu/unwind-resume.c +++ b/sysdeps/gnu/unwind-resume.c @@ -35,11 +35,8 @@ __libgcc_s_init (void) void *resume, *personality; void *handle; - /* Use RTLD_NOW here for consistency with pthread_cancel_init. - RTLD_NOW will rarely make a difference here because unwinding is - already in progress, so libgcc_s.so has already been loaded if - its unwinder is used. */ - handle = __libc_dlopen_mode (LIBGCC_S_SO, RTLD_NOW | __RTLD_DLOPEN); + /* See include/dlfcn.h. Use of __libc_dlopen requires RTLD_NOW. */ + handle = __libc_dlopen (LIBGCC_S_SO); if (handle == NULL || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL diff --git a/sysdeps/nptl/unwind-forcedunwind.c b/sysdeps/nptl/unwind-forcedunwind.c index 67b8e74b53..0621c8002f 100644 --- a/sysdeps/nptl/unwind-forcedunwind.c +++ b/sysdeps/nptl/unwind-forcedunwind.c @@ -49,7 +49,8 @@ pthread_cancel_init (void) return; } - handle = __libc_dlopen_mode (LIBGCC_S_SO, RTLD_NOW | __RTLD_DLOPEN); + /* See include/dlfcn.h. Use of __libc_dlopen requires RTLD_NOW. */ + handle = __libc_dlopen (LIBGCC_S_SO); if (handle == NULL || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL -- cgit 1.4.1