diff options
| author | Florian Weimer <fweimer@redhat.com> | 2024-08-09 15:31:18 +0200 |
|---|---|---|
| committer | Florian Weimer <fweimer@redhat.com> | 2024-12-20 16:16:21 +0100 |
| commit | 8f36b1469677afe37168f9af1b77402d7a70c673 (patch) | |
| tree | 821a4f6ed66688e051ec466279bda2c474aab0e7 /elf/dl-load.c | |
| parent | a20bc2f6233a726c7df8eaa332b6e498bd59321f (diff) | |
| download | glibc-8f36b1469677afe37168f9af1b77402d7a70c673.tar.xz glibc-8f36b1469677afe37168f9af1b77402d7a70c673.zip | |
elf: Signal la_objopen for the proxy link map in dlmopen (bug 31985)
Previously, the ld.so link map was silently added to the namespace.
This change produces an auditing event for it.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'elf/dl-load.c')
| -rw-r--r-- | elf/dl-load.c | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c index 4b8bd8a498..284857ddf6 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -902,6 +902,37 @@ _dl_process_pt_gnu_property (struct link_map *l, int fd, const ElfW(Phdr) *ph) } } +static void +_dl_notify_new_object (int mode, Lmid_t nsid, struct link_map *l) +{ + /* Signal that we are going to add new objects. */ + struct r_debug *r = _dl_debug_update (nsid); + 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) + _dl_audit_activity_nsid (nsid, LA_ACT_ADD); +#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); + } + else + assert (r->r_state == RT_ADD); + +#ifdef SHARED + /* Auditing checkpoint: we have a new object. */ + if (!GL(dl_ns)[l->l_ns]._ns_loaded->l_auditing) + _dl_audit_objopen (l, nsid); +#endif +} /* Map in the shared object NAME, actually located in REALNAME, and already opened on FD. */ @@ -1002,6 +1033,8 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd, /* Add the map for the mirrored object to the object list. */ _dl_add_to_namespace_list (l, nsid); + _dl_notify_new_object (mode, nsid, l); + return l; } #endif @@ -1426,33 +1459,7 @@ cannot enable executable stack as shared object requires"); if (mode & __RTLD_SPROF) return l; - /* Signal that we are going to add new objects. */ - struct r_debug *r = _dl_debug_update (nsid); - 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) - _dl_audit_activity_nsid (nsid, LA_ACT_ADD); -#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); - } - else - assert (r->r_state == RT_ADD); - -#ifdef SHARED - /* Auditing checkpoint: we have a new object. */ - if (!GL(dl_ns)[l->l_ns]._ns_loaded->l_auditing) - _dl_audit_objopen (l, nsid); -#endif + _dl_notify_new_object (mode, nsid, l); return l; } |
