about summary refs log tree commit diff
path: root/ports
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@redhat.com>2013-05-29 21:30:20 +0530
committerSiddhesh Poyarekar <siddhesh@redhat.com>2013-05-29 21:34:12 +0530
commitb937534868c8d7aec3b6d645bf5fd657bbfccd42 (patch)
tree18936faaea13f35bcaf698f97447752c0e1c4567 /ports
parentd0501bfbe228897c17875fcead8809d017135d6f (diff)
downloadglibc-b937534868c8d7aec3b6d645bf5fd657bbfccd42.tar.gz
glibc-b937534868c8d7aec3b6d645bf5fd657bbfccd42.tar.xz
glibc-b937534868c8d7aec3b6d645bf5fd657bbfccd42.zip
Avoid crashing in LD_DEBUG when program name is unavailable
Resolves: #15465

The program name may be unavailable if the user application tampers
with argc and argv[].  Some parts of the dynamic linker caters for
this while others don't, so this patch consolidates the check and
fallback into a single macro and updates all users.
Diffstat (limited to 'ports')
-rw-r--r--ports/ChangeLog.aarch646
-rw-r--r--ports/ChangeLog.arm7
-rw-r--r--ports/ChangeLog.hppa7
-rw-r--r--ports/ChangeLog.m68k6
-rw-r--r--ports/ChangeLog.microblaze6
-rw-r--r--ports/ChangeLog.mips10
-rw-r--r--ports/ChangeLog.tile6
-rw-r--r--ports/sysdeps/aarch64/dl-machine.h3
-rw-r--r--ports/sysdeps/arm/dl-machine.h6
-rw-r--r--ports/sysdeps/hppa/dl-machine.h5
-rw-r--r--ports/sysdeps/m68k/dl-machine.h3
-rw-r--r--ports/sysdeps/microblaze/dl-machine.h3
-rw-r--r--ports/sysdeps/mips/dl-lookup.c21
-rw-r--r--ports/sysdeps/mips/dl-machine.h3
-rw-r--r--ports/sysdeps/tile/dl-machine.h3
15 files changed, 64 insertions, 31 deletions
diff --git a/ports/ChangeLog.aarch64 b/ports/ChangeLog.aarch64
index aed68ef594..46def45f61 100644
--- a/ports/ChangeLog.aarch64
+++ b/ports/ChangeLog.aarch64
@@ -1,3 +1,9 @@
+2013-05-29  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+	[BZ #15465]
+	* sysdeps/aarch64/dl-machine.h (elf_machine_rela): Use
+	RTLD_PROGNAME.
+
 2013-05-23  Venkataranmanan Kumar  <venkataramanan.kumar@linaro.org>
 
 	* sysdeps/aarch64/machine-gmon.h: Remove.
diff --git a/ports/ChangeLog.arm b/ports/ChangeLog.arm
index dcf3605d0b..b1f14dfe64 100644
--- a/ports/ChangeLog.arm
+++ b/ports/ChangeLog.arm
@@ -1,3 +1,10 @@
+2013-05-29  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+	[BZ #15465]
+	* sysdeps/arm/dl-machine.h (elf_machine_rel): Use
+	RTLD_PROGNAME.
+	(elf_machine_rela): Likewise.
+
 2013-05-22  Joseph Myers  <joseph@codesourcery.com>
 
 	* sysdeps/arm/libm-test-ulps: Update test names.
diff --git a/ports/ChangeLog.hppa b/ports/ChangeLog.hppa
index 6a1cf1da05..f31de9a892 100644
--- a/ports/ChangeLog.hppa
+++ b/ports/ChangeLog.hppa
@@ -1,3 +1,10 @@
+2013-05-29  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+	[BZ #15465]
+	* sysdeps/hppa/dl-machine.h (elf_machine_rela): Use
+	RTLD_PROGNAME.
+	(elf_machine_rela_relative): Likewise.
+
 2013-05-22  Joseph Myers  <joseph@codesourcery.com>
 
 	* sysdeps/hppa/fpu/libm-test-ulps: Update test names.
diff --git a/ports/ChangeLog.m68k b/ports/ChangeLog.m68k
index 479f5e05f1..b5a0c6d56f 100644
--- a/ports/ChangeLog.m68k
+++ b/ports/ChangeLog.m68k
@@ -1,3 +1,9 @@
+2013-05-29  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+	[BZ #15465]
+	* sysdeps/m68k/dl-machine.h (elf_machine_rela): Use
+	RTLD_PROGNAME.
+
 2013-05-22  Joseph Myers  <joseph@codesourcery.com>
 
 	* sysdeps/m68k/coldfire/fpu/libm-test-ulps: Update test names.
diff --git a/ports/ChangeLog.microblaze b/ports/ChangeLog.microblaze
index f183b9ce0a..32fcfbc7cb 100644
--- a/ports/ChangeLog.microblaze
+++ b/ports/ChangeLog.microblaze
@@ -1,3 +1,9 @@
+2013-05-29  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+	[BZ #15465]
+	* sysdeps/microblaze/dl-machine.h (elf_machine_rela): Use
+	RTLD_PROGNAME.
+
 2013-05-22  Joseph Myers  <joseph@codesourcery.com>
 
 	* sysdeps/microblaze/libm-test-ulps: Update test names.
diff --git a/ports/ChangeLog.mips b/ports/ChangeLog.mips
index aff0572e22..a509992585 100644
--- a/ports/ChangeLog.mips
+++ b/ports/ChangeLog.mips
@@ -1,3 +1,13 @@
+2013-05-29  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+	[BZ #15465]
+	* sysdeps/mips/dl-lookup.c (do_lookup_x): Use DSO_FILENAME.
+	(add_dependency): Likewise.
+	(_dl_lookup_symbol_x): Likewise.
+	(_dl_debug_bindings): Likewise.
+	* sysdeps/mips/dl-machine.h (elf_machine_reloc): Use
+	RTLD_PROGNAME.
+
 2013-05-22  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>
 
 	* sysdeps/unix/sysv/linux/mips/bits/siginfo.h (siginfo_t): Add
diff --git a/ports/ChangeLog.tile b/ports/ChangeLog.tile
index 33ffa71fe6..dcfe00e529 100644
--- a/ports/ChangeLog.tile
+++ b/ports/ChangeLog.tile
@@ -1,3 +1,9 @@
+2013-05-29  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+	[BZ #15465]
+	* sysdeps/tile/dl-machine.h (elf_machine_rela): Use
+	RTLD_PROGNAME.
+
 2013-05-23  Chris Metcalf  <cmetcalf@tilera.com>
 
 	* sysdeps/tile/tilegx/Makefile ($(cflags-mcmodel-large)):
diff --git a/ports/sysdeps/aarch64/dl-machine.h b/ports/sysdeps/aarch64/dl-machine.h
index 702a7c0288..c91b0c42e0 100644
--- a/ports/sysdeps/aarch64/dl-machine.h
+++ b/ports/sysdeps/aarch64/dl-machine.h
@@ -257,8 +257,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
 	      strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
 	      _dl_error_printf ("\
 %s: Symbol `%s' has different size in shared object, consider re-linking\n",
-				rtld_progname ?: "<program name unknown>",
-				strtab + refsym->st_name);
+				RTLD_PROGNAME, strtab + refsym->st_name);
 	    }
 	  memcpy (reloc_addr_arg, (void *) value,
 		  MIN (sym->st_size, refsym->st_size));
diff --git a/ports/sysdeps/arm/dl-machine.h b/ports/sysdeps/arm/dl-machine.h
index 6e09aa107c..4cf87a99f9 100644
--- a/ports/sysdeps/arm/dl-machine.h
+++ b/ports/sysdeps/arm/dl-machine.h
@@ -398,8 +398,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
 	      strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
 	      _dl_error_printf ("\
 %s: Symbol `%s' has different size in shared object, consider re-linking\n",
-				rtld_progname ?: "<program name unknown>",
-				strtab + refsym->st_name);
+				RTLD_PROGNAME, strtab + refsym->st_name);
 	    }
 	  memcpy (reloc_addr_arg, (void *) value,
 		  MIN (sym->st_size, refsym->st_size));
@@ -560,8 +559,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
 	      strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
 	      _dl_error_printf ("\
 %s: Symbol `%s' has different size in shared object, consider re-linking\n",
-				rtld_progname ?: "<program name unknown>",
-				strtab + refsym->st_name);
+				RTLD_PROGNAME, strtab + refsym->st_name);
 	    }
 	  memcpy (reloc_addr_arg, (void *) value,
 		  MIN (sym->st_size, refsym->st_size));
diff --git a/ports/sysdeps/hppa/dl-machine.h b/ports/sysdeps/hppa/dl-machine.h
index a66be7ba4a..d2411a654a 100644
--- a/ports/sysdeps/hppa/dl-machine.h
+++ b/ports/sysdeps/hppa/dl-machine.h
@@ -673,8 +673,7 @@ elf_machine_rela (struct link_map *map,
 	  strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
 	  _dl_error_printf ("%s: Symbol `%s' has different size in shared object, "
 			    "consider re-linking\n",
-			    rtld_progname ?: "<program name unknown>",
-			    strtab + refsym->st_name);
+			    RTLD_PROGNAME, strtab + refsym->st_name);
 	}
       memcpy (reloc_addr_arg, (void *) value,
 	      MIN (sym->st_size, refsym->st_size));
