]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0113-selftests-x86-ldt_gdt-Robustify-against-set_thread_a.patch
KPTI: add follow-up fixes
[pve-kernel.git] / patches / kernel / 0113-selftests-x86-ldt_gdt-Robustify-against-set_thread_a.patch
CommitLineData
321d628a
FG
1From bd7ec1093f8a0a743215207ebc14cc6947ea23a0 Mon Sep 17 00:00:00 2001
2From: Andy Lutomirski <luto@kernel.org>
3Date: Sat, 4 Nov 2017 04:19:49 -0700
e4cdf2a5 4Subject: [PATCH 113/241] selftests/x86/ldt_gdt: Robustify against
321d628a
FG
5 set_thread_area() and LAR oddities
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10CVE-2017-5754
11
12Bits 19:16 of LAR's result are undefined, and some upcoming
13improvements to the test case seem to trigger this. Mask off those
14bits to avoid spurious failures.
15
16commit 5b781c7e317f ("x86/tls: Forcibly set the accessed bit in TLS
17segments") adds a valid case in which LAR's output doesn't quite
18agree with set_thread_area()'s input. This isn't triggered in the
19test as is, but it will be if we start calling set_thread_area()
20with the accessed bit clear. Work around this discrepency.
21
22I've added a Fixes tag so that -stable can pick this up if neccesary.
23
24Signed-off-by: Andy Lutomirski <luto@kernel.org>
25Cc: Borislav Petkov <bpetkov@suse.de>
26Cc: Linus Torvalds <torvalds@linux-foundation.org>
27Cc: Peter Zijlstra <peterz@infradead.org>
28Cc: Thomas Gleixner <tglx@linutronix.de>
29Fixes: 5b781c7e317f ("x86/tls: Forcibly set the accessed bit in TLS segments")
30Link: http://lkml.kernel.org/r/b82f3f89c034b53580970ac865139fd8863f44e2.1509794321.git.luto@kernel.org
31Signed-off-by: Ingo Molnar <mingo@kernel.org>
32(cherry picked from commit d60ad744c9741586010d4bea286f09a063a90fbd)
33Signed-off-by: Andy Whitcroft <apw@canonical.com>
34Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
35(cherry picked from commit d4c2ffcf3efe0d9610919fd48f5a1a5e38c28c07)
36Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
37---
38 tools/testing/selftests/x86/ldt_gdt.c | 10 +++++++++-
39 1 file changed, 9 insertions(+), 1 deletion(-)
40
41diff --git a/tools/testing/selftests/x86/ldt_gdt.c b/tools/testing/selftests/x86/ldt_gdt.c
42index b9a22f18566a..b2c54f4673f2 100644
43--- a/tools/testing/selftests/x86/ldt_gdt.c
44+++ b/tools/testing/selftests/x86/ldt_gdt.c
45@@ -114,7 +114,15 @@ static void check_valid_segment(uint16_t index, int ldt,
46 return;
47 }
48
49- if (ar != expected_ar) {
50+ /* The SDM says "bits 19:16 are undefined". Thanks. */
51+ ar &= ~0xF0000;
52+
53+ /*
54+ * NB: Different Linux versions do different things with the
55+ * accessed bit in set_thread_area().
56+ */
57+ if (ar != expected_ar &&
58+ (ldt || ar != (expected_ar | AR_ACCESSED))) {
59 printf("[FAIL]\t%s entry %hu has AR 0x%08X but expected 0x%08X\n",
60 (ldt ? "LDT" : "GDT"), index, ar, expected_ar);
61 nerrs++;
62--
632.14.2
64