[PATCH 1/2] libc: Fix _dl_map_object_from_fd to update ld.so link_map mirror object

Jiri Olsa jolsa@redhat.com
Wed Jul 27 12:59:00 GMT 2011


If __dl_iterate_phdr is called from audit context, it will not
provide all the info the callback. Some of the fields are just
zero.

The reason is, that inside the audit namespace the dynamic loader
link_map object is just a mirror of the real one. And it does not
have all the info filled in.

Filling in needed values for dynamic loader mirror link_map object.
---
2011-07-26  Jiri Olsa   <jolsa@redhat.com>

	* elf/dl-load.c (_dl_map_object_from_fd): Filling in needed
	values for dynamic loader mirror link_map object.

diff --git a/elf/dl-load.c b/elf/dl-load.c
index 18a83d2..4668b11 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -969,6 +969,13 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
       /* Refer to the real descriptor.  */
       l->l_real = &GL(dl_rtld_map);
 
+      /* Set up the program header information itself. It is needed in
+         the dl_iterate_phdr() callbacks.  */
+      l->l_addr = GL(dl_rtld_map).l_addr;
+      l->l_phdr = GL(dl_rtld_map).l_phdr;
+      l->l_phnum = GL(dl_rtld_map).l_phnum;
+      l->l_tls_modid = GL(dl_rtld_map).l_tls_modid;
+
       /* No need to bump the refcount of the real object, ld.so will
 	 never be unloaded.  */
       __close (fd);
-- 
1.7.4.4



More information about the Libc-alpha mailing list