@@ -730,7 +729,7 @@ elf_machine_rela_relative (Elf32_Addr l_addr,
   if (ELF32_R_SYM (reloc->r_info) != 0){
     _dl_error_printf ("%s: In elf_machine_rela_relative "
 		      "ELF32_R_SYM (reloc->r_info) != 0. Aborting.",
-		      rtld_progname ?: "<program name unknown>");
+		      RTLD_PROGNAME);
     ABORT_INSTRUCTION;  /* Crash. */
   }
 
diff --git a/ports/sysdeps/m68k/dl-machine.h b/ports/sysdeps/m68k/dl-machine.h
index b2ead16a00..acaabc1e1e 100644
--- a/ports/sysdeps/m68k/dl-machine.h
+++ b/ports/sysdeps/m68k/dl-machine.h
@@ -238,8 +238,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
 	      strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
 	      _dl_error_printf ("\
 %s: Symbol `%s' has different size in shared object, consider re-linking\n",
-				rtld_progname ?: "<program name unknown>",
-				strtab + refsym->st_name);
+				RTLD_PROGNAME, strtab + refsym->st_name);
 	    }
 	  memcpy (reloc_addr_arg, (void *) value,
 		  MIN (sym->st_size, refsym->st_size));
diff --git a/ports/sysdeps/microblaze/dl-machine.h b/ports/sysdeps/microblaze/dl-machine.h
index 7471bdd84f..ad1fc3ef37 100644
--- a/ports/sysdeps/microblaze/dl-machine.h
+++ b/ports/sysdeps/microblaze/dl-machine.h
@@ -240,8 +240,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
 	      strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
 	      _dl_error_printf ("\
 %s: Symbol `%s' has different size in shared object, consider re-linking\n",
-				rtld_progname ?: "<program name unknown>",
-				strtab + refsym->st_name);
+				RTLD_PROGNAME, strtab + refsym->st_name);
 	    }
 	  memcpy (reloc_addr_arg, (void *) value,
 		  MIN (sym->st_size, refsym->st_size));
