From 8e1472d2c1e25e6eabc2059170731365f6d5b3d1 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Mon, 18 Dec 2017 20:04:13 +0100 Subject: 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 --- libio/vtables.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libio') diff --git a/libio/vtables.c b/libio/vtables.c index 41b48db98c..4d4afa2efc 100644 --- a/libio/vtables.c +++ b/libio/vtables.c @@ -19,6 +19,7 @@ #include #include #include +#include #ifdef SHARED @@ -54,7 +55,7 @@ _IO_vtable_check (void) { Dl_info di; struct link_map *l; - if (_dl_open_hook != NULL + if (!rtld_active () || (_dl_addr (_IO_vtable_check, &di, &l, NULL) != 0 && l->l_ns != LM_ID_BASE)) return; -- cgit v1.2.3