]> git.proxmox.com Git - pve-kernel.git/blob - patches/kernel/0191-x86-pti-Add-the-pti-cmdline-option-and-documentation.patch
86c56710e9c125f26f1fb18bc12e277ba141cee1
[pve-kernel.git] / patches / kernel / 0191-x86-pti-Add-the-pti-cmdline-option-and-documentation.patch
1 From d6b6a8fa92efd244f759ab8ded4ccaebac2b762c Mon Sep 17 00:00:00 2001
2 From: Borislav Petkov <bp@suse.de>
3 Date: Tue, 12 Dec 2017 14:39:52 +0100
4 Subject: [PATCH 191/233] x86/pti: Add the pti= cmdline option and
5 documentation
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 CVE-2017-5754
11
12 Keep 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
17 Requested-by: Linus Torvalds <torvalds@linux-foundation.org>
18 Signed-off-by: Borislav Petkov <bp@suse.de>
19 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
20 Cc: Andy Lutomirski <luto@kernel.org>
21 Cc: Andy Lutomirsky <luto@kernel.org>
22 Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
23 Cc: Borislav Petkov <bp@alien8.de>
24 Cc: Brian Gerst <brgerst@gmail.com>
25 Cc: Dave Hansen <dave.hansen@intel.com>
26 Cc: Dave Hansen <dave.hansen@linux.intel.com>
27 Cc: David Laight <David.Laight@aculab.com>
28 Cc: Denys Vlasenko <dvlasenk@redhat.com>
29 Cc: Eduardo Valentin <eduval@amazon.com>
30 Cc: Greg KH <gregkh@linuxfoundation.org>
31 Cc: H. Peter Anvin <hpa@zytor.com>
32 Cc: Josh Poimboeuf <jpoimboe@redhat.com>
33 Cc: Juergen Gross <jgross@suse.com>
34 Cc: Linus Torvalds <torvalds@linux-foundation.org>
35 Cc: Peter Zijlstra <peterz@infradead.org>
36 Cc: Will Deacon <will.deacon@arm.com>
37 Cc: aliguori@amazon.com
38 Cc: daniel.gruss@iaik.tugraz.at
39 Cc: hughd@google.com
40 Cc: keescook@google.com
41 Link: https://lkml.kernel.org/r/20171212133952.10177-1-bp@alien8.de
42 Signed-off-by: Ingo Molnar <mingo@kernel.org>
43 (cherry picked from commit 41f4c20b57a4890ea7f56ff8717cc83fefb8d537)
44 Signed-off-by: Andy Whitcroft <apw@canonical.com>
45 Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
46 (cherry picked from commit 96d3670fa8f88989fb7c0be5172a1378143f3296)
47 Signed-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
53 diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
54 index 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.
70 diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
71 index 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 --
122 2.14.2
123