diff --git a/ports/sysdeps/mips/dl-lookup.c b/ports/sysdeps/mips/dl-lookup.c
index 02090e5e52..6d8f744246 100644
--- a/ports/sysdeps/mips/dl-lookup.c
+++ b/ports/sysdeps/mips/dl-lookup.c
@@ -114,7 +114,7 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash,
       if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SYMBOLS, 0))
 	_dl_debug_printf ("symbol=%s;  lookup in file=%s [%lu]\n",
 			  undef_name,
-			  map->l_name[0] ? map->l_name : rtld_progname,
+			  DSO_FILENAME (map->l_name),
 			  map->l_ns);
 
       /* If the hash table is empty there is nothing to do here.  */
@@ -684,10 +684,9 @@ add_dependency (struct link_map *undef_map, struct link_map *map, int flags)
       if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0))
 	_dl_debug_printf ("\
 \nfile=%s [%lu];  needed by %s [%lu] (relocation dependency)\n\n",
-			  map->l_name[0] ? map->l_name : rtld_progname,
+			  DSO_FILENAME (map->l_name),
 			  map->l_ns,
-			  undef_map->l_name[0]
-			  ? undef_map->l_name : rtld_progname,
+			  DSO_FILENAME (undef_map->l_name),
 			  undef_map->l_ns);
     }
   else
