virtio_pci: fix use after free on release
authorMichael S. Tsirkin <mst@redhat.com>
Thu, 14 Jan 2016 14:00:41 +0000 (16:00 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Mar 2016 23:07:18 +0000 (15:07 -0800)
commitd56842d88978f54a3f7b8dfac3ae99ec3e732b95
tree311e8795a3793f7ae7f64a6db3c2939fcf1cc396
parentafb02993539468a15700481b54968edc10940b0d
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@redhat.com>
Cc: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/virtio/virtio_pci_common.c