[tip:x86/urgent] x86, boot: Skip relocs when load address unchanged
Commit-ID: f285f4a21c3253887caceed493089ece17579d59 Gitweb: http://git.kernel.org/tip/f285f4a21c3253887caceed493089ece17579d59 Author: Kees Cook AuthorDate: Thu, 15 Jan 2015 16:51:46 -0800 Committer: Thomas Gleixner CommitDate: Tue, 20 Jan 2015 12:37:23 +0100 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 Signed-off-by: Kees Cook Tested-by: Thomas D. Cc: Vivek Goyal Cc: Jan Beulich Cc: Junjie Mao Cc: Andi Kleen Cc: sta...@vger.kernel.org Link: http://lkml.kernel.org/r/20150116005146.ga4...@www.outflux.net Signed-off-by: Thomas Gleixner --- arch/x86/boot/compressed/misc.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index dcc1c53..a950864 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, unsigned long output_len, unsigned long run_size) { + unsigned char *output_orig = output; + real_mode = rmode; sanitize_boot_params(real_mode); @@ -421,7 +423,12 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap, debug_putstr("\nDecompressing Linux... "); decompress(input_data, input_len, NULL, NULL, output, NULL, error); parse_elf(output); - handle_relocations(output, output_len); + /* +* 32-bit always performs relocations. 64-bit relocations are only +* needed if kASLR has chosen a different load address. +*/ + if (!IS_ENABLED(CONFIG_X86_64) || output != output_orig) + handle_relocations(output, output_len); debug_putstr("done.\nBooting the kernel.\n"); return output; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/urgent] x86, boot: Skip relocs when load address unchanged
Commit-ID: f285f4a21c3253887caceed493089ece17579d59 Gitweb: http://git.kernel.org/tip/f285f4a21c3253887caceed493089ece17579d59 Author: Kees Cook keesc...@chromium.org AuthorDate: Thu, 15 Jan 2015 16:51:46 -0800 Committer: Thomas Gleixner t...@linutronix.de CommitDate: Tue, 20 Jan 2015 12:37:23 +0100 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 b...@redhat.com Signed-off-by: Kees Cook keesc...@chromium.org Tested-by: Thomas D. whi...@whissi.de Cc: Vivek Goyal vgo...@redhat.com Cc: Jan Beulich jbeul...@suse.com Cc: Junjie Mao eternal@gmail.com Cc: Andi Kleen a...@linux.intel.com Cc: sta...@vger.kernel.org Link: http://lkml.kernel.org/r/20150116005146.ga4...@www.outflux.net Signed-off-by: Thomas Gleixner t...@linutronix.de --- arch/x86/boot/compressed/misc.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index dcc1c53..a950864 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, unsigned long output_len, unsigned long run_size) { + unsigned char *output_orig = output; + real_mode = rmode; sanitize_boot_params(real_mode); @@ -421,7 +423,12 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap, debug_putstr(\nDecompressing Linux... ); decompress(input_data, input_len, NULL, NULL, output, NULL, error); parse_elf(output); - handle_relocations(output, output_len); + /* +* 32-bit always performs relocations. 64-bit relocations are only +* needed if kASLR has chosen a different load address. +*/ + if (!IS_ENABLED(CONFIG_X86_64) || output != output_orig) + handle_relocations(output, output_len); debug_putstr(done.\nBooting the kernel.\n); return output; } -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/