Skip to content

Commit

Permalink
x86_64: Ignore compat mode SYSCALL when IA32_EMULATION is not defined
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andi Kleen authored and Linus Torvalds committed Jun 23, 2007
1 parent e2f1f19 commit 75154f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions arch/x86_64/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -1163,3 +1163,10 @@ ENTRY(call_softirq)
ret
CFI_ENDPROC
ENDPROC(call_softirq)

KPROBE_ENTRY(ignore_sysret)
CFI_STARTPROC
mov $-ENOSYS,%eax
sysret
CFI_ENDPROC
ENDPROC(ignore_sysret)
3 changes: 3 additions & 0 deletions arch/x86_64/kernel/setup64.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ void pda_init(int cpu)
char boot_exception_stacks[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]
__attribute__((section(".bss.page_aligned")));

extern asmlinkage void ignore_sysret(void);

/* May not be marked __init: used by software suspend */
void syscall_init(void)
{
Expand All @@ -160,6 +162,7 @@ void syscall_init(void)
*/
wrmsrl(MSR_STAR, ((u64)__USER32_CS)<<48 | ((u64)__KERNEL_CS)<<32);
wrmsrl(MSR_LSTAR, system_call);
wrmsrl(MSR_CSTAR, ignore_sysret);

#ifdef CONFIG_IA32_EMULATION
syscall32_cpu_init ();
Expand Down

0 comments on commit 75154f4

Please sign in to comment.