diff options
author | Ulrich Drepper <drepper@redhat.com> | 2004-03-27 03:40:33 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2004-03-27 03:40:33 +0000 |
commit | eec8b6cae586451deadf30c371f7b5e4c9d573d1 (patch) | |
tree | b005437b5b7d69778e06694e4bd836a3e7c42f6a /elf/dl-open.c | |
parent | 17c263876bf38178d3a4ba720bf81d7a214bba51 (diff) | |
download | glibc-eec8b6cae586451deadf30c371f7b5e4c9d573d1.tar.gz glibc-eec8b6cae586451deadf30c371f7b5e4c9d573d1.tar.xz glibc-eec8b6cae586451deadf30c371f7b5e4c9d573d1.zip |
Update.
2004-03-26 Ulrich Drepper <drepper@redhat.com> * elf/dl-caller.c: New file. * include/caller.h: New file. * Makefile (distribute): Add include/caller.h. * elf/Makefile (dl-routines): Add dl-caller. * elf/dl-load.c (_dl_map_object_from_fd): Record l_text_end. * elf/dl-open.c (check_libc_caller): Removed. (dl_open_worker): Use __check_caller instead. * elf/rtld.c (_rtld_global_ro): Initialize _dl_check_caller. (_dl_start_final): Record l_text_end for ld.so map. (dl_main): Record l_text_end for main object and vdso. * include/link.h (struct link_map): Add l_text_end field. * sysdeps/generic/ldsodefs.h (struct rtld_global_ro): Add _dl_check_caller field. Define enum allowmask. Add declaration of _dl_check_caller. * sysdeps/unix/sysv/linux/dl-execstack.c: Also use __check_caller test.
Diffstat (limited to 'elf/dl-open.c')
-rw-r--r-- | elf/dl-open.c | 68 |
1 files changed, 2 insertions, 66 deletions
diff --git a/elf/dl-open.c b/elf/dl-open.c index 47db84c867..70f2fb20bc 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -30,7 +30,7 @@ #include <bits/libc-lock.h> #include <ldsodefs.h> #include <bp-sym.h> -#include <gnu/lib-names.h> +#include <caller.h> #include <dl-dst.h> @@ -156,68 +156,6 @@ add_to_global (struct link_map *new) } -#ifdef SHARED -static int -internal_function -check_libc_caller (const void *caller) -{ - static const char expected1[] = LIBC_SO; - static const char expected2[] = LIBDL_SO; - - /* If we already know the address ranges, just test. */ - static const void *expected1_from; - static const void *expected1_to; - static const void *expected2_from; - static const void *expected2_to; - - if (expected1_from == NULL) - { - /* The only other DSO which is allowed to call these functions is - libdl. Find the address range containing the caller. */ - struct link_map *l; - - for (l = GL(dl_loaded); l != NULL; l = l->l_next) - if (strcmp (expected1, l->l_name) == 0) - { - is_1: - expected1_from = (const void *) l->l_map_start; - expected1_to = (const void *) l->l_map_end; - } - else if (strcmp (expected2, l->l_name) == 0) - { - is_2: - expected2_from = (const void *) l->l_map_start; - expected2_to = (const void *) l->l_map_end; - } - else - { - struct libname_list *runp = l->l_libname; - - while (runp != NULL) - { - if (strcmp (expected1, runp->name) == 0) - goto is_1; - else if (strcmp (expected2, runp->name) == 0) - goto is_2; - - runp = runp->next; - } - } - - assert (expected1_from != NULL); - } - - /* When there would be more than two expected caller we could use an - array for the values but for now this is cheaper. */ - if ((caller >= expected1_from && caller < expected1_to) - || (caller >= expected2_from && caller < expected2_to)) - return 0; - - return 1; -} -#endif - - static void dl_open_worker (void *a) { @@ -232,11 +170,9 @@ dl_open_worker (void *a) bool any_tls; #endif -#ifdef SHARED /* Check whether _dl_open() has been called from a valid DSO. */ - if (check_libc_caller (args->caller_dl_open) != 0) + if (__check_caller (args->caller_dl_open, allow_libc|allow_libdl) != 0) GLRO(dl_signal_error) (0, "dlopen", NULL, N_("invalid caller")); -#endif /* Maybe we have to expand a DST. */ dst = strchr (file, '$'); |