All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Yinghai Lu <yinghai@kernel.org>
Cc: Kees Cook <keescook@chromium.org>,
	Eric Northup <digitaleric@google.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"kernel-hardening@lists.openwall.com"
	<kernel-hardening@lists.openwall.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	the arch/x86 maintainers <x86@kernel.org>,
	Jarkko Sakkinen <jarkko.sakkinen@intel.com>,
	Matthew Garrett <mjg@redhat.com>,
	Matt Fleming <matt.fleming@intel.com>,
	Dan Rosenberg <drosenberg@vsecurity.com>,
	Julien Tinnes <jln@google.com>, Will Drewry <wad@chromium.org>
Subject: [kernel-hardening] Re: [PATCH 6/6] x86: kaslr: relocate base offset at boot
Date: Mon, 15 Apr 2013 19:34:16 -0700	[thread overview]
Message-ID: <516CB8A8.2080007@zytor.com> (raw)
In-Reply-To: <CAE9FiQWosJRz14HgSq0cDYfsdSsMO9Vpbjd4f5UL3R6KHmOK5Q@mail.gmail.com>

On 04/15/2013 03:38 PM, Yinghai Lu wrote:
> On Mon, Apr 15, 2013 at 3:07 PM, Kees Cook <keescook@chromium.org> wrote:
>> On Mon, Apr 15, 2013 at 3:00 PM, Yinghai Lu <yinghai@kernel.org> wrote:
>>> also do not overlap with boot_param, command_line, and initrd.
>>>
>>> and need to double check setup_header.init_size to make sure bss and
>>> etc will not
>>> fall into memory hole or reserved area in e820.
>>>
>>> also may need to setup page table for target position as bootloader may only
>>> has ident mapping only for loaded bzImage 64 areas.
>>>
>>> looks you are trying redo the work for bootloader to pick loaded phys addr.
>>
>> aslr.S's select_aslr_address uses z_extract_offset as the upper bound.

That seems really, really odd.

> so the decompressed image is not moved high?

This really seems wrong in so many ways.

If you relocate pre-decompression the amount of memory you need is given
by init_size:

#define ZO_INIT_SIZE    (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
#define VO_INIT_SIZE    (VO__end - VO__text)
#if ZO_INIT_SIZE > VO_INIT_SIZE
#define INIT_SIZE ZO_INIT_SIZE
#else
#define INIT_SIZE VO_INIT_SIZE
#endif
init_size:              .long INIT_SIZE         # kernel initialization size

In real life, VO_INIT_SIZE dominates almost every time.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.

WARNING: multiple messages have this Message-ID (diff)
From: "H. Peter Anvin" <hpa@zytor.com>
To: Yinghai Lu <yinghai@kernel.org>
Cc: Kees Cook <keescook@chromium.org>,
	Eric Northup <digitaleric@google.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"kernel-hardening@lists.openwall.com" 
	<kernel-hardening@lists.openwall.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	the arch/x86 maintainers <x86@kernel.org>,
	Jarkko Sakkinen <jarkko.sakkinen@intel.com>,
	Matthew Garrett <mjg@redhat.com>,
	Matt Fleming <matt.fleming@intel.com>,
	Dan Rosenberg <drosenberg@vsecurity.com>,
	Julien Tinnes <jln@google.com>, Will Drewry <wad@chromium.org>
Subject: Re: [PATCH 6/6] x86: kaslr: relocate base offset at boot
Date: Mon, 15 Apr 2013 19:34:16 -0700	[thread overview]
Message-ID: <516CB8A8.2080007@zytor.com> (raw)
In-Reply-To: <CAE9FiQWosJRz14HgSq0cDYfsdSsMO9Vpbjd4f5UL3R6KHmOK5Q@mail.gmail.com>

On 04/15/2013 03:38 PM, Yinghai Lu wrote:
> On Mon, Apr 15, 2013 at 3:07 PM, Kees Cook <keescook@chromium.org> wrote:
>> On Mon, Apr 15, 2013 at 3:00 PM, Yinghai Lu <yinghai@kernel.org> wrote:
>>> also do not overlap with boot_param, command_line, and initrd.
>>>
>>> and need to double check setup_header.init_size to make sure bss and
>>> etc will not
>>> fall into memory hole or reserved area in e820.
>>>
>>> also may need to setup page table for target position as bootloader may only
>>> has ident mapping only for loaded bzImage 64 areas.
>>>
>>> looks you are trying redo the work for bootloader to pick loaded phys addr.
>>
>> aslr.S's select_aslr_address uses z_extract_offset as the upper bound.

That seems really, really odd.

> so the decompressed image is not moved high?

This really seems wrong in so many ways.

If you relocate pre-decompression the amount of memory you need is given
by init_size:

#define ZO_INIT_SIZE    (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
#define VO_INIT_SIZE    (VO__end - VO__text)
#if ZO_INIT_SIZE > VO_INIT_SIZE
#define INIT_SIZE ZO_INIT_SIZE
#else
#define INIT_SIZE VO_INIT_SIZE
#endif
init_size:              .long INIT_SIZE         # kernel initialization size

