bin/171604: [patch] LD_PRELOAD set to not absolute path crashes
rtld
Mark Johnston
markjdb at gmail.com
Sat Sep 15 07:40:13 UTC 2012
The following reply was made to PR bin/171604; it has been noted by GNATS.
From: Mark Johnston <markjdb at gmail.com>
To: bug-followup at 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--
More information about the freebsd-bugs
mailing list