summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Wellving <andreas.wellving@enea.com>2019-02-04 13:23:53 +0100
committerAndreas Wellving <andreas.wellving@enea.com>2019-02-04 13:23:53 +0100
commit838e3893300a078ef12aa1d8d8c2336df259d2e0 (patch)
treedb938905dfa867d6dfc766296d539ad5fcce4f1b
parentf2e51e17184ff2dd07e82de32281ac3fffa2228a (diff)
downloadenea-kernel-cache-838e3893300a078ef12aa1d8d8c2336df259d2e0.tar.gz
KVM: CVE-2018-19407
KVM: X86: Fix scan ioapic use-before-initialization References: https://nvd.nist.gov/vuln/detail/CVE-2018-19407 https://lkml.org/lkml/2018/11/20/580 Change-Id: I25db67cd123956dbcf240a99f316e914c283d0e2 Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
-rw-r--r--patches/cve/4.14.x.scc1
-rw-r--r--patches/cve/CVE-2018-19407-KVM-X86-Fix-scan-ioapic-use-before-initialization.patch112
2 files changed, 113 insertions, 0 deletions
diff --git a/patches/cve/4.14.x.scc b/patches/cve/4.14.x.scc
index f47c792..9a53416 100644
--- a/patches/cve/4.14.x.scc
+++ b/patches/cve/4.14.x.scc
@@ -10,3 +10,4 @@ patch CVE-2018-14610-btrfs-Check-that-each-block-group-has-corresponding-.patch
10patch CVE-2018-14611-btrfs-validate-type-when-reading-a-chunk.patch 10patch CVE-2018-14611-btrfs-validate-type-when-reading-a-chunk.patch
11patch CVE-2018-14614-f2fs-fix-to-do-sanity-check-with-cp_pack_start_sum.patch 11patch CVE-2018-14614-f2fs-fix-to-do-sanity-check-with-cp_pack_start_sum.patch
12patch CVE-2018-18690-xfs-don-t-fail-when-converting-shortform-attr-to-lon.patch 12patch CVE-2018-18690-xfs-don-t-fail-when-converting-shortform-attr-to-lon.patch
13patch CVE-2018-19407-KVM-X86-Fix-scan-ioapic-use-before-initialization.patch
diff --git a/patches/cve/CVE-2018-19407-KVM-X86-Fix-scan-ioapic-use-before-initialization.patch b/patches/cve/CVE-2018-19407-KVM-X86-Fix-scan-ioapic-use-before-initialization.patch
new file mode 100644
index 0000000..55cc7e4
--- /dev/null
+++ b/patches/cve/CVE-2018-19407-KVM-X86-Fix-scan-ioapic-use-before-initialization.patch
@@ -0,0 +1,112 @@
1From 83f00ab9a7c03e9f1410727d985b7fe9473002e1 Mon Sep 17 00:00:00 2001
2From: Wanpeng Li <wanpengli@tencent.com>
3Date: Tue, 20 Nov 2018 16:34:18 +0800
4Subject: [PATCH] KVM: X86: Fix scan ioapic use-before-initialization
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9commit e97f852fd4561e77721bb9a4e0ea9d98305b1e93 upstream.
10
11Reported by syzkaller:
12
13 BUG: unable to handle kernel NULL pointer dereference at 00000000000001c8
14 PGD 80000003ec4da067 P4D 80000003ec4da067 PUD 3f7bfa067 PMD 0
15 Oops: 0000 [#1] PREEMPT SMP PTI
16 CPU: 7 PID: 5059 Comm: debug Tainted: G OE 4.19.0-rc5 #16
17 RIP: 0010:__lock_acquire+0x1a6/0x1990
18 Call Trace:
19 lock_acquire+0xdb/0x210
20 _raw_spin_lock+0x38/0x70
21 kvm_ioapic_scan_entry+0x3e/0x110 [kvm]
22 vcpu_enter_guest+0x167e/0x1910 [kvm]
23 kvm_arch_vcpu_ioctl_run+0x35c/0x610 [kvm]
24 kvm_vcpu_ioctl+0x3e9/0x6d0 [kvm]
25 do_vfs_ioctl+0xa5/0x690
26 ksys_ioctl+0x6d/0x80
27 __x64_sys_ioctl+0x1a/0x20
28 do_syscall_64+0x83/0x6e0
29 entry_SYSCALL_64_after_hwframe+0x49/0xbe
30
31The reason is that the testcase writes hyperv synic HV_X64_MSR_SINT6 msr
32and triggers scan ioapic logic to load synic vectors into EOI exit bitmap.
33However, irqchip is not initialized by this simple testcase, ioapic/apic
34objects should not be accessed.
35This can be triggered by the following program:
36
37 #define _GNU_SOURCE
38
39 #include <endian.h>
40 #include <stdint.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <string.h>
44 #include <sys/syscall.h>
45 #include <sys/types.h>
46 #include <unistd.h>
47
48 uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff};
49
50 int main(void)
51 {
52 syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
53 long res = 0;
54 memcpy((void*)0x20000040, "/dev/kvm", 9);
55 res = syscall(__NR_openat, 0xffffffffffffff9c, 0x20000040, 0, 0);
56 if (res != -1)
57 r[0] = res;Backport
58 res = syscall(__NR_ioctl, r[0], 0xae01, 0);
59 if (res != -1)
60 r[1] = res;
61 res = syscall(__NR_ioctl, r[1], 0xae41, 0);
62 if (res != -1)
63 r[2] = res;
64 memcpy(
65 (void*)0x20000080,
66 "\x01\x00\x00\x00\x00\x5b\x61\xbb\x96\x00\x00\x40\x00\x00\x00\x00\x01\x00"
67 "\x08\x00\x00\x00\x00\x00\x0b\x77\xd1\x78\x4d\xd8\x3a\xed\xb1\x5c\x2e\x43"
68 "\xaa\x43\x39\xd6\xff\xf5\xf0\xa8\x98\xf2\x3e\x37\x29\x89\xde\x88\xc6\x33"
69 "\xfc\x2a\xdb\xb7\xe1\x4c\xac\x28\x61\x7b\x9c\xa9\xbc\x0d\xa0\x63\xfe\xfe"
70 "\xe8\x75\xde\xdd\x19\x38\xdc\x34\xf5\xec\x05\xfd\xeb\x5d\xed\x2e\xaf\x22"
71 "\xfa\xab\xb7\xe4\x42\x67\xd0\xaf\x06\x1c\x6a\x35\x67\x10\x55\xcb",
72 106);
73 syscall(__NR_ioctl, r[2], 0x4008ae89, 0x20000080);
74 syscall(__NR_ioctl, r[2], 0xae80, 0);
75 return 0;
76 }
77
78This patch fixes it by bailing out scan ioapic if ioapic is not initialized in
79kernel.
80
81CVE: CVE-2018-19407
82Upstream-Status: Backport
83
84Reported-by: Wei Wu <ww9210@gmail.com>
85Cc: Paolo Bonzini <pbonzini@redhat.com>
86Cc: Radim Krčmář <rkrcmar@redhat.com>
87Cc: Wei Wu <ww9210@gmail.com>
88Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
89Cc: stable@vger.kernel.org
90Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
91Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
92Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
93---
94 arch/x86/kvm/x86.c | 3 ++-
95 1 file changed, 2 insertions(+), 1 deletion(-)
96
97diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
98index 7c4d02dba110..f24329659bea 100644
99--- a/arch/x86/kvm/x86.c
100+++ b/arch/x86/kvm/x86.c
101@@ -6885,7 +6885,8 @@ static void vcpu_scan_ioapic(struct kvm_vcpu *vcpu)
102 else {
103 if (kvm_x86_ops->sync_pir_to_irr && vcpu->arch.apicv_active)
104 kvm_x86_ops->sync_pir_to_irr(vcpu);
105- kvm_ioapic_scan_entry(vcpu, vcpu->arch.ioapic_handled_vectors);
106+ if (ioapic_in_kernel(vcpu->kvm))
107+ kvm_ioapic_scan_entry(vcpu, vcpu->arch.ioapic_handled_vectors);
108 }
109 bitmap_or((ulong *)eoi_exit_bitmap, vcpu->arch.ioapic_handled_vectors,
110 vcpu_to_synic(vcpu)->vec_bitmap, 256);
111--
1122.19.2