Skip to content

Commit

Permalink
coroutine: Fix use after free with qemu_coroutine_yield()
Browse files Browse the repository at this point in the history
Instead of using the same function for entering and exiting coroutines,
and hoping that it doesn't add any functionality that hurts with the
parameters used for exiting, we can just directly call into the real
task switch in qemu_coroutine_switch().

This fixes a use-after-free scenario where reentering a coroutine that
has yielded still accesses the old parent coroutine (which may have
meanwhile terminated) in the part of coroutine_swap() that follows
qemu_coroutine_switch().

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 80687b4)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
  • Loading branch information
kevmw authored and mdroth committed Mar 9, 2015
1 parent c4ca8af commit 07db685
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion qemu-coroutine.c
Expand Up @@ -135,7 +135,7 @@ void coroutine_fn qemu_coroutine_yield(void)
}

self->caller = NULL;
coroutine_swap(self, to);
qemu_coroutine_switch(self, to, COROUTINE_YIELD);
}

void qemu_coroutine_adjust_pool_size(int n)
Expand Down

0 comments on commit 07db685

Please sign in to comment.