[lkml]   [2010]   [Oct]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[079/103] KVM: fix irqfd assign/deassign race
2.6.35-stable review patch.  If anyone has any objections, please let us know.


From: Marcelo Tosatti <>

commit 6bbfb2653177a00f70e57e53625502d43804fed0 upstream.

I think I see the following (theoretical) race:

During irqfd assign, we drop irqfds lock before we
schedule inject work. Therefore, deassign running
on another CPU could cause shutdown and flush to run
before inject, causing user after free in inject.

A simple fix it to schedule inject under the lock.

Signed-off-by: Michael S. Tsirkin <>
Acked-by: Gregory Haskins <>
Signed-off-by: Marcelo Tosatti <>
Signed-off-by: Greg Kroah-Hartman <>

virt/kvm/eventfd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -217,7 +217,6 @@ kvm_irqfd_assign(struct kvm *kvm, int fd
events = file->f_op->poll(file, &irqfd->pt);

list_add_tail(&irqfd->list, &kvm->irqfds.items);
- spin_unlock_irq(&kvm->irqfds.lock);

* Check if there was an event already pending on the eventfd
@@ -226,6 +225,8 @@ kvm_irqfd_assign(struct kvm *kvm, int fd
if (events & POLLIN)

+ spin_unlock_irq(&kvm->irqfds.lock);
* do not drop the file until the irqfd is fully initialized, otherwise
* we might race against the POLLHUP

 \ /
  Last update: 2010-10-22 20:59    [W:0.249 / U:10.980 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site