This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/2] libc: Fix __dl_iterate_phdr to take values from real link_map object


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.

Using l_real link_map to get the values for __dl_iterate_phdr callback.
---
2011-07-26  Jiri Olsa   <jolsa@redhat.com>

	* elf/dl-iteratephdr.c (__dl_iterate_phdr): Using l_real link_map to
	get the values for __dl_iterate_phdr callback.

diff --git a/elf/dl-iteratephdr.c b/elf/dl-iteratephdr.c
index 5f1c20d..213296a 100644
--- a/elf/dl-iteratephdr.c
+++ b/elf/dl-iteratephdr.c
@@ -62,16 +62,19 @@ __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
 
   for (l = GL(dl_ns)[ns]._ns_loaded; l != NULL; l = l->l_next)
     {
-      info.dlpi_addr = l->l_addr;
-      info.dlpi_name = l->l_name;
-      info.dlpi_phdr = l->l_phdr;
-      info.dlpi_phnum = l->l_phnum;
+      /* Take the values from the l_real pointer. The chained link_map could
+         be only mirroring object as for dynamic loader. */
+      struct link_map *lr = l->l_real;
+      info.dlpi_addr = lr->l_addr;
+      info.dlpi_name = lr->l_name;
+      info.dlpi_phdr = lr->l_phdr;
+      info.dlpi_phnum = lr->l_phnum;
       info.dlpi_adds = GL(dl_load_adds);
       info.dlpi_subs = GL(dl_load_adds) - nloaded;
       info.dlpi_tls_data = NULL;
-      info.dlpi_tls_modid = l->l_tls_modid;
+      info.dlpi_tls_modid = lr->l_tls_modid;
       if (info.dlpi_tls_modid != 0)
-	info.dlpi_tls_data = GLRO(dl_tls_get_addr_soft) (l);
+	info.dlpi_tls_data = GLRO(dl_tls_get_addr_soft) (lr);
       ret = callback (&info, sizeof (struct dl_phdr_info), data);
       if (ret)
 	break;
-- 
1.7.4.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]