From: Neil Horman It appears that when the i386 arch traps on a machine check, the code in entry.S loads the vector pointed to by the machine_check_vector kernel varialbe. Since this happens before the switch to the kernel context in error_code, the result is an oops, if the reverenced address is unmapped, or silent memory corruption if the address is mapped. This patch corrects that, by jumping instead to a statically allocated kernel function instead, allowing us to load a static value, rather than the contents of a memory address before the switch to kernel context, like all of our other entry points do. Signed-off-by: Neil Horman Signed-off-by: Andrew Morton --- arch/i386/kernel/cpu/mcheck/mce.c | 5 +++++ arch/i386/kernel/cpu/mcheck/mce.h | 1 + arch/i386/kernel/entry.S | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff -puN arch/i386/kernel/cpu/mcheck/mce.c~i386-fix-machine_check-entry-point-in-entrys-to-not-dereference-kernel-memory-from-user-space-context arch/i386/kernel/cpu/mcheck/mce.c --- a/arch/i386/kernel/cpu/mcheck/mce.c~i386-fix-machine_check-entry-point-in-entrys-to-not-dereference-kernel-memory-from-user-space-context +++ a/arch/i386/kernel/cpu/mcheck/mce.c @@ -29,6 +29,11 @@ static fastcall void unexpected_machine_ /* Call the installed machine check handler for this CPU setup. */ void fastcall (*machine_check_vector)(struct pt_regs *, long error_code) = unexpected_machine_check; +asmlinkage void do_machine_check(struct pt_regs *regs, long error_code) +{ + machine_check_vector(regs, error_code); +} + /* This has to be run for each processor */ void mcheck_init(struct cpuinfo_x86 *c) { diff -puN arch/i386/kernel/cpu/mcheck/mce.h~i386-fix-machine_check-entry-point-in-entrys-to-not-dereference-kernel-memory-from-user-space-context arch/i386/kernel/cpu/mcheck/mce.h --- a/arch/i386/kernel/cpu/mcheck/mce.h~i386-fix-machine_check-entry-point-in-entrys-to-not-dereference-kernel-memory-from-user-space-context +++ a/arch/i386/kernel/cpu/mcheck/mce.h @@ -8,6 +8,7 @@ void winchip_mcheck_init(struct cpuinfo_ /* Call the installed machine check handler for this CPU setup. */ extern fastcall void (*machine_check_vector)(struct pt_regs *, long error_code); +extern asmlinkage void do_machine_check(struct pt_regs *, long error_code); extern int mce_disabled; extern int nr_mce_banks; diff -puN arch/i386/kernel/entry.S~i386-fix-machine_check-entry-point-in-entrys-to-not-dereference-kernel-memory-from-user-space-context arch/i386/kernel/entry.S --- a/arch/i386/kernel/entry.S~i386-fix-machine_check-entry-point-in-entrys-to-not-dereference-kernel-memory-from-user-space-context +++ a/arch/i386/kernel/entry.S @@ -964,7 +964,7 @@ ENTRY(machine_check) RING0_INT_FRAME pushl $0 CFI_ADJUST_CFA_OFFSET 4 - pushl machine_check_vector + pushl $do_machine_check CFI_ADJUST_CFA_OFFSET 4 jmp error_code CFI_ENDPROC _