diff options
author | Kees Cook <keescook@chromium.org> | 2015-01-15 19:51:46 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2015-01-20 06:37:23 -0500 |
commit | f285f4a21c3253887caceed493089ece17579d59 (patch) | |
tree | 17d7cc4556d5a1b144b49f79064cdfa222789441 /arch/x86/boot | |
parent | 8abb850a03a3a8b11a0e92949e5b99d9cc178e35 (diff) |
x86, boot: Skip relocs when load address unchanged
On 64-bit, relocation is not required unless the load address gets
changed. Without this, relocations do unexpected things when the kernel
is above 4G.
Reported-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Tested-by: Thomas D. <whissi@whissi.de>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Junjie Mao <eternal.n08@gmail.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/20150116005146.GA4212@www.outflux.net
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/boot')
-rw-r--r-- | arch/x86/boot/compressed/misc.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index dcc1c536cc21..a950864a64da 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c | |||
@@ -373,6 +373,8 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap, | |||
373 | unsigned long output_len, | 373 | unsigned long output_len, |
374 | unsigned long run_size) | 374 | unsigned long run_size) |
375 | { | 375 | { |
376 | unsigned char *output_orig = output; | ||
377 | |||
376 | real_mode = rmode; | 378 | real_mode = rmode; |
377 | 379 | ||
378 | sanitize_boot_params(real_mode); | 380 | sanitize_boot_params(real_mode); |
@@ -421,7 +423,12 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap, | |||
421 | debug_putstr("\nDecompressing Linux... "); | 423 | debug_putstr("\nDecompressing Linux... "); |
422 | decompress(input_data, input_len, NULL, NULL, output, NULL, error); | 424 | decompress(input_data, input_len, NULL, NULL, output, NULL, error); |
423 | parse_elf(output); | 425 | parse_elf(output); |
424 | handle_relocations(output, output_len); | 426 | /* |
427 | * 32-bit always performs relocations. 64-bit relocations are only | ||
428 | * needed if kASLR has chosen a different load address. | ||
429 | */ | ||
430 | if (!IS_ENABLED(CONFIG_X86_64) || output != output_orig) | ||
431 | handle_relocations(output, output_len); | ||
425 | debug_putstr("done.\nBooting the kernel.\n"); | 432 | debug_putstr("done.\nBooting the kernel.\n"); |
426 | return output; | 433 | return output; |
427 | } | 434 | } |