|
|
c996788 |
From f3b9db45027a40369fe13c4661c4249d1df8c8d0 Mon Sep 17 00:00:00 2001
|
|
|
c996788 |
From: Andrew Honig <ahonig@google.com>
|
|
|
c996788 |
Date: Wed, 18 Nov 2015 14:50:23 -0800
|
|
|
c996788 |
Subject: [PATCH] KVM: x86: Reload pit counters for all channels when restoring
|
|
|
c996788 |
state
|
|
|
c996788 |
|
|
|
c996788 |
Currently if userspace restores the pit counters with a count of 0
|
|
|
c996788 |
on channels 1 or 2 and the guest attempts to read the count on those
|
|
|
c996788 |
channels, then KVM will perform a mod of 0 and crash. This will ensure
|
|
|
c996788 |
that 0 values are converted to 65536 as per the spec.
|
|
|
c996788 |
|
|
|
c996788 |
This is CVE-2015-7513.
|
|
|
c996788 |
|
|
|
c996788 |
Signed-off-by: Andy Honig <ahonig@google.com>
|
|
|
c996788 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
c996788 |
[Backported to 4.3.y by Josh Boyer <jwboyer@fedoraproject.org>]
|
|
|
c996788 |
---
|
|
|
c996788 |
arch/x86/kvm/x86.c | 9 ++++++---
|
|
|
c996788 |
1 file changed, 6 insertions(+), 3 deletions(-)
|
|
|
c996788 |
|
|
|
c996788 |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
|
|
|
c996788 |
index 43609af03283..e124f9c8391e 100644
|
|
|
c996788 |
--- a/arch/x86/kvm/x86.c
|
|
|
c996788 |
+++ b/arch/x86/kvm/x86.c
|
|
|
c996788 |
@@ -3437,10 +3437,11 @@ static int kvm_vm_ioctl_get_pit(struct kvm *kvm, struct kvm_pit_state *ps)
|
|
|
c996788 |
static int kvm_vm_ioctl_set_pit(struct kvm *kvm, struct kvm_pit_state *ps)
|
|
|
c996788 |
{
|
|
|
c996788 |
int r = 0;
|
|
|
c996788 |
-
|
|
|
c996788 |
+ int i;
|
|
|
c996788 |
mutex_lock(&kvm->arch.vpit->pit_state.lock);
|
|
|
c996788 |
memcpy(&kvm->arch.vpit->pit_state, ps, sizeof(struct kvm_pit_state));
|
|
|
c996788 |
- kvm_pit_load_count(kvm, 0, ps->channels[0].count, 0);
|
|
|
c996788 |
+ for (i = 0; i < 3; i++)
|
|
|
c996788 |
+ kvm_pit_load_count(kvm, i, ps->channels[i].count, 0);
|
|
|
c996788 |
mutex_unlock(&kvm->arch.vpit->pit_state.lock);
|
|
|
c996788 |
return r;
|
|
|
c996788 |
}
|
|
|
c996788 |
@@ -3461,6 +3462,7 @@ static int kvm_vm_ioctl_get_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps)
|
|
|
c996788 |
static int kvm_vm_ioctl_set_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps)
|
|
|
c996788 |
{
|
|
|
c996788 |
int r = 0, start = 0;
|
|
|
c996788 |
+ int i;
|
|
|
c996788 |
u32 prev_legacy, cur_legacy;
|
|
|
c996788 |
mutex_lock(&kvm->arch.vpit->pit_state.lock);
|
|
|
c996788 |
prev_legacy = kvm->arch.vpit->pit_state.flags & KVM_PIT_FLAGS_HPET_LEGACY;
|
|
|
c996788 |
@@ -3470,7 +3472,8 @@ static int kvm_vm_ioctl_set_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps)
|
|
|
c996788 |
memcpy(&kvm->arch.vpit->pit_state.channels, &ps->channels,
|
|
|
c996788 |
sizeof(kvm->arch.vpit->pit_state.channels));
|
|
|
c996788 |
kvm->arch.vpit->pit_state.flags = ps->flags;
|
|
|
c996788 |
- kvm_pit_load_count(kvm, 0, kvm->arch.vpit->pit_state.channels[0].count, start);
|
|
|
c996788 |
+ for (i = 0; i < 3; i++)
|
|
|
c996788 |
+ kvm_pit_load_count(kvm, i, kvm->arch.vpit->pit_state.channels[i].count, start);
|
|
|
c996788 |
mutex_unlock(&kvm->arch.vpit->pit_state.lock);
|
|
|
c996788 |
return r;
|
|
|
c996788 |
}
|
|
|
c996788 |
--
|
|
|
c996788 |
2.5.0
|
|
|
c996788 |
|