Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1671839
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [kernel-hardening] [PATCH] [RFC] binfmt_elf: Use ELF_ET_DYN_BASE only for PIE |
| Date | 2017-06-21 19:40 +0200 |
| Message-ID | <tURLI-Mh-13@gated-at.bofh.it> (permalink) |
| References | (1 earlier) <tUMCm-5V5-29@gated-at.bofh.it> <tURC1-HR-9@gated-at.bofh.it> <tURC1-HR-11@gated-at.bofh.it> <tURC1-HR-7@gated-at.bofh.it> <tURLI-Mh-15@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed, Jun 21, 2017 at 10:32 AM, Daniel Micay <danielmicay@gmail.com> wrote:
> 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.
Ah! Rik, can you resend just the stack calculation fixes? I can Ack those.
-Kees
--
Kees Cook
Pixel Security
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] [RFC] binfmt_elf: Use ELF_ET_DYN_BASE only for PIE Kees Cook <keescook@chromium.org> - 2017-06-21 08:00 +0200
Re: [kernel-hardening] [PATCH] [RFC] binfmt_elf: Use ELF_ET_DYN_BASE only for PIE Rik van Riel <riel@redhat.com> - 2017-06-21 14:10 +0200
Re: [kernel-hardening] [PATCH] [RFC] binfmt_elf: Use ELF_ET_DYN_BASE only for PIE Kees Cook <keescook@chromium.org> - 2017-06-21 19:30 +0200
Re: [kernel-hardening] [PATCH] [RFC] binfmt_elf: Use ELF_ET_DYN_BASE only for PIE Kees Cook <keescook@chromium.org> - 2017-06-21 19:40 +0200
Re: [kernel-hardening] [PATCH] [RFC] binfmt_elf: Use ELF_ET_DYN_BASE only for PIE Daniel Micay <danielmicay@gmail.com> - 2017-06-21 19:40 +0200
Re: [kernel-hardening] [PATCH] [RFC] binfmt_elf: Use ELF_ET_DYN_BASE only for PIE Rik van Riel <riel@redhat.com> - 2017-06-21 20:50 +0200
Re: [kernel-hardening] [PATCH] [RFC] binfmt_elf: Use ELF_ET_DYN_BASE only for PIE Kees Cook <keescook@chromium.org> - 2017-06-21 19:30 +0200
Re: [kernel-hardening] [PATCH] [RFC] binfmt_elf: Use ELF_ET_DYN_BASE only for PIE Daniel Micay <danielmicay@gmail.com> - 2017-06-21 19:30 +0200
csiph-web