Skip to contentSkip to conversation

Patch "KVM: use after free in kvm_ioctl_create_device()" has been added to the 4.8-stable tree

PATCH [email protected] 1 participant 1 message Dec 5, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

KVM: use after free in kvm_ioctl_create_device()

to the 4.8-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
kvm-use-after-free-in-kvm_ioctl_create_device.patch
and it can be found in the queue-4.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From a0f1d21c1ccb1da66629627a74059dd7f5ac9c61 Mon Sep 17 00:00:00 2001

From: Dan Carpenter <[email protected]>
Date: Wed, 30 Nov 2016 22:21:05 +0300
Subject: KVM: use after free in kvm_ioctl_create_device()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

From: Dan Carpenter <[email protected]>

commit a0f1d21c1ccb1da66629627a74059dd7f5ac9c61 upstream.

We should move the ops->destroy(dev) after the list_del(&dev->vm_node) so that we don't use "dev" after freeing it.

Fixes a28ebea2adc4 ("KVM: Protect device ops->create and list_add with kvm->lock")
---
 virt/kvm/kvm_main.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
virt/kvm/kvm_main.c +1 -1
@@ -2852,10 +2852,10 @@ static int kvm_ioctl_create_device(struc
 
 	ret = anon_inode_getfd(ops->name, &kvm_device_fops, dev, O_RDWR | O_CLOEXEC);
 	if (ret < 0) {
-		ops->destroy(dev);
 		mutex_lock(&kvm->lock);
 		list_del(&dev->vm_node);
 		mutex_unlock(&kvm->lock);
+		ops->destroy(dev);
 		return ret;
 	}
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.8/drm-i915-don-t-touch-null-sg-on-i915_gem_object_get_pages_gtt-error.patch queue-4.8/kvm-use-after-free-in-kvm_ioctl_create_device.patch