Skip to content

Commit d977087

Browse files
metamevawilliam
authored andcommitted
vfio/pci: Clean up DMABUFs before disabling function
On device shutdown, make vfio_pci_core_close_device() call vfio_pci_dma_buf_cleanup() before the function is disabled via vfio_pci_core_disable(). This ensures that all access via DMABUFs is revoked before the function's BARs become inaccessible. This fixes an issue where, if the function is disabled first, a tiny window exists in which the function's MSE is cleared and yet BARs could still be accessed via the DMABUF. The resources would also be freed and up for grabs by a different driver. Fixes: 5d74781 ("vfio/pci: Add dma-buf export support for MMIO regions") Signed-off-by: Matt Evans <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alex Williamson <[email protected]>
1 parent 4ee6420 commit d977087

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/vfio/pci/vfio_pci_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,10 +734,10 @@ void vfio_pci_core_close_device(struct vfio_device *core_vdev)
734734
#if IS_ENABLED(CONFIG_EEH)
735735
eeh_dev_release(vdev->pdev);
736736
#endif
737-
vfio_pci_core_disable(vdev);
738-
739737
vfio_pci_dma_buf_cleanup(vdev);
740738

739+
vfio_pci_core_disable(vdev);
740+
741741
mutex_lock(&vdev->igate);
742742
vfio_pci_eventfd_replace_locked(vdev, &vdev->err_trigger, NULL);
743743
vfio_pci_eventfd_replace_locked(vdev, &vdev->req_trigger, NULL);

0 commit comments

Comments
 (0)