@@ -768,9 +767,7 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map,
 	  const char *reference_name = undef_map ? undef_map->l_name : NULL;
 
 	  /* XXX We cannot translate the message.  */
-	  _dl_signal_cerror (0, (reference_name[0]
-				 ? reference_name
-				 : (rtld_progname ?: "<main program>")),
+	  _dl_signal_cerror (0, DSO_FILENAME (reference_name),
 			     N_("relocation error"),
 			     make_string ("symbol ", undef_name, ", version ",
 					  version->name,
@@ -797,9 +794,7 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map,
 				     ? version->name : "");
 
 	  /* XXX We cannot translate the message.  */
-	  _dl_signal_cerror (0, (reference_name[0]
-				 ? reference_name
-				 : (rtld_progname ?: "<main program>")),
+	  _dl_signal_cerror (0, DSO_FILENAME (reference_name),
 			     N_("symbol lookup error"),
 			     make_string (undefined_msg, undef_name,
 					  versionstr, versionname));
@@ -929,11 +924,9 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map,
   if (GLRO(dl_debug_mask) & DL_DEBUG_BINDINGS)
     {
       _dl_debug_printf ("binding file %s [%lu] to %s [%lu]: %s symbol `%s'",
-			(reference_name[0]
-			 ? reference_name
-			 : (rtld_progname ?: "<main program>")),
+			DSO_FILENAME (reference_name),
 			undef_map->l_ns,
-			value->m->l_name[0] ? value->m->l_name : rtld_progname,
+			DSO_FILENAME (value->m->l_name),
 			value->m->l_ns,
 			protected ? "protected" : "normal", undef_name);
       if (version)
diff --git a/ports/sysdeps/mips/dl-machine.h b/ports/sysdeps/mips/dl-machine.h
index a7c784fec5..dae938f039 100644
--- a/ports/sysdeps/mips/dl-machine.h
+++ b/ports/sysdeps/mips/dl-machine.h
@@ -635,8 +635,7 @@ elf_machine_reloc (struct link_map *map, ElfW(Addr) r_info,
 	    strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
 	    _dl_error_printf ("\
   %s: Symbol `%s' has different size in shared object, consider re-linking\n",
-			      rtld_progname ?: "<program name unknown>",
-			      strtab + refsym->st_name);
+			      RTLD_PROGNAME, strtab + refsym->st_name);
 	  }
 	memcpy (reloc_addr, (void *) value,
 		MIN (sym->st_size, refsym->st_size));
diff --git a/ports/sysdeps/tile/dl-machine.h b/ports/sysdeps/tile/dl-machine.h
index 4e78bb8701..05aa2d826c 100644
--- a/ports/sysdeps/tile/dl-machine.h
+++ b/ports/sysdeps/tile/dl-machine.h
@@ -624,8 +624,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
           strtab = (const char *) D_PTR (map,l_info[DT_STRTAB]);
           _dl_error_printf ("%s: Symbol `%s' has different size in shared"
                             " object, consider re-linking\n",
-                            rtld_progname ?: "<program name unknown>",
-                            strtab + refsym->st_name);
+                            RTLD_PROGNAME, strtab + refsym->st_name);
         }
       memcpy (reloc_addr_arg, (void *) value,
               MIN (sym->st_size, refsym->st_size));