]> git.ipfire.org Git - thirdparty/qemu.git/commit
aio: fix qemu_bh_schedule() bh->ctx race condition
authorStefan Hajnoczi <stefanha@redhat.com>
Tue, 3 Jun 2014 09:21:01 +0000 (11:21 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 3 Jul 2014 21:31:30 +0000 (16:31 -0500)
commit404194562406e71d41c52742e674279e601903d6
treead42234ea574c84532629a61790700b70fba6300
parent501910686272349efbb0458d008fd76d2695a5c4
aio: fix qemu_bh_schedule() bh->ctx race condition

qemu_bh_schedule() is supposed to be thread-safe at least the first time
it is called.  Unfortunately this is not quite true:

  bh->scheduled = 1;
  aio_notify(bh->ctx);

Since another thread may run the BH callback once it has been scheduled,
there is a race condition if the callback frees the BH before
aio_notify(bh->ctx) has a chance to run.

Reported-by: Stefan Priebe <s.priebe@profihost.ag>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Stefan Priebe <s.priebe@profihost.ag>
(cherry picked from commit 924fe1293c3e7a3c787bbdfb351e7f168caee3e9)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
async.c