Skip to contentSkip to conversation

vfio/pci: Drain eventfd RCU callbacks on module exit

PATCH Applied Jiale Yao 2 participants 2 messages Oct 3 – Oct 9

Subsystems (2)
lore
Share & tools
lore

Jiale Yao

author
#0 lore raw

PATCH 1/1 vfio/pci: Drain eventfd RCU callbacks on module exit

vfio_pci_eventfd_replace_locked() defers freeing replaced eventfds to vfio_pci_eventfd_rcu_free(). A callback can remain queued after close_device() returns and the device driver module reference is dropped. Once the dependent driver is removed, vfio-pci-core can be unloaded while the callback still points into its module text.

Wait for outstanding RCU callbacks before vfio-pci-core exits.

Fixes 98693e0897f7 ("vfio/pci: Use RCU for error/request triggers to avoid circular locking")
---
 drivers/vfio/pci/vfio_pci_core.c | 1 +
 1 file changed, 1 insertion(+)
drivers/vfio/pci/vfio_pci_core.c +1 -0
index 6757054e9d87..9bce419c52c8 100644
@@ -2675,6 +2675,7 @@ static void vfio_pci_dev_set_try_reset(struct vfio_device_set *dev_set)
 static void vfio_pci_core_cleanup(void)
 {
 	vfio_pci_uninit_perm_bits();
+	rcu_barrier();
 }
 
 static int __init vfio_pci_core_init(void)
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 19 lines · On Sat, 3 Oct 2026 17:38:06 +0800 Jiale Yao <[email protected]> wrote:

vfio_pci_eventfd_replace_locked() defers freeing replaced eventfds to vfio_pci_eventfd_rcu_free(). A callback can remain queued after close_device() returns and the device driver module reference is dropped. Once the dependent driver is removed, vfio-pci-core can be unloaded while the callback still points into its module text.

Wait for outstanding RCU callbacks before vfio-pci-core exits.

Fixes 98693e0897f7 ("vfio/pci: Use RCU for error/request triggers to avoid circular locking")
---
 drivers/vfio/pci/vfio_pci_core.c | 1 +
 1 file changed, 1 insertion(+)
drivers/vfio/pci/vfio_pci_core.c +0 -0
index 6757054e9d87..9bce419c52c8 100644

drivers/vfio/pci/vfio_pci_core.c static void vfio_pci_dev_set_try_reset(struct vfio_device_set *dev_set) · line 2681

Quoted 7 lines
drivers/vfio/pci/vfio_pci_core.c +1 -0
@@ -2675,6 +2675,7 @@ static void vfio_pci_dev_set_try_reset(struct vfio_device_set *dev_set)
 static void vfio_pci_core_cleanup(void)
 {
 	vfio_pci_uninit_perm_bits();
+	rcu_barrier();
 }
 
 static int __init vfio_pci_core_init(void)

Applied to vfio next branch for v7.4. Thanks,

Alex