From 349b0441dab375099b1d7f6909c1742286a67da9 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 18 Jun 2021 16:50:39 -0700 Subject: Add run-time check for indirect external access When performing symbol lookup for references in executable without indirect external access: 1. Disallow copy relocations in executable against protected data symbols in a shared object with indirect external access. 2. Disallow non-zero symbol values of undefined function symbols in executable, which are used as the function pointer, against protected function symbols in a shared object with indirect external access. Reviewed-by: Adhemerval Zanella --- elf/dl-lookup.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'elf') diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c index eea217eb28..430359af39 100644 --- a/elf/dl-lookup.c +++ b/elf/dl-lookup.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -527,6 +528,10 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash, if (__glibc_unlikely (dl_symbol_visibility_binds_local_p (sym))) goto skip; + if (ELFW(ST_VISIBILITY) (sym->st_other) == STV_PROTECTED) + _dl_check_protected_symbol (undef_name, undef_map, ref, map, + type_class); + switch (ELFW(ST_BIND) (sym->st_info)) { case STB_WEAK: -- cgit 1.4.1