From ec70c011557d0964dfc528d2d326d75526aec123 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 6 Feb 2002 00:55:46 +0000 Subject: [PATCH] Update. * elf/dl-load.c (_dl_map_object_from_fd): Prevent dynamically loading modules with the DF_STATIC_TLS flag set. * elf/dynamic-link.h (elf_get_dynamic_info): Initialize l_flags element. * include/link.h (struct link_map): Add l_flags field. * elf/elf.h (DF_STATIC_TLS): New definition. --- ChangeLog | 7 +++++++ elf/dl-load.c | 6 +++++- elf/dynamic-link.h | 8 ++++---- elf/elf.h | 1 + include/link.h | 1 + 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7b9f8bb..b5993a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2002-02-05 Ulrich Drepper + * elf/dl-load.c (_dl_map_object_from_fd): Prevent dynamically + loading modules with the DF_STATIC_TLS flag set. + * elf/dynamic-link.h (elf_get_dynamic_info): Initialize l_flags + element. + * include/link.h (struct link_map): Add l_flags field. + * elf/elf.h (DF_STATIC_TLS): New definition. + * dlfcn/Makefile: Add rules to build and run bug-dlopen1. * dlfcn/bug-dlopen1.c: New file. By Bruno Haible. diff --git a/elf/dl-load.c b/elf/dl-load.c index a4e2421..6f9ce05 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -1170,7 +1170,11 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, /* Make sure we are dlopen()ing an object which has the DF_1_NOOPEN flag set. */ - if (__builtin_expect (l->l_flags_1 & DF_1_NOOPEN, 0) + if ((__builtin_expect (l->l_flags_1 & DF_1_NOOPEN, 0) +#ifdef USE_TLS + || __builtin_expect (l->l_flags & DF_STATIC_TLS, 0) +#endif + ) && (mode & __RTLD_DLOPEN)) { /* We are not supposed to load this object. Free all resources. */ diff --git a/elf/dynamic-link.h b/elf/dynamic-link.h index f352997..0229684 100644 --- a/elf/dynamic-link.h +++ b/elf/dynamic-link.h @@ -117,12 +117,12 @@ elf_get_dynamic_info (struct link_map *l) /* Flags are used. Translate to the old form where available. Since these l_info entries are only tested for NULL pointers it is ok if they point to the DT_FLAGS entry. */ - ElfW(Word) flags = info[DT_FLAGS]->d_un.d_val; - if (flags & DF_SYMBOLIC) + l->l_flags = info[DT_FLAGS]->d_un.d_val; + if l->l_(flags & DF_SYMBOLIC) info[DT_SYMBOLIC] = info[DT_FLAGS]; - if (flags & DF_TEXTREL) + if l->l_(flags & DF_TEXTREL) info[DT_TEXTREL] = info[DT_FLAGS]; - if (flags & DF_BIND_NOW) + if (l->l_flags & DF_BIND_NOW) info[DT_BIND_NOW] = info[DT_FLAGS]; } #endif diff --git a/elf/elf.h b/elf/elf.h index d333b4e..f43fbf8 100644 --- a/elf/elf.h +++ b/elf/elf.h @@ -730,6 +730,7 @@ typedef struct #define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */ #define DF_TEXTREL 0x00000004 /* Object contains text relocations */ #define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */ +#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */ /* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1 entry in the dynamic section. */ diff --git a/include/link.h b/include/link.h index 5502bbf..0bb244d 100644 --- a/include/link.h +++ b/include/link.h @@ -237,6 +237,7 @@ struct link_map /* Various flag words. */ ElfW(Word) l_feature_1; ElfW(Word) l_flags_1; + ElfW(Word) l_flags; /* Temporarily used in `dl_close'. */ unsigned int l_idx; -- 2.7.4