Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Sep 2012 07:40:12 GMT
From:      Mark Johnston <markjdb@gmail.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/171604: [patch] LD_PRELOAD set to not absolute path crashes rtld
Message-ID:  <201209150740.q8F7eCjd082658@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/171604; it has been noted by GNATS.

From: Mark Johnston <markjdb@gmail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/171604: [patch] LD_PRELOAD set to not absolute path crashes
 rtld
Date: Sat, 15 Sep 2012 03:39:39 -0400

 --45Z9DzgjV8m4Oswq
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Ok, so that fixed the segfault at least. I think the LD_PRELOAD handling
 is still incorrect. According to rtld(1), if LD_PRELOAD isn't an
 absolute path, then LD_LIBRARY_PATH and the standard library path
 (/lib:/usr/lib) should be searched. However, we're only searching
 LD_LIBRARY_PATH in this case at the moment:
 
 $ LD_PRELOAD=libc.so.7 ls
 Shared object "libc.so.7" not found
 $ LD_LIBRARY_PATH=/lib LD_PRELOAD=libc.so.7 ls
 <no errors>
 
 The attached patch addresses this problem as well.
 
 Thanks,
 -Mark
 
 --45Z9DzgjV8m4Oswq
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="rtld_crash.patch"
 
 diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
 index 050adbb..bd6d33a 100644
 --- a/libexec/rtld-elf/rtld.c
 +++ b/libexec/rtld-elf/rtld.c
 @@ -1471,9 +1471,10 @@ find_library(const char *xname, const Obj_Entry *refobj)
  	  (pathname = search_library_path(name, ld_library_path)) != NULL ||
  	  (objgiven &&
  	  (pathname = search_library_path(name, refobj->runpath)) != NULL) ||
 +	  (objgiven &&
  	  (pathname = search_library_path(name, gethints(refobj->z_nodeflib)))
 -	  != NULL ||
 -	  (objgiven && !refobj->z_nodeflib &&
 +	  != NULL) ||
 +	  (((objgiven && !refobj->z_nodeflib) || !objgiven) &&
  	  (pathname = search_library_path(name, STANDARD_LIBRARY_PATH)) != NULL))
  	    return (pathname);
      }
 
 --45Z9DzgjV8m4Oswq--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209150740.q8F7eCjd082658>