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

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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] Fix crash when tracing loaded objects


$ LD_TRACE_LOADED_OBJECTS=1 LD_DEBUG=libs /lib64/ld-linux-x86-64.so.2 libm.so.6 
      4160:     find library=libm.so.6 [0]; searching
      4160:      search cache=/etc/ld.so.cache
      4160:       trying file=/lib64/libm.so.6
Segmentation fault

Andreas.

2011-02-22  Andreas Schwab  <schwab@redhat.com>

	* elf/dl-load.c (open_verify): Check for NULL loader even if
	SHARED.
	(_dl_map_object): Likewise.
---
 elf/dl-load.c |   14 +++++---------
 1 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/elf/dl-load.c b/elf/dl-load.c
index 41b5ce7..e9e3876 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1,5 +1,5 @@
 /* Map in a shared object's segments from the file.
-   Copyright (C) 1995-2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 1995-2005, 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -1592,7 +1592,7 @@ open_verify (const char *name, struct filebuf *fbp, struct link_map *loader,
 #ifdef SHARED
   /* Give the auditing libraries a chance.  */
   if (__builtin_expect (GLRO(dl_naudit) > 0, 0) && whatcode != 0
-      && loader->l_auditing == 0)
+      && loader != NULL && loader->l_auditing == 0)
     {
       struct audit_ifaces *afct = GLRO(dl_audit);
       for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
@@ -2010,7 +2010,7 @@ _dl_map_object (struct link_map *loader, const char *name,
   /* Give the auditing libraries a chance to change the name before we
      try anything.  */
   if (__builtin_expect (GLRO(dl_naudit) > 0, 0)
-      && (loader == NULL || loader->l_auditing == 0))
+      && loader != NULL && loader->l_auditing == 0)
     {
       struct audit_ifaces *afct = GLRO(dl_audit);
       for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
@@ -2116,12 +2116,8 @@ _dl_map_object (struct link_map *loader, const char *name,
 
 	      /* If the loader has the DF_1_NODEFLIB flag set we must not
 		 use a cache entry from any of these directories.  */
-	      if (
-#ifndef SHARED
-		  /* 'l' is always != NULL for dynamically linked objects.  */
-		  l != NULL &&
-#endif
-		  __builtin_expect (l->l_flags_1 & DF_1_NODEFLIB, 0))
+	      if (l != NULL
+		  && __builtin_expect (l->l_flags_1 & DF_1_NODEFLIB, 0))
 		{
 		  const char *dirp = system_dirs;
 		  unsigned int cnt = 0;
-- 
1.7.4


-- 
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 250E 6F00 984E
"And now for something completely different."


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