From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14091 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 3/3] crt: add dcrt1, with support for locating the dynamic loader at runtime Date: Sat, 27 Apr 2019 12:19:36 -0400 Message-ID: <20190427161936.GS23599@brightrain.aerifal.cx> References: <1556327609-27385-1-git-send-email-rodger.combs@gmail.com> <1556327609-27385-3-git-send-email-rodger.combs@gmail.com> <20190427085539.GJ26605@port70.net> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="191164"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-14107-gllmg-musl=m.gmane.org@lists.openwall.com Sat Apr 27 18:19:54 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1hKQ3N-000nVl-5L for gllmg-musl@m.gmane.org; Sat, 27 Apr 2019 18:19:53 +0200 Original-Received: (qmail 14120 invoked by uid 550); 27 Apr 2019 16:19:50 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 14099 invoked from network); 27 Apr 2019 16:19:49 -0000 Content-Disposition: inline In-Reply-To: <20190427085539.GJ26605@port70.net> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:14091 Archived-At: On Sat, Apr 27, 2019 at 10:55:40AM +0200, Szabolcs Nagy wrote: > * Rodger Combs [2019-04-26 20:13:29 -0500]: > > --- > > i think you need a lot more explanation about possible > use-cases, failure modes, toolchain requirements etc. I can elaborate a bit. This is long-desired functionality, to be able to produce dynamic-linked binaries which run without the presence of a "program interpreter" (dynamic linker) at a fixed absolute pathname and without wrapper scripts or similar. The idea is that the entry point works like static pie, performing sufficient self-relocation to begin execution without a dynamic linker, but then maps the dynamic linker into memory according to some search procedure that allows it to be found relative to the main executable's location. More on this later. The use case is distribution of dynamic musl-linked binaries that can easily be run on non-musl systems. Toolchain requirements are essentially nothing new, but the toolchain must be invoked in a different way (alternate crt1 file and passing --no-dynamic-linker to ld). The patches as submitted put this into the musl-gcc and musl-clang wrapper scripts, which is a decent way of testing, but these wrappers are not really intended for serious use, so going forward there should be some discussion of what might be an acceptable way to upstream this to gcc or at least include it in mcm in a way that's maintainable and doesn't conflict with upstream. Failure modes include at least: - Cannot be used with suid/sgid, at all. Needs to hard fail if invoked that way; otherwise it invites dangerous misuse. Currently this is not handled right. - Does not work if /proc is not mounted or /proc/self/exe is not available. (It might be better to work from AT_EXECFN but that has different semantics.) - Processes and honors LD_LIBRARY_PATH and (new) LD_LOADER_PATH. These could be wrong especially in the main intended usage case, a non-musl system. But that would affect ldso itself already. It's not a hard no at this point (needs discussion) but I'm skeptical of any use of environment from crt1. - Depends on ability to rewrite aux vector and program headers in some possibly fragile ways (seems mostly ok from what I remember; need to review again where we'll have a record we can look back at). There may be others I find when reviewing the patches in more detail, which I'm starting now. Rich