From owner-freebsd-bugs@FreeBSD.ORG Sat Sep 15 07:40:13 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6C191106566B for ; Sat, 15 Sep 2012 07:40:13 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 56E458FC0C for ; Sat, 15 Sep 2012 07:40:13 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q8F7eCUl082671 for ; Sat, 15 Sep 2012 07:40:12 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q8F7eCjd082658; Sat, 15 Sep 2012 07:40:12 GMT (envelope-from gnats) Date: Sat, 15 Sep 2012 07:40:12 GMT Message-Id: <201209150740.q8F7eCjd082658@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Mark Johnston Cc: Subject: Re: bin/171604: [patch] LD_PRELOAD set to not absolute path crashes rtld X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Mark Johnston List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Sep 2012 07:40:13 -0000 The following reply was made to PR bin/171604; it has been noted by GNATS. From: Mark Johnston 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 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--