]> git.itanic.dy.fi Git - linux-stable/commit
virtio_pci: harden MSI-X interrupts
authorJason Wang <jasowang@redhat.com>
Tue, 19 Oct 2021 07:01:46 +0000 (15:01 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 1 Nov 2021 09:26:48 +0000 (05:26 -0400)
commit9e35276a5344f74d4a3600fc4100b3dd251d5c56
treefef437132497b7a4dcf7ff1e8e4ebbbb0da23f43
parentd50497eb4e554e1f0351e1836ee7241c059592e6
virtio_pci: harden MSI-X interrupts

We used to synchronize pending MSI-X irq handlers via
synchronize_irq(), this may not work for the untrusted device which
may keep sending interrupts after reset which may lead unexpected
results. Similarly, we should not enable MSI-X interrupt until the
device is ready. So this patch fixes those two issues by:

1) switching to use disable_irq() to prevent the virtio interrupt
   handlers to be called after the device is reset.
2) using IRQF_NO_AUTOEN and enable the MSI-X irq during .ready()

This can make sure the virtio interrupt handler won't be called before
virtio_device_ready() and after reset.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20211019070152.8236-5-jasowang@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/virtio/virtio_pci_common.c
drivers/virtio/virtio_pci_common.h
drivers/virtio/virtio_pci_legacy.c
drivers/virtio/virtio_pci_modern.c