From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10781 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: ldd not working on ET_EXEC executables Date: Thu, 8 Dec 2016 17:41:21 -0500 Message-ID: <20161208224121.GP1555@brightrain.aerifal.cx> References: <20161206023325.GH1555@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1481236896 3346 195.159.176.226 (8 Dec 2016 22:41:36 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 8 Dec 2016 22:41:36 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-10794-gllmg-musl=m.gmane.org@lists.openwall.com Thu Dec 08 23:41:32 2016 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.84_2) (envelope-from ) id 1cF7Nb-0008TC-Oc for gllmg-musl@m.gmane.org; Thu, 08 Dec 2016 23:41:31 +0100 Original-Received: (qmail 23907 invoked by uid 550); 8 Dec 2016 22:41:34 -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 23885 invoked from network); 8 Dec 2016 22:41:33 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:10781 Archived-At: On Thu, Dec 08, 2016 at 04:30:42PM -0600, Laine Gholson wrote: > You mean RANDMMAP? PaX's RANDMMAP feature ignoring the address your requesting it (without MAP_FIXED) is perfectly valid, to quote POSIX: > "When MAP_FIXED is not set, the implementation uses addr in an implementation-defined manner to arrive at pa." > mmap2(0x10000, 73728, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x1234abcd It's _valid_, but it's a bad implementation choice; it makes it impossible to request a particular range, which is necessary for ldso/ldd to load non-PIE programs. > You're not passing MAP_FIXED to mmap() but are expecting the kernel to still use the address you're giving it, which is wrong. > (as a side note, glibc works and it uses MAP_FIXED) This is invalid, and a bug in glibc, as there's no way to know that you're not mapping over something that's already there (perhaps even the function that's calling mmap). You can only use MAP_FIXED to map over top of an existing mapping you already know about and intend to replace (same with dup2 and file descriptors), not an arbitrary address range. Rich > Thanks, > > Laine Gholson > > On 12/05/16 20:33, Rich Felker wrote: > >On Mon, Dec 05, 2016 at 07:39:32PM -0600, Laine Gholson wrote: > >>Hello, > >> > >>I am running musl on a ARM platform, and ldd won't work on a executable with the ET_EXEC type. > >> > >>running GNU ld 2.25.1, gcc 6.2.0, and musl 1.1.15-git-71-g54991729 > >> > >> $ gcc -fPIE -pie test.c -o test-pie > >> $ ldd test-pie > >> > >> $ gcc -fno-PIE -no-pie test.c -o test-nopie > >> $ ldd test-nopie > >>ldd: test-nopie: Not a valid dynamic program > >> $ elfedit --output-type DYN test-nopie > >> $ ldd test-nopie > >> > >> > >>Any idea why ldd says executables with the ET_EXEC type aren't valid? > > > >strace it; I suspect you'll find that mmap is not honoring the > >requested address. This is a bug introduced intentionally by grsec/pax > >and perhaps other hardened kernels. > > > >Rich > >