linux/drivers/vfio
Alex Williamson 07afdfd8a6 vfio/platform: Create persistent IRQ handlers
[ Upstream commit 675daf435e ]

The vfio-platform SET_IRQS ioctl currently allows loopback triggering of
an interrupt before a signaling eventfd has been configured by the user,
which thereby allows a NULL pointer dereference.

Rather than register the IRQ relative to a valid trigger, register all
IRQs in a disabled state in the device open path.  This allows mask
operations on the IRQ to nest within the overall enable state governed
by a valid eventfd signal.  This decouples @masked, protected by the
@locked spinlock from @trigger, protected via the @igate mutex.

In doing so, it's guaranteed that changes to @trigger cannot race the
IRQ handlers because the IRQ handler is synchronously disabled before
modifying the trigger, and loopback triggering of the IRQ via ioctl is
safe due to serialization with trigger changes via igate.

For compatibility, request_irq() failures are maintained to be local to
the SET_IRQS ioctl rather than a fatal error in the open device path.
This allows, for example, a userspace driver with polling mode support
to continue to work regardless of moving the request_irq() call site.
This necessarily blocks all SET_IRQS access to the failed index.

Cc: Eric Auger <eric.auger@redhat.com>
Cc:  <stable@vger.kernel.org>
Fixes: 57f972e2b3 ("vfio/platform: trigger an interrupt via eventfd")
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Link: https://lore.kernel.org/r/20240308230557.805580-7-alex.williamson@redhat.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-04-13 12:51:34 +02:00
..
mdev vfio/mdev: Do not allow a mdev_type to have a NULL parent pointer 2021-05-14 09:44:24 +02:00
pci vfio/pci: Create persistent INTx handler 2024-04-13 12:51:34 +02:00
platform vfio/platform: Create persistent IRQ handlers 2024-04-13 12:51:34 +02:00
Kconfig vfio: Use config not menuconfig for VFIO_NOIOMMU 2021-09-22 12:26:23 +02:00
Makefile
vfio_iommu_spapr_tce.c
vfio_iommu_type1.c vfio/type1: Use follow_pte() 2021-03-04 10:26:38 +01:00
vfio_spapr_eeh.c
vfio.c vfio: Clear the caps->buf to NULL after free 2022-08-25 11:18:36 +02:00
virqfd.c vfio: Introduce interface to flush virqfd inject workqueue 2024-04-13 12:51:34 +02:00