mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	virtio_pci: fix use after free on release
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: 63bd62a08c ("virtio_pci: defer kfree until release callback")
Reported-by: Jerome Marchand <jmarchan@redhat.com>
Cc: stable@vger.kernel.org
Cc: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Jerome Marchand <jmarchan@redhat.com>
			
			
This commit is contained in:
		
							parent
							
								
									92e963f50f
								
							
						
					
					
						commit
						2989be09a8
					
				
					 1 changed files with 2 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -545,6 +545,7 @@ static int virtio_pci_probe(struct pci_dev *pci_dev,
 | 
			
		|||
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);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -554,6 +555,7 @@ static void virtio_pci_remove(struct pci_dev *pci_dev)
 | 
			
		|||
		virtio_pci_modern_remove(vp_dev);
 | 
			
		||||
 | 
			
		||||
	pci_disable_device(pci_dev);
 | 
			
		||||
	put_device(dev);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct pci_driver virtio_pci_driver = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue