about summary refs log tree commit diff
path: root/dlfcn/dladdr.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-12-18 20:04:13 +0100
committerFlorian Weimer <fweimer@redhat.com>2017-12-18 20:04:13 +0100
commit8e1472d2c1e25e6eabc2059170731365f6d5b3d1 (patch)
tree5b29308e6b00178a34422b6f7bb7b4f9252801dc /dlfcn/dladdr.c
parent49b036bce9f021ae994a85aee8b410d20b29c8b7 (diff)
downloadglibc-8e1472d2c1e25e6eabc2059170731365f6d5b3d1.tar.gz
glibc-8e1472d2c1e25e6eabc2059170731365f6d5b3d1.tar.xz
glibc-8e1472d2c1e25e6eabc2059170731365f6d5b3d1.zip
ld.so: Examine GLRO to detect inactive loader [BZ #20204]
GLRO (_rtld_global_ro) is read-only after initialization and can
therefore not be patched at run time, unlike the hook table addresses
and their contents, so this is a desirable hardening feature.

The hooks are only needed if ld.so has not been initialized, and this
happens only after static dlopen (dlmopen uses a single ld.so object
across all namespaces).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'dlfcn/dladdr.c')
-rw-r--r--dlfcn/dladdr.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/dlfcn/dladdr.c b/dlfcn/dladdr.c
index 1753434160..1bebd00240 100644
--- a/dlfcn/dladdr.c
+++ b/dlfcn/dladdr.c
@@ -17,6 +17,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <dlfcn.h>
+#include <ldsodefs.h>
 
 #if !defined SHARED && IS_IN (libdl)
 
@@ -32,7 +33,7 @@ int
 __dladdr (const void *address, Dl_info *info)
 {
 # ifdef SHARED
-  if (__glibc_unlikely (_dlfcn_hook != NULL))
+  if (!rtld_active ())
     return _dlfcn_hook->dladdr (address, info);
 # endif
   return _dl_addr (address, info, NULL, NULL);