This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] [BZ #14579] rtld: limit the self loading check to normalmode
- From: Carlos O'Donell <carlos_odonell at mentor dot com>
- To: "Dmitry V. Levin" <ldv at altlinux dot org>
- Cc: <libc-alpha at sourceware dot org>
- Date: Thu, 13 Sep 2012 21:50:20 -0400
- Subject: Re: [PATCH] [BZ #14579] rtld: limit the self loading check to normalmode
- References: <20120914012605.GB3090@altlinux.org>
On 9/13/2012 9:26 PM, Dmitry V. Levin wrote:
> Run time dynamic linker used to allow processing itself in verify, list
> and trace modes until commit glibc-2.14~10 disallowed all kinds of self
> loading altogether. This change limits the check for self loading to
> normal mode so that instruments like ldd could handle rtld properly.
I like where this patch is going, but you are missing some more information.
(a) Why was this disabled? What has changed since then that would make
it meaningful to enable today?
(b) What use case does this enable? Is it actually useful to run ldd
against the loader? Why?
(c) Testcase?
> ---
> ChangeLog | 6 ++++++
> NEWS | 2 +-
> elf/rtld.c | 3 ++-
> 3 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index 5d14c4f..0e5ba4e 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,9 @@
> +2012-09-13 Dmitry V. Levin <ldv@altlinux.org>
> +
> + [BZ #14579]
> + * elf/rtld.c (dl_main): Limit the check for self loading to normal
> + mode only.
> +
> 2012-09-13 H.J. Lu <hongjiu.lu@intel.com>
>
> [BZ #14576]
> diff --git a/NEWS b/NEWS
> index d27de18..b11dfd4 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -13,7 +13,7 @@ Version 2.17
> 13542, 13717, 13696, 13939, 13966, 14042, 14090, 14166, 14150, 14151,
> 14154, 14157, 14166, 14173, 14195, 14237, 14252, 14283, 14298, 14303,
> 14307, 14328, 14331, 14336, 14337, 14347, 14349, 14459, 14476, 14505,
> - 14510, 14516, 14518, 14519, 14532, 14538, 14544, 14545, 14576,
> + 14510, 14516, 14518, 14519, 14532, 14538, 14544, 14545, 14576, 14579.
>
> * Support for STT_GNU_IFUNC symbols added for s390 and s390x.
> Optimized versions of memcpy, memset, and memcmp added for System z10 and
> diff --git a/elf/rtld.c b/elf/rtld.c
> index fc221ac..ed0a86b 100644
> --- a/elf/rtld.c
> +++ b/elf/rtld.c
> @@ -1093,10 +1093,11 @@ of this helper program; chances are you did not intend to run this program.\n\
> /* Now the map for the main executable is available. */
> main_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
>
> - if (GL(dl_rtld_map).l_info[DT_SONAME] != NULL
> + if (__builtin_expect (mode, normal) == normal
> + && GL(dl_rtld_map).l_info[DT_SONAME] != NULL
> && main_map->l_info[DT_SONAME] != NULL
> && strcmp ((const char *) D_PTR (&GL(dl_rtld_map), l_info[DT_STRTAB])
> + GL(dl_rtld_map).l_info[DT_SONAME]->d_un.d_val,
> (const char *) D_PTR (main_map, l_info[DT_STRTAB])
> + main_map->l_info[DT_SONAME]->d_un.d_val) == 0)
> _dl_fatal_printf ("loader cannot load itself\n");
>
>
--
Carlos O'Donell
Mentor Graphics / CodeSourcery
carlos_odonell@mentor.com
carlos@codesourcery.com
+1 (613) 963 1026