]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.9-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Aug 2018 09:55:16 +0000 (11:55 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Aug 2018 09:55:16 +0000 (11:55 +0200)
added patches:
kvm-irqfd-fix-race-between-epollhup-and-irq_bypass_register_consumer.patch

queue-4.9/kvm-irqfd-fix-race-between-epollhup-and-irq_bypass_register_consumer.patch [new file with mode: 0644]
queue-4.9/series

diff --git a/queue-4.9/kvm-irqfd-fix-race-between-epollhup-and-irq_bypass_register_consumer.patch b/queue-4.9/kvm-irqfd-fix-race-between-epollhup-and-irq_bypass_register_consumer.patch
new file mode 100644 (file)
index 0000000..e1d0e92
--- /dev/null
@@ -0,0 +1,51 @@
+From 9432a3175770e06cb83eada2d91fac90c977cb99 Mon Sep 17 00:00:00 2001
+From: Paolo Bonzini <pbonzini@redhat.com>
+Date: Mon, 28 May 2018 13:31:13 +0200
+Subject: KVM: irqfd: fix race between EPOLLHUP and irq_bypass_register_consumer
+
+From: Paolo Bonzini <pbonzini@redhat.com>
+
+commit 9432a3175770e06cb83eada2d91fac90c977cb99 upstream.
+
+A comment warning against this bug is there, but the code is not doing what
+the comment says.  Therefore it is possible that an EPOLLHUP races against
+irq_bypass_register_consumer.  The EPOLLHUP handler schedules irqfd_shutdown,
+and if that runs soon enough, you get a use-after-free.
+
+Reported-by: syzbot <syzkaller@googlegroups.com>
+Cc: stable@vger.kernel.org
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ virt/kvm/eventfd.c |   11 ++++++-----
+ 1 file changed, 6 insertions(+), 5 deletions(-)
+
+--- a/virt/kvm/eventfd.c
++++ b/virt/kvm/eventfd.c
+@@ -405,11 +405,6 @@ kvm_irqfd_assign(struct kvm *kvm, struct
+       if (events & POLLIN)
+               schedule_work(&irqfd->inject);
+-      /*
+-       * do not drop the file until the irqfd is fully initialized, otherwise
+-       * we might race against the POLLHUP
+-       */
+-      fdput(f);
+ #ifdef CONFIG_HAVE_KVM_IRQ_BYPASS
+       if (kvm_arch_has_irq_bypass()) {
+               irqfd->consumer.token = (void *)irqfd->eventfd;
+@@ -425,6 +420,12 @@ kvm_irqfd_assign(struct kvm *kvm, struct
+ #endif
+       srcu_read_unlock(&kvm->irq_srcu, idx);
++
++      /*
++       * do not drop the file until the irqfd is fully initialized, otherwise
++       * we might race against the POLLHUP
++       */
++      fdput(f);
+       return 0;
+ fail:
index 03c09d12030ea67c17c57a90629051aa50c4d70e..acd96b2e9d8eab53c984e777ea98ef0600a81a7e 100644 (file)
@@ -116,3 +116,4 @@ net-qca_spi-avoid-packet-drop-during-initial-sync.patch
 net-qca_spi-make-sure-the-qca7000-reset-is-triggered.patch
 net-qca_spi-fix-log-level-if-probe-fails.patch
 tcp-identify-cryptic-messages-as-tcp-seq-bugs.patch
+kvm-irqfd-fix-race-between-epollhup-and-irq_bypass_register_consumer.patch