[3.16.y-ckt stable] Patch "virtio_pci: fix use after free on release" has been added to the 3.16.y-ckt tree

Luis Henriques luis.henriques at canonical.com
Wed Feb 17 10:49:19 UTC 2016


This is a note to let you know that I have just added a patch titled

    virtio_pci: fix use after free on release

to the linux-3.16.y-queue branch of the 3.16.y-ckt extended stable tree 
which can be found at:

    http://kernel.ubuntu.com/git/ubuntu/linux.git/log/?h=linux-3.16.y-queue

This patch is scheduled to be released in version 3.16.7-ckt25.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.16.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Luis

---8<------------------------------------------------------------

>From 8014c2513d5f595cfde7036ea4b4d98e2c223dd2 Mon Sep 17 00:00:00 2001
From: "Michael S. Tsirkin" <mst at redhat.com>
Date: Thu, 14 Jan 2016 16:00:41 +0200
Subject: virtio_pci: fix use after free on release

commit 2989be09a8a9d62a785137586ad941f916e08f83 upstream.

KASan detected a use-after-free error in virtio-pci remove code. In
virtio_pci_remove(), vp_dev is still used after being freed in
unregister_virtio_device() (in virtio_pci_release_dev() more
precisely).

To fix, keep a reference until cleanup is done.

Fixes: 63bd62a08ca4 ("virtio_pci: defer kfree until release callback")
Reported-by: Jerome Marchand <jmarchan at redhat.com>
Cc: Sasha Levin <sasha.levin at oracle.com>
Signed-off-by: Michael S. Tsirkin <mst at redhat.com>
Tested-by: Jerome Marchand <jmarchan at redhat.com>
[ luis: backported to 3.16:
  - file rename: virtio_pci_legacy.c -> virtio_pci.c ]
Signed-off-by: Luis Henriques <luis.henriques at canonical.com>
---
 drivers/virtio/virtio_pci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index c09527df161c..3eecbbad6cb4 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -756,6 +756,7 @@ out:
 static void virtio_pci_remove(struct pci_dev *pci_dev)
 {
 	struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
+	struct device *dev = get_device(&vp_dev->vdev.dev);

 	unregister_virtio_device(&vp_dev->vdev);

@@ -763,6 +764,7 @@ static void virtio_pci_remove(struct pci_dev *pci_dev)
 	pci_iounmap(pci_dev, vp_dev->ioaddr);
 	pci_release_regions(pci_dev);
 	pci_disable_device(pci_dev);
+	put_device(dev);
 }

 #ifdef CONFIG_PM_SLEEP




More information about the kernel-team mailing list