diff options
author | Kees Cook <[email protected]> | 2014-09-11 09:19:31 -0700 |
---|---|---|
committer | Ingo Molnar <[email protected]> | 2014-09-19 13:04:29 +0200 |
commit | 0cacbfbeb5077b63d5d3cf6df88b14ac12ad584b (patch) | |
tree | 9bb11c6c1601404990f7ed17b3573c4d155b38f3 | |
parent | 43657ffb79eba5234333d8657457774c0d3bff46 (diff) |
x86/kaslr: Avoid the setup_data area when picking location
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 <[email protected]>
Tested-by: Baoquan He <[email protected]>
Cc: [email protected]
Cc: Vivek Goyal <[email protected]>
Cc: Rafael J. Wysocki <[email protected]>
Cc: Wei Yongjun <[email protected]>
Cc: Pavel Machek <[email protected]>
Cc: Linus Torvalds <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
-rw-r--r-- | arch/x86/boot/compressed/aslr.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/x86/boot/compressed/aslr.c b/arch/x86/boot/compressed/aslr.c index fc6091abedb7..d39189ba7f8e 100644 --- a/arch/x86/boot/compressed/aslr.c +++ b/arch/x86/boot/compressed/aslr.c @@ -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; } |