linux-stable/drivers/vfio/pci
Alex Williamson 7d29d4c72c vfio/pci: Create persistent INTx handler
[ Upstream commit 18c198c96a ]

A vulnerability exists where the eventfd for INTx signaling can be
deconfigured, which unregisters the IRQ handler but still allows
eventfds to be signaled with a NULL context through the SET_IRQS ioctl
or through unmask irqfd if the device interrupt is pending.

Ideally this could be solved with some additional locking; the igate
mutex serializes the ioctl and config space accesses, and the interrupt
handler is unregistered relative to the trigger, but the irqfd path
runs asynchronous to those.  The igate mutex cannot be acquired from the
atomic context of the eventfd wake function.  Disabling the irqfd
relative to the eventfd registration is potentially incompatible with
existing userspace.

As a result, the solution implemented here moves configuration of the
INTx interrupt handler to track the lifetime of the INTx context object
and irq_type configuration, rather than registration of a particular
trigger eventfd.  Synchronization is added between the ioctl path and
eventfd_signal() wrapper such that the eventfd trigger can be
dynamically updated relative to in-flight interrupts or irqfd callbacks.

Cc:  <stable@vger.kernel.org>
Fixes: 89e1f7d4c6 ("vfio: Add PCI device driver")
Reported-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Link: https://lore.kernel.org/r/20240308230557.805580-5-alex.williamson@redhat.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-04-03 15:19:46 +02:00
..
hisilicon
mlx5
Kconfig
Makefile
trace.h
vfio_pci.c
vfio_pci_config.c vfio: Use GFP_KERNEL_ACCOUNT for userspace persistent allocations 2024-04-03 15:19:34 +02:00
vfio_pci_core.c vfio: Use GFP_KERNEL_ACCOUNT for userspace persistent allocations 2024-04-03 15:19:34 +02:00
vfio_pci_igd.c vfio: Use GFP_KERNEL_ACCOUNT for userspace persistent allocations 2024-04-03 15:19:34 +02:00
vfio_pci_intrs.c vfio/pci: Create persistent INTx handler 2024-04-03 15:19:46 +02:00
vfio_pci_priv.h
vfio_pci_rdwr.c vfio: Use GFP_KERNEL_ACCOUNT for userspace persistent allocations 2024-04-03 15:19:34 +02:00
vfio_pci_zdev.c