linux/drivers/virtio
Karl Mehltretter d7808b37da virtio_input: stop callbacks before unregistering input device
virtinput_remove() unregisters the input device before resetting the
virtio device. virtinput_recv_events() drops vi->lock around input_event(),
so clearing vi->ready does not stop a callback that passed the entry check.
It can still use vi->idev, requeue buffers and kick the queue.

Reset first, as virtinput_freeze() already does. With the preceding core
change, reset waits for callbacks before input_unregister_device() can
free vi->idev. Recheck vi->ready after taking the lock again: keep draining
completed events so an input packet is not truncated, but stop requeueing
buffers and kicking the queue.

With evdev attached, input_unregister_handle() currently waits for an RCU
grace period, which also waits out IRQ callbacks. This masks the lifetime
bug on PCI and MMIO, but does not protect sleepable callbacks on other
transports.

Fixes: 271c865161 ("Add virtio-input driver.")
Assisted-by: LLM
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260905152059.89560-3-kmehltretter@gmail.com>
2026-09-07 18:54:04 -04:00
..
Kconfig mm: rename CONFIG_MEMORY_BALLOON -> CONFIG_BALLOON 2026-01-31 14:22:36 -08:00
Makefile virtio_rtc: Add RTC class driver 2025-05-27 10:27:54 -04:00
virtio_anchor.c virtio: replace restricted mem access flag with callback 2022-08-01 07:42:49 +02:00
virtio_balloon.c virtio_balloon: warn on failed buffer add in stats_handle_request() 2026-08-19 06:38:44 -04:00
virtio_debug.c virtio: clean up features qword/dword terms 2025-11-27 02:03:07 -05:00
virtio_dma_buf.c virtio: fix article before virtio in dma-buf comment 2026-08-19 06:38:47 -04:00
virtio_input.c virtio_input: stop callbacks before unregistering input device 2026-09-07 18:54:04 -04:00
virtio_mem.c virtio_mem: fix typo in comment 2026-08-19 06:38:47 -04:00
virtio_mmio.c virtio_mmio: disable IRQ wake before free_irq 2026-09-07 18:54:02 -04:00
virtio_pci_admin_legacy_io.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
virtio_pci_common.c virtio-pci: return IRQ_HANDLED after non-zero ISR 2026-09-07 18:54:03 -04:00
virtio_pci_common.h VFIO updates for v6.13 2024-11-27 12:57:03 -08:00
virtio_pci_legacy_dev.c virtio_pci: Fix misleading comment for queue vector 2025-08-26 03:38:10 -04:00
virtio_pci_legacy.c virtio: rename find_vqs_info() op to find_vqs() 2024-07-17 05:20:57 -04:00
virtio_pci_modern_dev.c virtio: clean up features qword/dword terms 2025-11-27 02:03:07 -05:00
virtio_pci_modern.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
virtio_ring.c virtio_ring: fix stale descriptor flags after a failed packed add 2026-09-07 18:54:02 -04:00
virtio_rtc_arm.c virtio_rtc: Add Arm Generic Timer cross-timestamping 2025-05-27 10:27:54 -04:00
virtio_rtc_class.c virtio_rtc: Add RTC class driver 2025-05-27 10:27:54 -04:00
virtio_rtc_driver.c virtio: rtc: time out alarm requests 2026-08-19 06:38:47 -04:00
virtio_rtc_internal.h virtio_rtc: Add RTC class driver 2025-05-27 10:27:54 -04:00
virtio_rtc_ptp.c virtio_rtc: Use provided clock ID for history snapshot 2026-06-04 11:04:17 +02:00
virtio_vdpa.c virtio-vdpa: Use queue id when setting vq affinity 2026-09-07 18:54:03 -04:00
virtio.c virtio: fix use-after-free in unregister_virtio_device() 2026-09-07 18:54:02 -04:00