]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0090-x86-entry-64-Shrink-paranoid_exit_restore-and-make-l.patch
KPTI: add follow-up fixes
[pve-kernel.git] / patches / kernel / 0090-x86-entry-64-Shrink-paranoid_exit_restore-and-make-l.patch
CommitLineData
321d628a
FG
1From d8fdea47d7fc1177aa0843a49dc89422ac6f4fea Mon Sep 17 00:00:00 2001
2From: Andy Lutomirski <luto@kernel.org>
3Date: Thu, 2 Nov 2017 00:59:02 -0700
e4cdf2a5 4Subject: [PATCH 090/241] x86/entry/64: Shrink paranoid_exit_restore and make
321d628a
FG
5 labels local
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10CVE-2017-5754
11
12paranoid_exit_restore was a copy of restore_regs_and_return_to_kernel.
13Merge them and make the paranoid_exit internal labels local.
14
15Keeping .Lparanoid_exit makes the code a bit shorter because it
16allows a 2-byte jnz instead of a 5-byte jnz.
17
18Saves 96 bytes of text.
19
20( This is still a bit suboptimal in a non-CONFIG_TRACE_IRQFLAGS
21 kernel, but fixing that would make the code rather messy. )
22
23Signed-off-by: Andy Lutomirski <luto@kernel.org>
24Cc: Borislav Petkov <bpetkov@suse.de>
25Cc: Brian Gerst <brgerst@gmail.com>
26Cc: Dave Hansen <dave.hansen@intel.com>
27Cc: Linus Torvalds <torvalds@linux-foundation.org>
28Cc: Peter Zijlstra <peterz@infradead.org>
29Cc: Thomas Gleixner <tglx@linutronix.de>
30Link: http://lkml.kernel.org/r/510d66a1895cda9473c84b1086f0bb974f22de6a.1509609304.git.luto@kernel.org
31Signed-off-by: Ingo Molnar <mingo@kernel.org>
32(cherry picked from commit e53178328c9b96fbdbc719e78c93b5687ee007c3)
33Signed-off-by: Andy Whitcroft <apw@canonical.com>
34Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
35(cherry picked from commit fb53fe10add935c3d0eb63199e43426eaf3b4299)
36Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
37---
38 arch/x86/entry/entry_64.S | 13 +++++--------
39 1 file changed, 5 insertions(+), 8 deletions(-)
40
41diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
42index a1a86e782a0e..6995f7e08aa1 100644
43--- a/arch/x86/entry/entry_64.S
44+++ b/arch/x86/entry/entry_64.S
45@@ -1136,17 +1136,14 @@ ENTRY(paranoid_exit)
46 DISABLE_INTERRUPTS(CLBR_ANY)
47 TRACE_IRQS_OFF_DEBUG
48 testl %ebx, %ebx /* swapgs needed? */
49- jnz paranoid_exit_no_swapgs
50+ jnz .Lparanoid_exit_no_swapgs
51 TRACE_IRQS_IRETQ
52 SWAPGS_UNSAFE_STACK
53- jmp paranoid_exit_restore
54-paranoid_exit_no_swapgs:
55+ jmp .Lparanoid_exit_restore
56+.Lparanoid_exit_no_swapgs:
57 TRACE_IRQS_IRETQ_DEBUG
58-paranoid_exit_restore:
59- RESTORE_EXTRA_REGS
60- RESTORE_C_REGS
61- REMOVE_PT_GPREGS_FROM_STACK 8
62- INTERRUPT_RETURN
63+.Lparanoid_exit_restore:
64+ jmp restore_regs_and_return_to_kernel
65 END(paranoid_exit)
66
67 /*
68--
692.14.2
70