Skip to content

vfio/cdx: Fix interrupt trigger races and consolidate MSI state

Alex Williamson kvm lkml stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest3 patches 1 replyIn review

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3vfio/cdx: Fix NULL pointer dereference in interrupt trigger pathdrivers/vfio/cdx/intr.c+4 -00 replies
2/3vfio/cdx: Serialize VFIO_DEVICE_SET_IRQS with a per-device mutexdrivers/vfio/cdx/intr.c drivers/vfio/cdx/main.c drivers/vfio/cdx/private.h+24 -70 replies
3/3vfio/cdx: Consolidate MSI configured state onto cdx_irqsdrivers/vfio/cdx/intr.c drivers/vfio/cdx/private.h+14 -160 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchNipun GuptaNikhil Agarwal
SeriesA-b
1/3A-b
2/3
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/3] vfio/cdx: Fix interrupt trigger races and consolidate MSI state

Prasanna Kumar's original patch [1] closes a NULL-pointer dereference that can be triggered by userspace via VFIO_DEVICE_SET_IRQS with VFIO_IRQ_SET_DATA_BOOL or VFIO_IRQ_SET_DATA_NONE before any VFIO_IRQ_SET_DATA_EVENTFD. Included here unchanged as patch 1/3.

Review of that patch identified a race in the same code path, where concurrent SET_IRQS calls can potentially result in time-of-check vs time-of-use and use-after-free inconsistencies. Patch 2/3 adds a per-device cdx_irqs_lock mutex and serializes all MSI state updates through vfio_cdx_set_msi_trigger(), which is the single choke-point covering both the ioctl path and the close-device cleanup.

Patch 3/3 is a non-stable cleanup that aligns vdev->cdx_irqs to NULL in error paths, thereby allowing removal of the now redundant config_msi.

[1] https://lore.kernel.org/all/[email protected]

Alex Williamson (2):
vfio/cdx: Serialize VFIO_DEVICE_SET_IRQS with a per-device mutex vfio/cdx: Consolidate MSI configured state onto cdx_irqs

Prasanna Kumar T S M (1):
vfio/cdx: Fix NULL pointer dereference in interrupt trigger path

 drivers/vfio/cdx/intr.c    | 38 ++++++++++++++++++--------------------
 drivers/vfio/cdx/main.c    | 19 +++++++++++++++++++
 drivers/vfio/cdx/private.h |  4 +++-
 3 files changed, 40 insertions(+), 21 deletions(-)
Signature · 1 line
2.51.0