From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4722 Path: news.gmane.org!not-for-mail From: u-igbb@aetey.se Newsgroups: gmane.linux.lib.musl.general Subject: be able to break inheritance of LD_LIBRARY_PATH Date: Fri, 28 Mar 2014 10:42:08 +0000 Message-ID: <20140328104208.GZ8221@example.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1396003368 495 80.91.229.3 (28 Mar 2014 10:42:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 28 Mar 2014 10:42:48 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4726-gllmg-musl=m.gmane.org@lists.openwall.com Fri Mar 28 11:42:55 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1WTUFQ-0003W6-Db for gllmg-musl@plane.gmane.org; Fri, 28 Mar 2014 11:42:52 +0100 Original-Received: (qmail 9456 invoked by uid 550); 28 Mar 2014 10:42:50 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 9448 invoked from network); 28 Mar 2014 10:42:50 -0000 X-T2-Spam-Status: No, hits=0.0 required=5.0 Received-SPF: none receiver=mailfe07.swip.net; client-ip=31.172.30.4; envelope-from=u-igbb@aetey.se Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Xref: news.gmane.org gmane.linux.lib.musl.general:4722 Archived-At: Hello, I was aware of musl for some time and now consider deploying it as a default library for new software builds, due to its very appealing virtues. Yet there is a small but important issue. For our software setup it is crucial (quite useful otherwise in general) to be able to specify the location of the dynamic libraries per binary/run _without_ the unconditional inheritance imposed by LD_LIBRARY_PATH. A very nice solution would be the ability to explicitely run a standalone dynamic loader, as implemented in both glibc and uclibc. We are heavily relying on this functionality. I do not know how hard it would be to teach the musl loader to be runnable standalone and which corner cases this might create. As a simpler approach I might suggest simply being able to drop LD_LIBRARY_PATH as soon as it has been read. An extra environment variable as a flag would do. Compared to a standalone loader this lacks the ability to run a binary with a different version of the loader/musl but at least makes it straightforward and safe to freely specify where to find other libraries. A naïve implementation might look as follows: --- src/ldso/dynlink.c.ori 2014-03-28 10:37:34.821317811 +0100 +++ src/ldso/dynlink.c 2014-03-28 11:21:16.828047766 +0100 @@ -962,6 +962,7 @@ size_t vdso_base; size_t *auxv; char **envp = argv+argc+1; + int forget_ld_library_path = 0; /* Find aux vector just past environ[] */ for (i=argc+1; argv[i]; i++) @@ -969,8 +970,19 @@ env_path = argv[i]+16; else if (!memcmp(argv[i], "LD_PRELOAD=", 11)) env_preload = argv[i]+11; + else if (!memcmp(argv[i], "FORGET_LD_LIBRARY_PATH=", 23)) + forget_ld_library_path = 1; auxv = (void *)(argv+i+1); + /* one _may_ wish to break the inheritance of LD_LIBRARY_PATH, + * the hack below only works if the corresponding memory is writable + * -- rl */ + if (forget_ld_library_path) + for (i=argc+1; argv[i]; i++) + if (!memcmp(argv[i], "LD_LIBRARY_PATH=", 16) || + !memcmp(argv[i], "FORGET_LD_LIBRARY_PATH=", 23)) + argv[i][0] = 'X'; + decode_vec(auxv, aux, AUX_CNT); /* Only trust user/env if kernel says we're not suid/sgid */ What do you think about this? Can this or something better be done? I would love to be able to go with musl. Regards, Rune