|
|
147e83 |
commit 10e93d968716ab82931d593bada121c17c0a4b93
|
|
|
147e83 |
Author: Dmitry V. Levin <ldv@altlinux.org>
|
|
|
147e83 |
Date: Mon Dec 18 21:46:07 2017 +0000
|
|
|
147e83 |
|
|
|
147e83 |
elf: remove redundant __libc_enable_secure check from fillin_rpath
|
|
|
147e83 |
|
|
|
147e83 |
There are just two users of fillin_rpath: one is decompose_rpath that
|
|
|
147e83 |
sets check_trusted argument to 0, another one is _dl_init_paths that
|
|
|
147e83 |
sets check_trusted argument to __libc_enable_secure and invokes
|
|
|
147e83 |
fillin_rpath only when LD_LIBRARY_PATH is non-empty.
|
|
|
147e83 |
|
|
|
147e83 |
Starting with commit
|
|
|
147e83 |
glibc-2.25.90-512-gf6110a8fee2ca36f8e2d2abecf3cba9fa7b8ea7d,
|
|
|
147e83 |
LD_LIBRARY_PATH is ignored for __libc_enable_secure executables,
|
|
|
147e83 |
so check_trusted argument of fillin_rpath is always zero.
|
|
|
147e83 |
|
|
|
147e83 |
* elf/dl-load.c (is_trusted_path): Remove.
|
|
|
147e83 |
(fillin_rpath): Remove check_trusted argument and its use,
|
|
|
147e83 |
all callers changed.
|
|
|
147e83 |
|
|
|
147e83 |
Index: glibc-2.17-c758a686/elf/dl-load.c
|
|
|
147e83 |
===================================================================
|
|
|
147e83 |
--- glibc-2.17-c758a686.orig/elf/dl-load.c
|
|
|
147e83 |
+++ glibc-2.17-c758a686/elf/dl-load.c
|
|
|
147e83 |
@@ -169,24 +169,6 @@ local_strdup (const char *s)
|
|
|
147e83 |
|
|
|
147e83 |
|
|
|
147e83 |
static bool
|
|
|
147e83 |
-is_trusted_path (const char *path, size_t len)
|
|
|
147e83 |
-{
|
|
|
147e83 |
- const char *trun = system_dirs;
|
|
|
147e83 |
-
|
|
|
147e83 |
- for (size_t idx = 0; idx < nsystem_dirs_len; ++idx)
|
|
|
147e83 |
- {
|
|
|
147e83 |
- if (len == system_dirs_len[idx] && memcmp (trun, path, len) == 0)
|
|
|
147e83 |
- /* Found it. */
|
|
|
147e83 |
- return true;
|
|
|
147e83 |
-
|
|
|
147e83 |
- trun += system_dirs_len[idx] + 1;
|
|
|
147e83 |
- }
|
|
|
147e83 |
-
|
|
|
147e83 |
- return false;
|
|
|
147e83 |
-}
|
|
|
147e83 |
-
|
|
|
147e83 |
-
|
|
|
147e83 |
-static bool
|
|
|
147e83 |
is_trusted_path_normalize (const char *path, size_t len)
|
|
|
147e83 |
{
|
|
|
147e83 |
if (len == 0)
|
|
|
147e83 |
@@ -487,8 +469,7 @@ static size_t max_dirnamelen;
|
|
|
147e83 |
|
|
|
147e83 |
static struct r_search_path_elem **
|
|
|
147e83 |
fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep,
|
|
|
147e83 |
- int check_trusted, const char *what, const char *where,
|
|
|
147e83 |
- struct link_map *l)
|
|
|
147e83 |
+ const char *what, const char *where, struct link_map *l)
|
|
|
147e83 |
{
|
|
|
147e83 |
char *cp;
|
|
|
147e83 |
size_t nelems = 0;
|
|
|
147e83 |
@@ -518,13 +499,6 @@ fillin_rpath (char *rpath, struct r_sear
|
|
|
147e83 |
if (len > 0 && cp[len - 1] != '/')
|
|
|
147e83 |
cp[len++] = '/';
|
|
|
147e83 |
|
|
|
147e83 |
- /* Make sure we don't use untrusted directories if we run SUID. */
|
|
|
147e83 |
- if (__builtin_expect (check_trusted, 0) && !is_trusted_path (cp, len))
|
|
|
147e83 |
- {
|
|
|
147e83 |
- free (to_free);
|
|
|
147e83 |
- continue;
|
|
|
147e83 |
- }
|
|
|
147e83 |
-
|
|
|
147e83 |
/* See if this directory is already known. */
|
|
|
147e83 |
for (dirp = GL(dl_all_dirs); dirp != NULL; dirp = dirp->next)
|
|
|
147e83 |
if (dirp->dirnamelen == len && memcmp (cp, dirp->dirname, len) == 0)
|
|
|
147e83 |
@@ -674,7 +648,7 @@ decompose_rpath (struct r_search_path_st
|
|
|
147e83 |
_dl_signal_error (ENOMEM, NULL, NULL, errstring);
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
- fillin_rpath (copy, result, ":", 0, what, where, l);
|
|
|
147e83 |
+ fillin_rpath (copy, result, ":", what, where, l);
|
|
|
147e83 |
|
|
|
147e83 |
/* Free the copied RPATH string. `fillin_rpath' make own copies if
|
|
|
147e83 |
necessary. */
|
|
|
147e83 |
@@ -847,8 +821,7 @@ _dl_init_paths (const char *llp)
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
(void) fillin_rpath (llp_tmp, env_path_list.dirs, ":;",
|
|
|
147e83 |
- INTUSE(__libc_enable_secure), "LD_LIBRARY_PATH",
|
|
|
147e83 |
- NULL, l);
|
|
|
147e83 |
+ "LD_LIBRARY_PATH", NULL, l);
|
|
|
147e83 |
|
|
|
147e83 |
if (env_path_list.dirs[0] == NULL)
|
|
|
147e83 |
{
|