Skip to content

Commit

Permalink
x86/kaslr: Avoid the setup_data area when picking location
Browse files Browse the repository at this point in the history
The KASLR location-choosing logic needs to avoid the setup_data
list memory areas as well. Without this, it would be possible to
have the ASLR position stomp on the memory, ultimately causing
the boot to fail.

Signed-off-by: Kees Cook <keescook@chromium.org>
Tested-by: Baoquan He <bhe@redhat.com>
Cc: stable@vger.kernel.org
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/20140911161931.GA12001@www.outflux.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Kees Cook authored and Ingo Molnar committed Sep 19, 2014
1 parent 43657ff commit 0cacbfb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions arch/x86/boot/compressed/aslr.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,27 @@ static void mem_avoid_init(unsigned long input, unsigned long input_size,
static bool mem_avoid_overlap(struct mem_vector *img)
{
int i;
struct setup_data *ptr;

for (i = 0; i < MEM_AVOID_MAX; i++) {
if (mem_overlaps(img, &mem_avoid[i]))
return true;
}

/* Avoid all entries in the setup_data linked list. */
ptr = (struct setup_data *)(unsigned long)real_mode->hdr.setup_data;
while (ptr) {
struct mem_vector avoid;

avoid.start = (u64)ptr;
avoid.size = sizeof(*ptr) + ptr->len;

if (mem_overlaps(img, &avoid))
return true;

ptr = (struct setup_data *)(unsigned long)ptr->next;
}

return false;
}

Expand Down

0 comments on commit 0cacbfb

Please sign in to comment.