Skip to content

Commit e303a06

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull KVM fixes from Paolo Bonzini: "Three security fixes" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: KVM: nVMX: unconditionally cancel preemption timer in free_nested (CVE-2019-7221) KVM: x86: work around leak of uninitialized stack contents (CVE-2019-7222) kvm: fix kvm_ioctl_create_device() reference counting (CVE-2019-6974)
2 parents ee6c073 + ecec768 commit e303a06

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

arch/x86/kvm/vmx/nested.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ static void free_nested(struct kvm_vcpu *vcpu)
211211
if (!vmx->nested.vmxon && !vmx->nested.smm.vmxon)
212212
return;
213213

214+
hrtimer_cancel(&vmx->nested.preemption_timer);
214215
vmx->nested.vmxon = false;
215216
vmx->nested.smm.vmxon = false;
216217
free_vpid(vmx->nested.vpid02);

arch/x86/kvm/x86.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5116,6 +5116,13 @@ int kvm_read_guest_virt(struct kvm_vcpu *vcpu,
51165116
{
51175117
u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0;
51185118

5119+
/*
5120+
* FIXME: this should call handle_emulation_failure if X86EMUL_IO_NEEDED
5121+
* is returned, but our callers are not ready for that and they blindly
5122+
* call kvm_inject_page_fault. Ensure that they at least do not leak
5123+
* uninitialized kernel stack memory into cr2 and error code.
5124+
*/
5125+
memset(exception, 0, sizeof(*exception));
51195126
return kvm_read_guest_virt_helper(addr, val, bytes, vcpu, access,
51205127
exception);
51215128
}

virt/kvm/kvm_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3000,16 +3000,17 @@ static int kvm_ioctl_create_device(struct kvm *kvm,
30003000
if (ops->init)
30013001
ops->init(dev);
30023002

3003+
kvm_get_kvm(kvm);
30033004
ret = anon_inode_getfd(ops->name, &kvm_device_fops, dev, O_RDWR | O_CLOEXEC);
30043005
if (ret < 0) {
3006+
kvm_put_kvm(kvm);
30053007
mutex_lock(&kvm->lock);
30063008
list_del(&dev->vm_node);
30073009
mutex_unlock(&kvm->lock);
30083010
ops->destroy(dev);
30093011
return ret;
30103012
}
30113013

3012-
kvm_get_kvm(kvm);
30133014
cd->fd = ret;
30143015
return 0;
30153016
}

0 commit comments

Comments
 (0)