Commit b42e547c authored by Andy Whitcroft's avatar Andy Whitcroft Committed by Kleber Sacilotto de Souza

Revert "x86/enter: Use IBRS on syscall and interrupts"

CVE-2017-5753 (revert embargoed)
CVE-2017-5715 (revert embargoed)

This reverts commit 0e2f6c3e.
Signed-off-by: default avatarAndy Whitcroft <apw@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 10e23462
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include <asm/smap.h> #include <asm/smap.h>
#include <asm/pgtable_types.h> #include <asm/pgtable_types.h>
#include <asm/kaiser.h> #include <asm/kaiser.h>
#include <asm/spec_ctrl.h>
#include <linux/err.h> #include <linux/err.h>
/* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */ /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
...@@ -174,8 +173,6 @@ GLOBAL(entry_SYSCALL_64_after_swapgs) ...@@ -174,8 +173,6 @@ GLOBAL(entry_SYSCALL_64_after_swapgs)
pushq %r11 /* pt_regs->r11 */ pushq %r11 /* pt_regs->r11 */
sub $(6*8), %rsp /* pt_regs->bp, bx, r12-15 not saved */ sub $(6*8), %rsp /* pt_regs->bp, bx, r12-15 not saved */
ENABLE_IBRS
testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS) testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
jnz tracesys jnz tracesys
entry_SYSCALL_64_fastpath: entry_SYSCALL_64_fastpath:
...@@ -215,9 +212,6 @@ entry_SYSCALL_64_fastpath: ...@@ -215,9 +212,6 @@ entry_SYSCALL_64_fastpath:
movq RIP(%rsp), %rcx movq RIP(%rsp), %rcx
movq EFLAGS(%rsp), %r11 movq EFLAGS(%rsp), %r11
RESTORE_C_REGS_EXCEPT_RCX_R11 RESTORE_C_REGS_EXCEPT_RCX_R11
DISABLE_IBRS
/* /*
* This opens a window where we have a user CR3, but are * This opens a window where we have a user CR3, but are
* running in the kernel. This makes using the CS * running in the kernel. This makes using the CS
...@@ -361,8 +355,6 @@ GLOBAL(int_ret_from_sys_call) ...@@ -361,8 +355,6 @@ GLOBAL(int_ret_from_sys_call)
* perf profiles. Nothing jumps here. * perf profiles. Nothing jumps here.
*/ */
syscall_return_via_sysret: syscall_return_via_sysret:
DISABLE_IBRS
/* rcx and r11 are already restored (see code above) */ /* rcx and r11 are already restored (see code above) */
RESTORE_C_REGS_EXCEPT_RCX_R11 RESTORE_C_REGS_EXCEPT_RCX_R11
/* /*
...@@ -377,7 +369,6 @@ syscall_return_via_sysret: ...@@ -377,7 +369,6 @@ syscall_return_via_sysret:
USERGS_SYSRET64 USERGS_SYSRET64
opportunistic_sysret_failed: opportunistic_sysret_failed:
/* XXX: might we need a DISABLE_IBRS */
/* /*
* This opens a window where we have a user CR3, but are * This opens a window where we have a user CR3, but are
* running in the kernel. This makes using the CS * running in the kernel. This makes using the CS
...@@ -546,8 +537,6 @@ END(irq_entries_start) ...@@ -546,8 +537,6 @@ END(irq_entries_start)
SWAPGS SWAPGS
SWITCH_KERNEL_CR3 SWITCH_KERNEL_CR3
ENABLE_IBRS
/* /*
* We need to tell lockdep that IRQs are off. We can't do this until * We need to tell lockdep that IRQs are off. We can't do this until
* we fix gsbase, and we should do it before enter_from_user_mode * we fix gsbase, and we should do it before enter_from_user_mode
...@@ -606,7 +595,6 @@ GLOBAL(retint_user) ...@@ -606,7 +595,6 @@ GLOBAL(retint_user)
mov %rsp,%rdi mov %rsp,%rdi
call prepare_exit_to_usermode call prepare_exit_to_usermode
TRACE_IRQS_IRETQ TRACE_IRQS_IRETQ
DISABLE_IBRS
SWITCH_USER_CR3 SWITCH_USER_CR3
SWAPGS SWAPGS
jmp restore_regs_and_iret jmp restore_regs_and_iret
...@@ -1073,8 +1061,6 @@ ENTRY(paranoid_entry) ...@@ -1073,8 +1061,6 @@ ENTRY(paranoid_entry)
movq %rax, %cr3 movq %rax, %cr3
2: 2:
#endif #endif
ENABLE_IBRS_CLOBBER
ret ret
END(paranoid_entry) END(paranoid_entry)
...@@ -1101,7 +1087,6 @@ ENTRY(paranoid_exit) ...@@ -1101,7 +1087,6 @@ ENTRY(paranoid_exit)
/* No ALTERNATIVE for X86_FEATURE_KAISER: paranoid_entry sets %ebx */ /* No ALTERNATIVE for X86_FEATURE_KAISER: paranoid_entry sets %ebx */
testl $2, %ebx /* SWITCH_USER_CR3 needed? */ testl $2, %ebx /* SWITCH_USER_CR3 needed? */
jz paranoid_exit_no_switch jz paranoid_exit_no_switch
DISABLE_IBRS
SWITCH_USER_CR3 SWITCH_USER_CR3
paranoid_exit_no_switch: paranoid_exit_no_switch:
#endif #endif
...@@ -1141,8 +1126,6 @@ ENTRY(error_entry) ...@@ -1141,8 +1126,6 @@ ENTRY(error_entry)
*/ */
SWAPGS SWAPGS
ENABLE_IBRS
.Lerror_entry_from_usermode_after_swapgs: .Lerror_entry_from_usermode_after_swapgs:
/* /*
* We need to tell lockdep that IRQs are off. We can't do this until * We need to tell lockdep that IRQs are off. We can't do this until
...@@ -1193,7 +1176,6 @@ ENTRY(error_entry) ...@@ -1193,7 +1176,6 @@ ENTRY(error_entry)
* We came from an IRET to user mode, so we have user gsbase. * We came from an IRET to user mode, so we have user gsbase.
* Switch to kernel gsbase: * Switch to kernel gsbase:
*/ */
ENABLE_IBRS_CLOBBER
SWAPGS SWAPGS
/* /*
...@@ -1344,7 +1326,6 @@ ENTRY(nmi) ...@@ -1344,7 +1326,6 @@ ENTRY(nmi)
movq %rax, %cr3 movq %rax, %cr3
2: 2:
#endif #endif
ENABLE_IBRS
call do_nmi call do_nmi
#ifdef CONFIG_KAISER #ifdef CONFIG_KAISER
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <asm/smap.h> #include <asm/smap.h>
#include <asm/pgtable_types.h> #include <asm/pgtable_types.h>
#include <asm/kaiser.h> #include <asm/kaiser.h>
#include <asm/spec_ctrl.h>
#include <linux/linkage.h> #include <linux/linkage.h>
#include <linux/err.h> #include <linux/err.h>
...@@ -100,8 +99,6 @@ ENTRY(entry_SYSENTER_compat) ...@@ -100,8 +99,6 @@ ENTRY(entry_SYSENTER_compat)
pushq %r8 /* pt_regs->r15 = 0 */ pushq %r8 /* pt_regs->r15 = 0 */
cld cld
ENABLE_IBRS
/* /*
* Sysenter doesn't filter flags, so we need to clear NT * Sysenter doesn't filter flags, so we need to clear NT
* ourselves. To save a few cycles, we can check whether * ourselves. To save a few cycles, we can check whether
...@@ -200,8 +197,6 @@ ENTRY(entry_SYSCALL_compat) ...@@ -200,8 +197,6 @@ ENTRY(entry_SYSCALL_compat)
pushq %r8 /* pt_regs->r14 = 0 */ pushq %r8 /* pt_regs->r14 = 0 */
pushq %r8 /* pt_regs->r15 = 0 */ pushq %r8 /* pt_regs->r15 = 0 */
ENABLE_IBRS
/* /*
* User mode is traced as though IRQs are on, and SYSENTER * User mode is traced as though IRQs are on, and SYSENTER
* turned them off. * turned them off.
...@@ -217,7 +212,6 @@ ENTRY(entry_SYSCALL_compat) ...@@ -217,7 +212,6 @@ ENTRY(entry_SYSCALL_compat)
/* Opportunistic SYSRET */ /* Opportunistic SYSRET */
sysret32_from_system_call: sysret32_from_system_call:
TRACE_IRQS_ON /* User mode traces as IRQs on. */ TRACE_IRQS_ON /* User mode traces as IRQs on. */
DISABLE_IBRS
SWITCH_USER_CR3 SWITCH_USER_CR3
movq RBX(%rsp), %rbx /* pt_regs->rbx */ movq RBX(%rsp), %rbx /* pt_regs->rbx */
movq RBP(%rsp), %rbp /* pt_regs->rbp */ movq RBP(%rsp), %rbp /* pt_regs->rbp */
...@@ -311,8 +305,6 @@ ENTRY(entry_INT80_compat) ...@@ -311,8 +305,6 @@ ENTRY(entry_INT80_compat)
pushq %r15 /* pt_regs->r15 */ pushq %r15 /* pt_regs->r15 */
cld cld
ENABLE_IBRS
/* /*
* User mode is traced as though IRQs are on, and the interrupt * User mode is traced as though IRQs are on, and the interrupt
* gate turned them off. * gate turned them off.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment