linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Micay <danielmicay@gmail.com>
To: Kees Cook <keescook@chromium.org>
Cc: Rik van Riel <riel@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Qualys Security Advisory <qsa@qualys.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	"x86@kernel.org" <x86@kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Dmitry Safonov <dsafonov@virtuozzo.com>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Grzegorz Andrejczuk <grzegorz.andrejczuk@intel.com>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"kernel-hardening@lists.openwall.com"
	<kernel-hardening@lists.openwall.com>
Subject: Re: [kernel-hardening] [PATCH] [RFC] binfmt_elf: Use ELF_ET_DYN_BASE only for PIE
Date: Wed, 21 Jun 2017 13:32:13 -0400	[thread overview]
Message-ID: <1498066333.27465.8.camel@gmail.com> (raw)
In-Reply-To: <CAGXu5jJGD5md4YZXadcFnw2WogoXfKtBSQmMa=Mm+CNe309F6w@mail.gmail.com>

On Wed, 2017-06-21 at 10:28 -0700, Kees Cook wrote:
> On Wed, Jun 21, 2017 at 10:27 AM, Daniel Micay <danielmicay@gmail.com>
> wrote:
> > On Wed, 2017-06-21 at 10:23 -0700, Kees Cook wrote:
> > > On Wed, Jun 21, 2017 at 5:07 AM, Rik van Riel <riel@redhat.com>
> > > wrote:
> > > > On Tue, 2017-06-20 at 22:58 -0700, Kees Cook wrote:
> > > > > +/* This is the base location for PIE (ET_DYN with INTERP)
> > > > > loads.
> > > > > */
> > > > > +#define ELF_ET_DYN_BASE              0x400000UL
> > > > 
> > > > This value is good for 32 bit binaries, but for 64
> > > > bit binaries you probably want to put ELF_ET_DYN_BASE
> > > > at 4GB or higher.
> > > > 
> > > > The latter is necessary because Android uses the
> > > > lower 4GB of address space for its JVM runtime,
> > > > with 32 bit pointers inside that part of the otherwise
> > > > 64 bit address space.
> > > > 
> > > > In other words:
> > > > 
> > > > #define ELF_ET_DYN_BASE (mmap_is_ia32() ? 0x400000UL :
> > > > 0x100000000UL)
> > > 
> > > Ah, interesting. Okay, that should be fine. I'll adjust it.
> > > 
> > > > > +++ b/fs/binfmt_elf.c
> > > > > 
> > > > > +                      * Therefore, programs are loaded offset
> > > > > from
> > > > > +                      * ELF_ET_DYN_BASE and loaders are
> > > > > loaded
> > > > > into the
> > > > > +                      * independently randomized mmap region
> > > > > (0
> > > > > load_bias
> > > > > +                      * without MAP_FIXED).
> > > > > +                      */
> > > > > +                     if (elf_interpreter) {
> > > > > +                             load_bias = ELF_ET_DYN_BASE;
> > > > > +                             if (current->flags &
> > > > > PF_RANDOMIZE)
> > > > > +                                     load_bias +=
> > > > > arch_mmap_rnd();
> > > > > +                             elf_flags |= MAP_FIXED;
> > > > > +                     } else
> > > > > +                             load_bias = 0;
> > > > > +
> > > > > +                     load_bias -= vaddr;
> > > > 
> > > > I like this, and the big comment telling people how it
> > > > works :)
> > > 
> > > Thanks! It looks like your patch for commenting load_bias never
> > > got
> > > picked up, so I've added some more comments for that and some
> > > other
> > > things too. (Mostly for all the stuff I have to read a few times
> > > when
> > > I look at this code.)
> > > 
> > > -Kees
> > > 
> > 
> > The stack rlimit calculation fix for space potentially lost to ASLR
> > is
> > probably still needed too, right?
> 
> Yes. Was that picked up by akpm already?
> 
> -Kees

I think it was dropped when the ET_DYN changes were dropped.

  reply	other threads:[~2017-06-21 17:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-21  5:58 [PATCH] [RFC] binfmt_elf: Use ELF_ET_DYN_BASE only for PIE Kees Cook
2017-06-21 12:07 ` [kernel-hardening] " Rik van Riel
2017-06-21 17:23   ` Kees Cook
2017-06-21 17:27     ` Daniel Micay
2017-06-21 17:28       ` Kees Cook
2017-06-21 17:32         ` Daniel Micay [this message]
2017-06-21 17:33           ` Kees Cook
2017-06-21 18:47           ` Rik van Riel

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=1498066333.27465.8.camel@gmail.com \
    --to=danielmicay@gmail.com \
    --cc=dsafonov@virtuozzo.com \
    --cc=grzegorz.andrejczuk@intel.com \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=qsa@qualys.com \
    --cc=riel@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    --cc=x86@kernel.org \
    --cc=yamada.masahiro@socionext.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.
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).