From: tip-bot for Yinghai Lu <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: keescook@chromium.org, akpm@linux-foundation.org,
aryabinin@virtuozzo.com, bhe@redhat.com, hpa@zytor.com,
torvalds@linux-foundation.org, tglx@linutronix.de,
mingo@kernel.org, jpoimboe@redhat.com, peterz@infradead.org,
dvyukov@google.com, hjl.tools@gmail.com, brgerst@gmail.com,
bp@alien8.de, yinghai@kernel.org, linux-kernel@vger.kernel.org,
luto@kernel.org, dvlasenk@redhat.com
Subject: [tip:x86/boot] x86/KASLR: Allow randomization below the load address
Date: Sun, 26 Jun 2016 04:03:22 -0700 [thread overview]
Message-ID: <tip-e066cc47776a89bbdaf4184c0e75f7d389f9ab48@git.kernel.org> (raw)
In-Reply-To: <1464216334-17200-6-git-send-email-keescook@chromium.org>
Commit-ID: e066cc47776a89bbdaf4184c0e75f7d389f9ab48
Gitweb: http://git.kernel.org/tip/e066cc47776a89bbdaf4184c0e75f7d389f9ab48
Author: Yinghai Lu <yinghai@kernel.org>
AuthorDate: Wed, 25 May 2016 15:45:34 -0700
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sun, 26 Jun 2016 12:32:05 +0200
x86/KASLR: Allow randomization below the load address
Currently the kernel image physical address randomization's lower
boundary is the original kernel load address.
For bootloaders that load kernels into very high memory (e.g. kexec),
this means randomization takes place in a very small window at the
top of memory, ignoring the large region of physical memory below
the load address.
Since mem_avoid[] is already correctly tracking the regions that must be
avoided, this patch changes the minimum address to whatever is less:
512M (to conservatively avoid unknown things in lower memory) or the
load address. Now, for example, if the kernel is loaded at 8G, [512M,
8G) will be added to the list of possible physical memory positions.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
[ Rewrote the changelog, refactored the code to use min(). ]
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: H.J. Lu <hjl.tools@gmail.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1464216334-17200-6-git-send-email-keescook@chromium.org
[ Edited the changelog some more, plus the code comment as well. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/boot/compressed/kaslr.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index 36e2811..749c9e0 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -492,7 +492,7 @@ void choose_random_location(unsigned long input,
unsigned long output_size,
unsigned long *virt_addr)
{
- unsigned long random_addr;
+ unsigned long random_addr, min_addr;
/* By default, keep output position unchanged. */
*virt_addr = *output;
@@ -510,8 +510,15 @@ void choose_random_location(unsigned long input,
/* Record the various known unsafe memory ranges. */
mem_avoid_init(input, input_size, *output);
+ /*
+ * Low end of the randomization range should be the
+ * smaller of 512M or the initial kernel image
+ * location:
+ */
+ min_addr = min(*output, 512UL << 20);
+
/* Walk e820 and find a random address. */
- random_addr = find_random_phys_addr(*output, output_size);
+ random_addr = find_random_phys_addr(min_addr, output_size);
if (!random_addr) {
warn("KASLR disabled: could not find suitable E820 region!");
} else {
prev parent reply other threads:[~2016-06-26 11:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-25 22:45 [PATCH v9 0/5] x86/KASLR: Randomize virtual address separately Kees Cook
2016-05-25 22:45 ` [PATCH v9 1/5] x86/boot: Refuse to build with data relocations Kees Cook
2016-06-17 12:22 ` [tip:x86/boot] " tip-bot for Kees Cook
2016-06-26 11:01 ` tip-bot for Kees Cook
2016-05-25 22:45 ` [PATCH v9 2/5] x86/KASLR: Clarify identity map interface Kees Cook
2016-06-17 12:22 ` [tip:x86/boot] " tip-bot for Kees Cook
2016-06-26 11:02 ` tip-bot for Kees Cook
2016-05-25 22:45 ` [PATCH v9 3/5] x86/KASLR: Randomize virtual address separately Kees Cook
2016-06-17 8:20 ` Ingo Molnar
2016-06-17 8:35 ` Ingo Molnar
2016-06-17 12:22 ` [tip:x86/boot] " tip-bot for Baoquan He
2016-06-26 11:02 ` tip-bot for Baoquan He
2016-05-25 22:45 ` [PATCH v9 4/5] x86/KASLR: Add physical address randomization >4G Kees Cook
2016-06-17 12:23 ` [tip:x86/boot] x86/KASLR: Extend kernel image physical address randomization to addresses larger than 4G tip-bot for Kees Cook
2016-06-26 11:02 ` tip-bot for Kees Cook
2016-05-25 22:45 ` [PATCH v9 5/5] x86/KASLR: Allow randomization below load address Kees Cook
2016-06-17 8:47 ` Ingo Molnar
2016-06-17 15:44 ` Kees Cook
2016-06-17 18:44 ` Yinghai Lu
2016-06-17 12:23 ` [tip:x86/boot] x86/KASLR: Allow randomization below the " tip-bot for Yinghai Lu
2016-06-26 11:03 ` tip-bot for Yinghai Lu [this message]
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=tip-e066cc47776a89bbdaf4184c0e75f7d389f9ab48@git.kernel.org \
--to=tipbot@zytor.com \
--cc=akpm@linux-foundation.org \
--cc=aryabinin@virtuozzo.com \
--cc=bhe@redhat.com \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dvlasenk@redhat.com \
--cc=dvyukov@google.com \
--cc=hjl.tools@gmail.com \
--cc=hpa@zytor.com \
--cc=jpoimboe@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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.