From: Thomas Gleixner Date: Thu, 18 Jan 2018 15:28:26 +0000 (+0100) Subject: x86/mce: Make machine check speculation protected X-Git-Tag: v4.1.12-124.31.3~1173 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c7e7f9258186b53840f1c62104db19acfc2c1fbb;p=users%2Fjedix%2Flinux-maple.git x86/mce: Make machine check speculation protected commit 6f41c34d69eb005e7848716bbcafc979b35037d5 upstream. The machine check idtentry uses an indirect branch directly from the low level code. This evades the speculation protection. Replace it by a direct call into C code and issue the indirect call there so the compiler can apply the proper speculation protection. Signed-off-by: Thomas Gleixner Reviewed-by:Borislav Petkov Reviewed-by: David Woodhouse Niced-by: Peter Zijlstra Link: https://lkml.kernel.org/r/alpine.DEB.2.20.1801181626290.1847@nanos Signed-off-by: Greg Kroah-Hartman (cherry picked from commit f59e7ce17ba327245c8feb312d447b09d3b98eba) Orabug: 27477743 CVE: CVE-2017-5715 Signed-off-by: Daniel Jordan Conflicts: arch/x86/kernel/entry_64.S (dmj: patch had arch/x86/entry/entry_64.S) Signed-off-by: Konrad Rzeszutek Wilk Reviewed-by: Darren Kenny Reviewed-by: Pavel Tatashin --- diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h index bb3af3db6f22..49d8b21e520a 100644 --- a/arch/x86/include/asm/traps.h +++ b/arch/x86/include/asm/traps.h @@ -92,6 +92,7 @@ dotraplinkage int do_simd_coprocessor_error(struct pt_regs *, long); #ifdef CONFIG_X86_32 dotraplinkage int do_iret_error(struct pt_regs *, long); #endif +dotraplinkage void do_mce(struct pt_regs *, long); static inline int get_si_code(unsigned long condition) { diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index ff78767c42ee..d52ec9c1ae21 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -1728,6 +1728,11 @@ static int unexpected_machine_check(struct pt_regs *regs, long error_code) int (*machine_check_vector)(struct pt_regs *, long error_code) = unexpected_machine_check; +dotraplinkage void do_mce(struct pt_regs *regs, long error_code) +{ + machine_check_vector(regs, error_code); +} + /* * Called for each booted CPU to set up machine checks. * Must be called with preempt off: diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S index 7c31f57d4303..789860576b31 100644 --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S @@ -1469,7 +1469,7 @@ trace_idtentry page_fault do_page_fault has_error_code=1 idtentry async_page_fault do_async_page_fault has_error_code=1 #endif #ifdef CONFIG_X86_MCE -idtentry machine_check has_error_code=0 paranoid=1 do_sym=*machine_check_vector(%rip) +idtentry machine_check do_mce has_error_code=0 paranoid=1 #endif /*