Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86_64: Ignore compat mode SYSCALL when IA32_EMULATION is not defined

Previously a program could switch to a compat mode segment and then
execute SYSCALL and it would jump to an uninitialized MSR and crash
the kernel.

Instead supply a dummy target for this case.

Pointed out by Jan Beulich

Cc: jbeulich@novell.com
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Andi Kleen and committed by
Linus Torvalds
75154f40 e2f1f192

+10
+7
arch/x86_64/kernel/entry.S
··· 1163 1163 ret 1164 1164 CFI_ENDPROC 1165 1165 ENDPROC(call_softirq) 1166 + 1167 + KPROBE_ENTRY(ignore_sysret) 1168 + CFI_STARTPROC 1169 + mov $-ENOSYS,%eax 1170 + sysret 1171 + CFI_ENDPROC 1172 + ENDPROC(ignore_sysret)
+3
arch/x86_64/kernel/setup64.c
··· 150 150 char boot_exception_stacks[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ] 151 151 __attribute__((section(".bss.page_aligned"))); 152 152 153 + extern asmlinkage void ignore_sysret(void); 154 + 153 155 /* May not be marked __init: used by software suspend */ 154 156 void syscall_init(void) 155 157 { ··· 162 160 */ 163 161 wrmsrl(MSR_STAR, ((u64)__USER32_CS)<<48 | ((u64)__KERNEL_CS)<<32); 164 162 wrmsrl(MSR_LSTAR, system_call); 163 + wrmsrl(MSR_CSTAR, ignore_sysret); 165 164 166 165 #ifdef CONFIG_IA32_EMULATION 167 166 syscall32_cpu_init ();