mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: [PATCH 3/3] crt: add dcrt1, with support for locating the dynamic loader at runtime
Date: Sun, 28 Apr 2019 01:55:10 +0200	[thread overview]
Message-ID: <20190427235510.GL26605@port70.net> (raw)
In-Reply-To: <56F34851-93B5-43D7-8968-4316F0F76157@gmail.com>

* Rodger Combs <rodger.combs@gmail.com> [2019-04-27 17:51:17 -0500]:
> On Apr 27, 2019, at 12:19, Rich Felker <dalias@libc.org> wrote:
> > On Fri, Apr 26, 2019 at 08:13:29PM -0500, Rodger Combs wrote:
> >> +	secure = ((aux[0] & 0x7800) != 0x7800 || aux[AT_UID] != aux[AT_EUID]
> >> +		|| aux[AT_GID] != aux[AT_EGID] || aux[AT_SECURE]);
> > 
> > At this point we can just abort if secure != 0. There is unbounded
> > attack surface trying to load a (possibly relative) ldso with elevated
> > privileges.
> 
> No more so than dynlink.c normally has when loading other SOs. Like there, I don't follow $ORIGIN in secure mode, and additionally here I don't handle relative-to-cwd paths in secure mode. I don't see a problem with allowing a load from an absolute rpath, or from the hardcoded path, using this mechanism, though.
> Basically, I'm intending for this to be a feature that you could just turn on in your linker flags for everything you build, and get the functionality in the cases where you want it, at no significant cost in those where you don't.

i think the code should be written such that it is obvious
that user input cannot affect runtime behaviour in secure
mode in any way (in particular the loaded code).

> >> +	// Copy the program headers into an anonymous mapping
> >> +	new_hdr = mmap(0, (aux[AT_PHENT] * (aux[AT_PHNUM] + 2) + linker_len + PAGE_SIZE - 1) & -PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
> >> +	if (map_library_failed(new_hdr))
> >> +		goto error;
> > 
> > Can you remind us why patched program headers are needed? I think it
> > was absence of PT_PHDR or something...
> 
> Yeah, the linker doesn't add PT_PHDR when we tell it not to set a dynamic loader, and dynlink needs it.

there should be a strong reason to add fake program headers.
why is PT_PHDR required?
who uses PT_INTERP?


  reply	other threads:[~2019-04-27 23:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-27  1:13 [PATCH 1/3] ldso: when run via CLI, set auxv as if the app was loaded by the kernel Rodger Combs
2019-04-27  1:13 ` [PATCH 2/3] ldso: move (un)map_library functions to separate file Rodger Combs
2019-04-27  1:13 ` [PATCH 3/3] crt: add dcrt1, with support for locating the dynamic loader at runtime Rodger Combs
2019-04-27  8:55   ` Szabolcs Nagy
2019-04-27 16:19     ` Rich Felker
2019-04-27 17:19   ` Rich Felker
2019-04-27 22:51     ` Rodger Combs
2019-04-27 23:55       ` Szabolcs Nagy [this message]
2019-04-28  0:16         ` Rodger Combs
2019-04-28 11:07           ` Szabolcs Nagy
2019-04-28 16:28             ` Rich Felker
2019-04-28 16:12       ` Rich Felker
2019-09-10  4:56 [PATCH 1/3] ldso: when run via CLI, set auxv as if the app was loaded by the kernel Rodger Combs
2019-09-10  4:56 ` [PATCH 3/3] crt: add dcrt1, with support for locating the dynamic loader at runtime Rodger Combs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190427235510.GL26605@port70.net \
    --to=nsz@port70.net \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).