vfio: Fix virqfd release race
authorAlex Williamson <alex.williamson@redhat.com>
Fri, 21 Sep 2012 16:48:28 +0000 (10:48 -0600)
committerAlex Williamson <alex.williamson@redhat.com>
Fri, 21 Sep 2012 16:48:28 +0000 (10:48 -0600)
commitb68e7fa879cd3b1126a7c455d9da1b70299efc0d
tree96126d0337b76ab5148fcd844e971e4afe9a02b1
parentb37b593e20a073dce5c7cbaf230f166db6425450
vfio: Fix virqfd release race

vfoi-pci supports a mechanism like KVM's irqfd for unmasking an
interrupt through an eventfd.  There are two ways to shutdown this
interface: 1) close the eventfd, 2) ioctl (such as disabling the
interrupt).  Both of these do the release through a workqueue,
which can result in a segfault if two jobs get queued for the same
virqfd.

Fix this by protecting the pointer to these virqfds by a spinlock.
The vfio pci device will therefore no longer have a reference to it
once the release job is queued under lock.  On the ioctl side, we
still flush the workqueue to ensure that any outstanding releases
are completed.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/pci/vfio_pci_intrs.c