In real life, VO_INIT_SIZE dominates almost every time.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


  parent reply	other threads:[~2013-04-16  2:34 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-12 20:13 [kernel-hardening] [PATCH v2 0/6] kernel ASLR Kees Cook
2013-04-12 20:13 ` Kees Cook
2013-04-12 20:13 ` [kernel-hardening] [PATCH 1/6] x86: relocs: generalize Elf structure names Kees Cook
2013-04-12 20:13   ` Kees Cook
2013-04-16 23:17   ` [tip:x86/kaslr] x86, relocs: Generalize ELF " tip-bot for Kees Cook
2013-04-12 20:13 ` [kernel-hardening] [PATCH 2/6] x86: relocs: consolidate processing logic Kees Cook
2013-04-12 20:13   ` Kees Cook
2013-04-16 23:18   ` [tip:x86/kaslr] x86, relocs: Consolidate " tip-bot for Kees Cook
2013-04-12 20:13 ` [kernel-hardening] [PATCH 3/6] x86: relocs: add 64-bit ELF support to relocs tool Kees Cook
2013-04-12 20:13   ` Kees Cook
2013-04-16 23:19   ` [tip:x86/kaslr] x86, relocs: Add " tip-bot for Kees Cook
2013-04-12 20:13 ` [kernel-hardening] [PATCH 4/6] x86: relocs: build separate 32/64-bit tools Kees Cook
2013-04-12 20:13   ` Kees Cook
2013-04-16 22:21   ` [kernel-hardening] " H. Peter Anvin
2013-04-16 22:21     ` H. Peter Anvin
2013-04-16 22:38     ` [kernel-hardening] " Kees Cook
2013-04-16 22:38       ` Kees Cook
2013-04-16 22:39       ` [kernel-hardening] " H. Peter Anvin
2013-04-16 22:39         ` H. Peter Anvin
2013-04-16 23:20   ` [tip:x86/kaslr] x86, relocs: Build " tip-bot for Kees Cook
2013-04-16 23:22   ` [tip:x86/kaslr] x86, relocs: Refactor the relocs tool to merge 32- and 64-bit ELF tip-bot for H. Peter Anvin
2013-04-12 20:13 ` [kernel-hardening] [PATCH 5/6] x86: kaslr: routines to choose random base offset Kees Cook
2013-04-12 20:13   ` Kees Cook
2013-04-14  0:11   ` [kernel-hardening] " Yinghai Lu
2013-04-14  0:11     ` Yinghai Lu
2013-04-12 20:13 ` [kernel-hardening] [PATCH 6/6] x86: kaslr: relocate base offset at boot Kees Cook
2013-04-12 20:13   ` Kees Cook
2013-04-14  0:37   ` [kernel-hardening] " Yinghai Lu
2013-04-14  0:37     ` Yinghai Lu
2013-04-14  3:06     ` [kernel-hardening] " H. Peter Anvin
2013-04-14  3:06       ` H. Peter Anvin
2013-04-15 21:06       ` [kernel-hardening] " Eric Northup
2013-04-15 21:06         ` Eric Northup
2013-04-15 21:25         ` [kernel-hardening] " H. Peter Anvin
2013-04-15 21:25           ` H. Peter Anvin
2013-04-15 21:41           ` [kernel-hardening] " Kees Cook
2013-04-15 21:41             ` Kees Cook
2013-04-15 21:44             ` [kernel-hardening] " Eric Northup
2013-04-15 21:44               ` Eric Northup
2013-04-15 21:46             ` [kernel-hardening] " H. Peter Anvin
2013-04-15 21:46               ` H. Peter Anvin
2013-04-15 21:59               ` [kernel-hardening] " Kees Cook
2013-04-15 21:59                 ` Kees Cook
2013-04-16  2:31                 ` [kernel-hardening] " H. Peter Anvin
2013-04-16  2:31                   ` H. Peter Anvin
2013-04-16  2:40                   ` [kernel-hardening] " H. Peter Anvin
2013-04-16  2:40                     ` H. Peter Anvin
2013-04-16 16:08                     ` [kernel-hardening] " Kees Cook
2013-04-16 16:08                       ` Kees Cook
2013-04-15 22:00               ` [kernel-hardening] " Yinghai Lu
2013-04-15 22:00                 ` Yinghai Lu
2013-04-15 22:07                 ` [kernel-hardening] " Kees Cook
2013-04-15 22:07                   ` Kees Cook
2013-04-15 22:38                   ` [kernel-hardening] " Yinghai Lu
2013-04-15 22:38                     ` Yinghai Lu
2013-04-15 22:42                     ` [kernel-hardening] " Kees Cook
2013-04-15 22:42                       ` Kees Cook
2013-04-15 22:57                       ` [kernel-hardening] " Yinghai Lu
2013-04-15 22:57                         ` Yinghai Lu
2013-04-16  2:34                     ` H. Peter Anvin [this message]
2013-04-16  2:34                       ` H. Peter Anvin
2013-04-16  2:36                 ` [kernel-hardening] " H. Peter Anvin
2013-04-16  2:36                   ` H. Peter Anvin
2013-04-16  2:56                   ` [kernel-hardening] " Yinghai Lu
2013-04-16  2:56                     ` Yinghai Lu
2013-04-16  3:02                     ` [kernel-hardening] " H. Peter Anvin
2013-04-16  3:02                       ` H. Peter Anvin
2013-04-16 13:08                       ` [kernel-hardening] " Ingo Molnar
2013-04-16 13:08                         ` Ingo Molnar
2013-04-16 13:27                         ` [kernel-hardening] " H. Peter Anvin
2013-04-16 13:27                           ` H. Peter Anvin
2013-04-16 18:08 ` [kernel-hardening] Re: [PATCH v2 0/6] kernel ASLR Kees Cook
2013-04-16 18:08   ` Kees Cook
2013-04-16 18:15   ` [kernel-hardening] " H. Peter Anvin
2013-04-16 18:15     ` H. Peter Anvin

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=516CB8A8.2080007@zytor.com \
    --to=hpa@zytor.com \
    --cc=digitaleric@google.com \
    --cc=drosenberg@vsecurity.com \
    --cc=jarkko.sakkinen@intel.com \
    --cc=jln@google.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt.fleming@intel.com \
    --cc=mingo@redhat.com \
    --cc=mjg@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=wad@chromium.org \
    --cc=x86@kernel.org \
    --cc=yinghai@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.