]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0191-x86-pti-Add-the-pti-cmdline-option-and-documentation.patch
revert buggy SCSI error handler commit
[pve-kernel.git] / patches / kernel / 0191-x86-pti-Add-the-pti-cmdline-option-and-documentation.patch
CommitLineData
321d628a
FG
1From d6b6a8fa92efd244f759ab8ded4ccaebac2b762c Mon Sep 17 00:00:00 2001
2From: Borislav Petkov <bp@suse.de>
3Date: Tue, 12 Dec 2017 14:39:52 +0100
633c5ed1 4Subject: [PATCH 191/242] x86/pti: Add the pti= cmdline option and
321d628a
FG
5 documentation
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10CVE-2017-5754
11
12Keep the "nopti" optional for traditional reasons.
13
14[ tglx: Don't allow force on when running on XEN PV and made 'on'
15 printout conditional ]
16
17Requested-by: Linus Torvalds <torvalds@linux-foundation.org>
18Signed-off-by: Borislav Petkov <bp@suse.de>
19Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
20Cc: Andy Lutomirski <luto@kernel.org>
21Cc: Andy Lutomirsky <luto@kernel.org>
22Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
23Cc: Borislav Petkov <bp@alien8.de>
24Cc: Brian Gerst <brgerst@gmail.com>
25Cc: Dave Hansen <dave.hansen@intel.com>
26Cc: Dave Hansen <dave.hansen@linux.intel.com>
27Cc: David Laight <David.Laight@aculab.com>
28Cc: Denys Vlasenko <dvlasenk@redhat.com>
29Cc: Eduardo Valentin <eduval@amazon.com>
30Cc: Greg KH <gregkh@linuxfoundation.org>
31Cc: H. Peter Anvin <hpa@zytor.com>
32Cc: Josh Poimboeuf <jpoimboe@redhat.com>
33Cc: Juergen Gross <jgross@suse.com>
34Cc: Linus Torvalds <torvalds@linux-foundation.org>
35Cc: Peter Zijlstra <peterz@infradead.org>
36Cc: Will Deacon <will.deacon@arm.com>
37Cc: aliguori@amazon.com
38Cc: daniel.gruss@iaik.tugraz.at
39Cc: hughd@google.com
40Cc: keescook@google.com
41Link: https://lkml.kernel.org/r/20171212133952.10177-1-bp@alien8.de
42Signed-off-by: Ingo Molnar <mingo@kernel.org>
43(cherry picked from commit 41f4c20b57a4890ea7f56ff8717cc83fefb8d537)
44Signed-off-by: Andy Whitcroft <apw@canonical.com>
45Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
46(cherry picked from commit 96d3670fa8f88989fb7c0be5172a1378143f3296)
47Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
48---
49 Documentation/admin-guide/kernel-parameters.txt | 6 ++++++
50 arch/x86/mm/pti.c | 26 ++++++++++++++++++++++++-
51 2 files changed, 31 insertions(+), 1 deletion(-)
52
53diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
54index e2a4608da5d2..b4d2edf316db 100644
55--- a/Documentation/admin-guide/kernel-parameters.txt
56+++ b/Documentation/admin-guide/kernel-parameters.txt
57@@ -3247,6 +3247,12 @@
58 pt. [PARIDE]
59 See Documentation/blockdev/paride.txt.
60
61+ pti= [X86_64]
62+ Control user/kernel address space isolation:
63+ on - enable
64+ off - disable
65+ auto - default setting
66+
67 pty.legacy_count=
68 [KNL] Number of legacy pty's. Overwrites compiled-in
69 default number.
70diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
71index 375f23a758bc..a13f6b109865 100644
72--- a/arch/x86/mm/pti.c
73+++ b/arch/x86/mm/pti.c
74@@ -54,21 +54,45 @@ static void __init pti_print_if_insecure(const char *reason)
75 pr_info("%s\n", reason);
76 }
77
78+static void __init pti_print_if_secure(const char *reason)
79+{
80+ if (!boot_cpu_has_bug(X86_BUG_CPU_INSECURE))
81+ pr_info("%s\n", reason);
82+}
83+
84 void __init pti_check_boottime_disable(void)
85 {
86+ char arg[5];
87+ int ret;
88+
89 if (hypervisor_is_type(X86_HYPER_XEN_PV)) {
90 pti_print_if_insecure("disabled on XEN PV.");
91 return;
92 }
93
94+ ret = cmdline_find_option(boot_command_line, "pti", arg, sizeof(arg));
95+ if (ret > 0) {
96+ if (ret == 3 && !strncmp(arg, "off", 3)) {
97+ pti_print_if_insecure("disabled on command line.");
98+ return;
99+ }
100+ if (ret == 2 && !strncmp(arg, "on", 2)) {
101+ pti_print_if_secure("force enabled on command line.");
102+ goto enable;
103+ }
104+ if (ret == 4 && !strncmp(arg, "auto", 4))
105+ goto autosel;
106+ }
107+
108 if (cmdline_find_option_bool(boot_command_line, "nopti")) {
109 pti_print_if_insecure("disabled on command line.");
110 return;
111 }
112
113+autosel:
114 if (!boot_cpu_has_bug(X86_BUG_CPU_INSECURE))
115 return;
116-
117+enable:
118 setup_force_cpu_cap(X86_FEATURE_PTI);
119 }
120
121--
1222.14.2
123