about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-05-30 01:55:40 -0400
committerUlrich Drepper <drepper@gmail.com>2011-05-30 01:55:40 -0400
commit01f16ab0a581838d44ad79e82c0c3e1691d8506e (patch)
tree3a86fd351888f646ad8ae26313570cddbaf1d52d /elf
parent7ae22829afb2b4ca531d1c00437d428f55d59341 (diff)
downloadglibc-01f16ab0a581838d44ad79e82c0c3e1691d8506e.tar.gz
glibc-01f16ab0a581838d44ad79e82c0c3e1691d8506e.tar.xz
glibc-01f16ab0a581838d44ad79e82c0c3e1691d8506e.zip
Prevent loader from loading itself
Diffstat (limited to 'elf')
-rw-r--r--elf/rtld.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/elf/rtld.c b/elf/rtld.c
index 174954bf3b..9eb9289ead 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -1076,6 +1076,14 @@ 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
+	  && 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");
+
       phdr = main_map->l_phdr;
       phnum = main_map->l_phnum;
       /* We overwrite here a pointer to a malloc()ed string.  But since