aboutsummaryrefslogtreecommitdiff
path: root/elf/dl-load.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2021-10-15 10:44:49 -0700
committerH.J. Lu <hjl.tools@gmail.com>2022-01-04 04:56:08 -0800
commitbfb5ed5df3dd4d9507b4922248dc445b690d19c0 (patch)
tree844dc10ce1770a0d44c8d372e021d3053c2e7f43 /elf/dl-load.c
parent7ac2bee49540b87e6e1c309e23ea170b0fa6e5df (diff)
downloadglibc-bfb5ed5df3dd4d9507b4922248dc445b690d19c0.tar
glibc-bfb5ed5df3dd4d9507b4922248dc445b690d19c0.tar.gz
glibc-bfb5ed5df3dd4d9507b4922248dc445b690d19c0.tar.bz2
glibc-bfb5ed5df3dd4d9507b4922248dc445b690d19c0.zip
elf: Also try DT_RUNPATH for LD_AUDIT dlopen [BZ #28455]
DT_RUNPATH is only used to find the immediate dependencies of the executable or shared object containing the DT_RUNPATH entry. Update LD_AUDIT dlopen call to try the DT_RUNPATH entry of the executable. Add tst-audit14a, which is copied from tst-audit14, to DT_RUNPATH and build tst-audit14 with -Wl,--disable-new-dtags to test DT_RPATH. This partially fixes BZ #28455.
Diffstat (limited to 'elf/dl-load.c')
-rw-r--r--elf/dl-load.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index ddc4295ef5..12744caf91 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -2111,6 +2111,21 @@ _dl_map_object (struct link_map *loader, const char *name,
&main_map->l_rpath_dirs,
&realname, &fb, loader ?: main_map, LA_SER_RUNPATH,
&found_other_class);
+
+ /* Also try DT_RUNPATH in the executable for LD_AUDIT dlopen
+ call. */
+ if (__glibc_unlikely (mode & __RTLD_AUDIT)
+ && fd == -1 && !did_main_map
+ && main_map != NULL && main_map->l_type != lt_loaded)
+ {
+ struct r_search_path_struct l_rpath_dirs;
+ l_rpath_dirs.dirs = NULL;
+ if (cache_rpath (main_map, &l_rpath_dirs,
+ DT_RUNPATH, "RUNPATH"))
+ fd = open_path (name, namelen, mode, &l_rpath_dirs,
+ &realname, &fb, loader ?: main_map,
+ LA_SER_RUNPATH, &found_other_class);
+ }
}
/* Try the LD_LIBRARY_PATH environment variable. */