1cea4bf
From patchwork Tue Sep 12 20:02:54 2017
1cea4bf
Content-Type: text/plain; charset="utf-8"
1cea4bf
MIME-Version: 1.0
1cea4bf
Content-Transfer-Encoding: 7bit
1cea4bf
Subject: kvm: nVMX: Don't allow L2 to access the hardware CR8
1cea4bf
From: Jim Mattson <jmattson@google.com>
1cea4bf
X-Patchwork-Id: 9950035
1cea4bf
Message-Id: <20170912200254.111560-1-jmattson@google.com>
1cea4bf
To: kvm@vger.kernel.org, P J P <ppandit@redhat.com>,
1cea4bf
 Paolo Bonzini <pbonzini@redhat.com>
1cea4bf
Cc: Jim Mattson <jmattson@google.com>
1cea4bf
Date: Tue, 12 Sep 2017 13:02:54 -0700
1cea4bf
1cea4bf
If L1 does not specify the "use TPR shadow" VM-execution control in
1cea4bf
vmcs12, then L0 must specify the "CR8-load exiting" and "CR8-store
1cea4bf
exiting" VM-execution controls in vmcs02. Failure to do so will give
1cea4bf
the L2 VM unrestricted read/write access to the hardware CR8.
1cea4bf
1cea4bf
This fixes CVE-2017-12154.
1cea4bf
1cea4bf
Signed-off-by: Jim Mattson <jmattson@google.com>
1cea4bf
---
1cea4bf
 arch/x86/kvm/vmx.c | 5 +++++
1cea4bf
 1 file changed, 5 insertions(+)
1cea4bf
1cea4bf
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
1cea4bf
index c6efc1f88b25..885b7eed4320 100644
1cea4bf
--- a/arch/x86/kvm/vmx.c
1cea4bf
+++ b/arch/x86/kvm/vmx.c
1cea4bf
@@ -10525,6 +10525,11 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
1cea4bf
 	if (exec_control & CPU_BASED_TPR_SHADOW) {
1cea4bf
 		vmcs_write64(VIRTUAL_APIC_PAGE_ADDR, -1ull);
1cea4bf
 		vmcs_write32(TPR_THRESHOLD, vmcs12->tpr_threshold);
1cea4bf
+	} else {
1cea4bf
+#ifdef CONFIG_X86_64
1cea4bf
+		exec_control |= CPU_BASED_CR8_LOAD_EXITING |
1cea4bf
+				CPU_BASED_CR8_STORE_EXITING;
1cea4bf
+#endif
1cea4bf
 	}
1cea4bf
 
1cea4bf
 	/*