]> git.proxmox.com Git - pve-kernel.git/blob - 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
1 From bd7ec1093f8a0a743215207ebc14cc6947ea23a0 Mon Sep 17 00:00:00 2001
2 From: Andy Lutomirski <luto@kernel.org>
3 Date: Sat, 4 Nov 2017 04:19:49 -0700
4 Subject: [PATCH 113/241] selftests/x86/ldt_gdt: Robustify against
5 set_thread_area() and LAR oddities
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 Bits 19:16 of LAR's result are undefined, and some upcoming
13 improvements to the test case seem to trigger this. Mask off those
14 bits to avoid spurious failures.
15
16 commit 5b781c7e317f ("x86/tls: Forcibly set the accessed bit in TLS
17 segments") adds a valid case in which LAR's output doesn't quite
18 agree with set_thread_area()'s input. This isn't triggered in the
19 test as is, but it will be if we start calling set_thread_area()
20 with the accessed bit clear. Work around this discrepency.
21
22 I've added a Fixes tag so that -stable can pick this up if neccesary.
23
24 Signed-off-by: Andy Lutomirski <luto@kernel.org>
25 Cc: Borislav Petkov <bpetkov@suse.de>
26 Cc: Linus Torvalds <torvalds@linux-foundation.org>
27 Cc: Peter Zijlstra <peterz@infradead.org>
28 Cc: Thomas Gleixner <tglx@linutronix.de>
29 Fixes: 5b781c7e317f ("x86/tls: Forcibly set the accessed bit in TLS segments")
30 Link: http://lkml.kernel.org/r/b82f3f89c034b53580970ac865139fd8863f44e2.1509794321.git.luto@kernel.org
31 Signed-off-by: Ingo Molnar <mingo@kernel.org>
32 (cherry picked from commit d60ad744c9741586010d4bea286f09a063a90fbd)
33 Signed-off-by: Andy Whitcroft <apw@canonical.com>
34 Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
35 (cherry picked from commit d4c2ffcf3efe0d9610919fd48f5a1a5e38c28c07)
36 Signed-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
41 diff --git a/tools/testing/selftests/x86/ldt_gdt.c b/tools/testing/selftests/x86/ldt_gdt.c
42 index 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 --
63 2.14.2
64