diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2021-11-11 09:28:21 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2021-11-18 17:17:58 -0300 |
commit | ed3ce71f5c64c5f07cbde0ef03554ea8950d8f2c (patch) | |
tree | 0510cc6754006d88cb384c37a8834509954e9074 /elf/dl-load.c | |
parent | bdeb7a8fa9989d18dab6310753d04d908125dc1d (diff) | |
download | glibc-ed3ce71f5c64c5f07cbde0ef03554ea8950d8f2c.zip glibc-ed3ce71f5c64c5f07cbde0ef03554ea8950d8f2c.tar.gz glibc-ed3ce71f5c64c5f07cbde0ef03554ea8950d8f2c.tar.bz2 |
elf: Move la_activity (LA_ACT_ADD) after _dl_add_to_namespace_list() (BZ #28062)
It ensures that the the namespace is guaranteed to not be empty.
Checked on x86_64-linux-gnu.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Diffstat (limited to 'elf/dl-load.c')
-rw-r--r-- | elf/dl-load.c | 74 |
1 files changed, 38 insertions, 36 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c index 9f4fa96..bf8957e 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -1058,42 +1058,6 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd, /* This is the ELF header. We read it in `open_verify'. */ header = (void *) fbp->buf; - /* Signal that we are going to add new objects. */ - if (r->r_state == RT_CONSISTENT) - { -#ifdef SHARED - /* Auditing checkpoint: we are going to add new objects. */ - if ((mode & __RTLD_AUDIT) == 0 - && __glibc_unlikely (GLRO(dl_naudit) > 0)) - { - struct link_map *head = GL(dl_ns)[nsid]._ns_loaded; - /* Do not call the functions for any auditing object. */ - if (head->l_auditing == 0) - { - struct audit_ifaces *afct = GLRO(dl_audit); - for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt) - { - if (afct->activity != NULL) - afct->activity (&link_map_audit_state (head, cnt)->cookie, - LA_ACT_ADD); - - afct = afct->next; - } - } - } -#endif - - /* Notify the debugger we have added some objects. We need to - call _dl_debug_initialize in a static program in case dynamic - linking has not been used before. */ - r->r_state = RT_ADD; - _dl_debug_state (); - LIBC_PROBE (map_start, 2, nsid, r); - make_consistent = true; - } - else - assert (r->r_state == RT_ADD); - /* Enter the new object in the list of loaded objects. */ l = _dl_new_object (realname, name, l_type, loader, mode, nsid); if (__glibc_unlikely (l == NULL)) @@ -1515,6 +1479,44 @@ cannot enable executable stack as shared object requires"); /* Now that the object is fully initialized add it to the object list. */ _dl_add_to_namespace_list (l, nsid); + /* Signal that we are going to add new objects. */ + if (r->r_state == RT_CONSISTENT) + { +#ifdef SHARED + /* Auditing checkpoint: we are going to add new objects. Since this + is called after _dl_add_to_namespace_list the namespace is guaranteed + to not be empty. */ + if ((mode & __RTLD_AUDIT) == 0 + && __glibc_unlikely (GLRO(dl_naudit) > 0)) + { + struct link_map *head = GL(dl_ns)[nsid]._ns_loaded; + /* Do not call the functions for any auditing object. */ + if (head->l_auditing == 0) + { + struct audit_ifaces *afct = GLRO(dl_audit); + for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt) + { + if (afct->activity != NULL) + afct->activity (&link_map_audit_state (head, cnt)->cookie, + LA_ACT_ADD); + + afct = afct->next; + } + } + } +#endif + + /* Notify the debugger we have added some objects. We need to + call _dl_debug_initialize in a static program in case dynamic + linking has not been used before. */ + r->r_state = RT_ADD; + _dl_debug_state (); + LIBC_PROBE (map_start, 2, nsid, r); + make_consistent = true; + } + else + assert (r->r_state == RT_ADD); + #ifdef SHARED /* Auditing checkpoint: we have a new object. */ if (__glibc_unlikely (GLRO(dl_naudit) > 0) |