Change-Id: I07672d0166dfccdbdc65ec1830f244fb69857bac
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4611
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>
... | ... |
@@ -2,7 +2,7 @@ |
2 | 2 |
Summary: Kernel |
3 | 3 |
Name: linux-esx |
4 | 4 |
Version: 4.9.75 |
5 |
-Release: 2%{?dist} |
|
5 |
+Release: 3%{?dist} |
|
6 | 6 |
License: GPLv2 |
7 | 7 |
URL: http://www.kernel.org/ |
8 | 8 |
Group: System Environment/Kernel |
... | ... |
@@ -152,9 +152,8 @@ The Linux package contains the Linux kernel doc files |
152 | 152 |
%patch64 -p1 |
153 | 153 |
%patch65 -p1 |
154 | 154 |
%patch66 -p1 |
155 |
-#not ready yet |
|
156 |
-#%patch67 -p1 |
|
157 |
-#%patch68 -p1 |
|
155 |
+%patch67 -p1 |
|
156 |
+%patch68 -p1 |
|
158 | 157 |
|
159 | 158 |
%build |
160 | 159 |
# patch vmw_balloon driver |
... | ... |
@@ -251,7 +250,9 @@ ln -sf linux-%{uname_r}.cfg /boot/photon.cfg |
251 | 251 |
/usr/src/linux-headers-%{uname_r} |
252 | 252 |
|
253 | 253 |
%changelog |
254 |
-* Sun Jan 08 2018 Bo Gan <ganb@vmware.com> 4.9.75-2 |
|
254 |
+* Sun Jan 07 2018 Bo Gan <ganb@vmware.com> 4.9.75-3 |
|
255 |
+- Second Spectre fix, clear user controlled registers upon syscall entry |
|
256 |
+* Sun Jan 07 2018 Bo Gan <ganb@vmware.com> 4.9.75-2 |
|
255 | 257 |
- Initial Spectre fix |
256 | 258 |
* Fri Jan 05 2018 Anish Swaminathan <anishs@vmware.com> 4.9.75-1 |
257 | 259 |
- Version update to 4.9.75 |
... | ... |
@@ -2,7 +2,7 @@ |
2 | 2 |
Summary: Kernel |
3 | 3 |
Name: linux-secure |
4 | 4 |
Version: 4.9.75 |
5 |
-Release: 2%{?kat_build:.%kat_build}%{?dist} |
|
5 |
+Release: 3%{?kat_build:.%kat_build}%{?dist} |
|
6 | 6 |
License: GPLv2 |
7 | 7 |
URL: http://www.kernel.org/ |
8 | 8 |
Group: System Environment/Kernel |
... | ... |
@@ -169,9 +169,6 @@ EOF |
169 | 169 |
%patch10 -p1 |
170 | 170 |
%patch11 -p1 |
171 | 171 |
%patch12 -p1 |
172 |
-%patch13 -p1 |
|
173 |
-%patch14 -p1 |
|
174 |
-%patch15 -p1 |
|
175 | 172 |
%patch16 -p1 |
176 | 173 |
%patch17 -p1 |
177 | 174 |
%patch19 -p1 |
... | ... |
@@ -191,6 +188,7 @@ EOF |
191 | 191 |
%patch34 -p1 |
192 | 192 |
%patch35 -p1 |
193 | 193 |
|
194 |
+# spectre |
|
194 | 195 |
%patch50 -p1 |
195 | 196 |
%patch51 -p1 |
196 | 197 |
%patch52 -p1 |
... | ... |
@@ -208,9 +206,13 @@ EOF |
208 | 208 |
%patch64 -p1 |
209 | 209 |
%patch65 -p1 |
210 | 210 |
%patch66 -p1 |
211 |
-#not ready yet |
|
212 |
-#%patch67 -p1 |
|
213 |
-#%patch68 -p1 |
|
211 |
+%patch67 -p1 |
|
212 |
+%patch68 -p1 |
|
213 |
+ |
|
214 |
+# secure |
|
215 |
+%patch13 -p1 |
|
216 |
+%patch14 -p1 |
|
217 |
+%patch15 -p1 |
|
214 | 218 |
|
215 | 219 |
pushd .. |
216 | 220 |
%patch99 -p0 |
... | ... |
@@ -337,7 +339,9 @@ ln -sf linux-%{uname_r}.cfg /boot/photon.cfg |
337 | 337 |
/usr/src/linux-headers-%{uname_r} |
338 | 338 |
|
339 | 339 |
%changelog |
340 |
-* Sun Jan 08 2018 Bo Gan <ganb@vmware.com> 4.9.75-2 |
|
340 |
+* Sun Jan 07 2018 Bo Gan <ganb@vmware.com> 4.9.75-3 |
|
341 |
+- Second Spectre fix, clear user controlled registers upon syscall entry |
|
342 |
+* Sun Jan 07 2018 Bo Gan <ganb@vmware.com> 4.9.75-2 |
|
341 | 343 |
- Initial Spectre fix |
342 | 344 |
* Fri Jan 05 2018 Bo Gan <ganb@vmware.com> 4.9.75-1 |
343 | 345 |
- Verion update (fix Intel Meltdown) |
... | ... |
@@ -2,7 +2,7 @@ |
2 | 2 |
Summary: Kernel |
3 | 3 |
Name: linux |
4 | 4 |
Version: 4.9.75 |
5 |
-Release: 2%{?kat_build:.%kat_build}%{?dist} |
|
5 |
+Release: 3%{?kat_build:.%kat_build}%{?dist} |
|
6 | 6 |
License: GPLv2 |
7 | 7 |
URL: http://www.kernel.org/ |
8 | 8 |
Group: System Environment/Kernel |
... | ... |
@@ -195,9 +195,8 @@ This package contains the 'perf' performance analysis tools for Linux kernel. |
195 | 195 |
%patch64 -p1 |
196 | 196 |
%patch65 -p1 |
197 | 197 |
%patch66 -p1 |
198 |
-#not ready yet |
|
199 |
-#%patch67 -p1 |
|
200 |
-#%patch68 -p1 |
|
198 |
+%patch67 -p1 |
|
199 |
+%patch68 -p1 |
|
201 | 200 |
|
202 | 201 |
%if 0%{?kat_build:1} |
203 | 202 |
%patch1000 -p1 |
... | ... |
@@ -365,7 +364,9 @@ ln -sf %{name}-%{uname_r}.cfg /boot/photon.cfg |
365 | 365 |
/usr/share/doc/* |
366 | 366 |
|
367 | 367 |
%changelog |
368 |
-* Sun Jan 08 2018 Bo Gan <ganb@vmware.com> 4.9.75-2 |
|
368 |
+* Sun Jan 07 2018 Bo Gan <ganb@vmware.com> 4.9.75-3 |
|
369 |
+- Second Spectre fix, clear user controlled registers upon syscall entry |
|
370 |
+* Sun Jan 07 2018 Bo Gan <ganb@vmware.com> 4.9.75-2 |
|
369 | 371 |
- Initial Spectre fix |
370 | 372 |
* Fri Jan 05 2018 Anish Swaminathan <anishs@vmware.com> 4.9.75-1 |
371 | 373 |
- Version update to 4.9.75 |
... | ... |
@@ -12,72 +12,40 @@ for code hygiene. |
12 | 12 |
arch/x86/entry/entry_64.S | 13 ++++++++++--- |
13 | 13 |
2 files changed, 29 insertions(+), 3 deletions(-) |
14 | 14 |
|
15 |
-diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h |
|
16 |
-index 393a5bf..dba5ff7 100644 |
|
17 |
-+++ b/arch/x86/entry/calling.h |
|
18 |
-@@ -156,6 +156,25 @@ For 32-bit we have the following conventions - kernel is built with |
|
19 |
- popq %rbx |
|
20 |
- .endm |
|
21 |
- |
|
22 |
-+ .macro RESTORE_EXTRA_REGS offset=0 |
|
23 |
-+ movq 0*8+\offset(%rsp), %r15 |
|
24 |
-+ movq 1*8+\offset(%rsp), %r14 |
|
25 |
-+ movq 2*8+\offset(%rsp), %r13 |
|
26 |
-+ movq 3*8+\offset(%rsp), %r12 |
|
27 |
-+ movq 4*8+\offset(%rsp), %rbp |
|
28 |
-+ movq 5*8+\offset(%rsp), %rbx |
|
29 |
-+ UNWIND_HINT_REGS offset=\offset extra=0 |
|
30 |
-+ .endm |
|
31 |
-+ |
|
32 |
-+ .macro CLEAR_EXTRA_REGS |
|
33 |
-+ xorq %r15, %r15 |
|
34 |
-+ xorq %r14, %r14 |
|
35 |
-+ xorq %r13, %r13 |
|
36 |
-+ xorq %r12, %r12 |
|
37 |
-+ xorq %rbp, %rbp |
|
38 |
-+ xorq %rbx, %rbx |
|
39 |
-+ .endm |
|
40 |
-+ |
|
41 |
- .macro POP_C_REGS |
|
42 |
- popq %r11 |
|
43 |
- popq %r10 |
|
15 |
+ Removed arch/x86/entry/calling.h changes, as it's in 4.9 upstream already |
|
16 |
+ |
|
44 | 17 |
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S |
45 |
-index e58a78f..f65060a 100644 |
|
18 |
+index af4e581..9e31419 100644 |
|
46 | 19 |
--- a/arch/x86/entry/entry_64.S |
47 | 20 |
+++ b/arch/x86/entry/entry_64.S |
48 |
-@@ -235,9 +235,16 @@ GLOBAL(entry_SYSCALL_64_after_hwframe) |
|
21 |
+@@ -176,7 +176,14 @@ GLOBAL(entry_SYSCALL_64_after_swapgs) |
|
49 | 22 |
pushq %r9 /* pt_regs->r9 */ |
50 | 23 |
pushq %r10 /* pt_regs->r10 */ |
51 | 24 |
pushq %r11 /* pt_regs->r11 */ |
52 | 25 |
- sub $(6*8), %rsp /* pt_regs->bp, bx, r12-15 not saved */ |
53 | 26 |
+ sub $(6*8), %rsp /* pt_regs->bp, bx, r12-15 not used */ |
54 |
- UNWIND_HINT_REGS extra=0 |
|
55 |
- |
|
27 |
++ |
|
56 | 28 |
+ /* |
57 | 29 |
+ * Clear the unused extra regs for code hygiene. |
58 | 30 |
+ * Will restore the callee saved extra regs at end of syscall. |
59 | 31 |
+ */ |
60 | 32 |
+ SAVE_EXTRA_REGS |
61 |
-+ CLEAR_EXTRA_REGS |
|
62 |
-+ |
|
63 |
- TRACE_IRQS_OFF |
|
33 |
++ ZERO_EXTRA_REGS |
|
64 | 34 |
|
65 |
- STUFF_RSB |
|
66 |
-@@ -290,7 +297,9 @@ entry_SYSCALL_64_fastpath: |
|
35 |
+ /* |
|
36 |
+ * If we need to do entry work or if we guess we'll need to do |
|
37 |
+@@ -229,6 +236,7 @@ entry_SYSCALL_64_fastpath: |
|
67 | 38 |
TRACE_IRQS_ON /* user mode is traced as IRQs on */ |
68 | 39 |
movq RIP(%rsp), %rcx |
69 | 40 |
movq EFLAGS(%rsp), %r11 |
70 | 41 |
+ RESTORE_EXTRA_REGS |
71 |
- addq $6*8, %rsp /* skip extra regs -- they were preserved */ |
|
72 |
-+ |
|
73 |
- UNWIND_HINT_EMPTY |
|
74 |
- jmp .Lpop_c_regs_except_rcx_r11_and_sysret |
|
75 |
- |
|
76 |
-@@ -302,14 +311,12 @@ entry_SYSCALL_64_fastpath: |
|
42 |
+ RESTORE_C_REGS_EXCEPT_RCX_R11 |
|
43 |
+ /* |
|
44 |
+ * This opens a window where we have a user CR3, but are |
|
45 |
+@@ -249,19 +257,16 @@ entry_SYSCALL_64_fastpath: |
|
77 | 46 |
*/ |
78 | 47 |
TRACE_IRQS_ON |
79 |
- ENABLE_INTERRUPTS(CLBR_ANY) |
|
48 |
+ ENABLE_INTERRUPTS(CLBR_NONE) |
|
80 | 49 |
- SAVE_EXTRA_REGS |
81 | 50 |
movq %rsp, %rdi |
82 | 51 |
call syscall_return_slowpath /* returns with IRQs disabled */ |
... | ... |
@@ -89,6 +57,28 @@ index e58a78f..f65060a 100644 |
89 | 89 |
movq %rsp, %rdi |
90 | 90 |
call do_syscall_64 /* returns with IRQs disabled */ |
91 | 91 |
|
92 |
+ return_from_SYSCALL_64: |
|
93 |
+- RESTORE_EXTRA_REGS |
|
94 |
+ TRACE_IRQS_IRETQ /* we're about to change IF */ |
|
95 |
+ |
|
96 |
+ /* |
|
97 |
+@@ -331,6 +336,7 @@ return_from_SYSCALL_64: |
|
98 |
+ * perf profiles. Nothing jumps here. |
|
99 |
+ */ |
|
100 |
+ syscall_return_via_sysret: |
|
101 |
++ RESTORE_EXTRA_REGS |
|
102 |
+ /* rcx and r11 are already restored (see code above) */ |
|
103 |
+ RESTORE_C_REGS_EXCEPT_RCX_R11 |
|
104 |
+ /* |
|
105 |
+@@ -354,7 +360,7 @@ opportunistic_sysret_failed: |
|
106 |
+ */ |
|
107 |
+ SWITCH_USER_CR3 |
|
108 |
+ SWAPGS |
|
109 |
+- jmp restore_c_regs_and_iret |
|
110 |
++ jmp restore_regs_and_iret |
|
111 |
+ END(entry_SYSCALL_64) |
|
112 |
+ |
|
113 |
+ ENTRY(stub_ptregs_64) |
|
92 | 114 |
-- |
93 | 115 |
2.9.5 |
94 | 116 |
|
... | ... |
@@ -15,11 +15,11 @@ Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com> |
15 | 15 |
2 files changed, 25 insertions(+), 4 deletions(-) |
16 | 16 |
|
17 | 17 |
diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h |
18 |
-index dba5ff7..b4c6842 100644 |
|
18 |
+index 9a9e588..1439429 100644 |
|
19 | 19 |
--- a/arch/x86/entry/calling.h |
20 | 20 |
+++ b/arch/x86/entry/calling.h |
21 |
-@@ -156,6 +156,17 @@ For 32-bit we have the following conventions - kernel is built with |
|
22 |
- popq %rbx |
|
21 |
+@@ -129,6 +129,17 @@ For 32-bit we have the following conventions - kernel is built with |
|
22 |
+ SAVE_C_REGS_HELPER 0, 0, 0, 1, 0 |
|
23 | 23 |
.endm |
24 | 24 |
|
25 | 25 |
+ .macro CLEAR_R8_TO_R15 |
... | ... |
@@ -33,23 +33,33 @@ index dba5ff7..b4c6842 100644 |
33 | 33 |
+ xorq %r8, %r8 |
34 | 34 |
+ .endm |
35 | 35 |
+ |
36 |
- .macro RESTORE_EXTRA_REGS offset=0 |
|
37 |
- movq 0*8+\offset(%rsp), %r15 |
|
38 |
- movq 1*8+\offset(%rsp), %r14 |
|
36 |
+ .macro SAVE_EXTRA_REGS offset=0 |
|
37 |
+ movq %r15, 0*8+\offset(%rsp) |
|
38 |
+ movq %r14, 1*8+\offset(%rsp) |
|
39 | 39 |
diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S |
40 |
-index 574b599..7951358 100644 |
|
40 |
+index d76a976..9217245 100644 |
|
41 | 41 |
--- a/arch/x86/entry/entry_64_compat.S |
42 | 42 |
+++ b/arch/x86/entry/entry_64_compat.S |
43 |
-@@ -100,6 +100,8 @@ ENTRY(entry_SYSENTER_compat) |
|
44 |
- |
|
45 |
- STUFF_RSB |
|
43 |
+@@ -88,12 +88,14 @@ ENTRY(entry_SYSENTER_compat) |
|
44 |
+ pushq $0 /* pt_regs->r11 = 0 */ |
|
45 |
+ pushq %rbx /* pt_regs->rbx */ |
|
46 |
+ pushq %rbp /* pt_regs->rbp (will be overwritten) */ |
|
47 |
+- pushq $0 /* pt_regs->r12 = 0 */ |
|
48 |
+- pushq $0 /* pt_regs->r13 = 0 */ |
|
49 |
+- pushq $0 /* pt_regs->r14 = 0 */ |
|
50 |
+- pushq $0 /* pt_regs->r15 = 0 */ |
|
51 |
++ pushq %r12 /* pt_regs->r12 */ |
|
52 |
++ pushq %r13 /* pt_regs->r13 */ |
|
53 |
++ pushq %r14 /* pt_regs->r14 */ |
|
54 |
++ pushq %r15 /* pt_regs->r15 */ |
|
55 |
+ cld |
|
46 | 56 |
|
47 | 57 |
+ CLEAR_R8_TO_R15 |
48 | 58 |
+ |
49 | 59 |
/* |
50 | 60 |
* SYSENTER doesn't filter flags, so we need to clear NT and AC |
51 | 61 |
* ourselves. To save a few cycles, we can check whether |
52 |
-@@ -218,10 +220,12 @@ GLOBAL(entry_SYSCALL_compat_after_hwframe) |
|
62 |
+@@ -214,10 +217,12 @@ ENTRY(entry_SYSCALL_compat) |
|
53 | 63 |
pushq $0 /* pt_regs->r11 = 0 */ |
54 | 64 |
pushq %rbx /* pt_regs->rbx */ |
55 | 65 |
pushq %rbp /* pt_regs->rbp (will be overwritten) */ |
... | ... |
@@ -65,11 +75,11 @@ index 574b599..7951358 100644 |
65 | 65 |
+ CLEAR_R8_TO_R15 |
66 | 66 |
|
67 | 67 |
/* |
68 |
- * We just saved %rdi so it is safe to clobber. It is not |
|
69 |
-@@ -247,6 +251,10 @@ GLOBAL(entry_SYSCALL_compat_after_hwframe) |
|
68 |
+ * User mode is traced as though IRQs are on, and SYSENTER |
|
69 |
+@@ -234,6 +238,10 @@ ENTRY(entry_SYSCALL_compat) |
|
70 |
+ /* Opportunistic SYSRET */ |
|
70 | 71 |
sysret32_from_system_call: |
71 | 72 |
TRACE_IRQS_ON /* User mode traces as IRQs on. */ |
72 |
- DISABLE_IBRS_CLOBBER |
|
73 | 73 |
+ movq R15(%rsp), %r15 /* pt_regs->r15 */ |
74 | 74 |
+ movq R14(%rsp), %r14 /* pt_regs->r14 */ |
75 | 75 |
+ movq R13(%rsp), %r13 /* pt_regs->r13 */ |
... | ... |
@@ -77,9 +87,9 @@ index 574b599..7951358 100644 |
77 | 77 |
movq RBX(%rsp), %rbx /* pt_regs->rbx */ |
78 | 78 |
movq RBP(%rsp), %rbp /* pt_regs->rbp */ |
79 | 79 |
movq EFLAGS(%rsp), %r11 /* pt_regs->flags (in r11) */ |
80 |
-@@ -359,6 +367,8 @@ ENTRY(entry_INT80_compat) |
|
81 |
- |
|
82 |
- STUFF_RSB |
|
80 |
+@@ -331,6 +339,8 @@ ENTRY(entry_INT80_compat) |
|
81 |
+ pushq %r15 /* pt_regs->r15 */ |
|
82 |
+ cld |
|
83 | 83 |
|
84 | 84 |
+ CLEAR_R8_TO_R15 |
85 | 85 |
+ |