Message ID | 1423564888-14933-2-git-send-email-kwolf@redhat.com |
---|---|
State | New |
Headers | show |
Am 10.02.2015 um 11:41 hat Kevin Wolf geschrieben: > 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(). > > Signed-off-by: Kevin Wolf <kwolf@redhat.com> Cc: qemu-stable@nongnu.org Thanks to Peter for noticing that I forgot this. Kevin
diff --git a/qemu-coroutine.c b/qemu-coroutine.c index 525247b..5019b81 100644 --- a/qemu-coroutine.c +++ b/qemu-coroutine.c @@ -148,5 +148,5 @@ void coroutine_fn qemu_coroutine_yield(void) } self->caller = NULL; - coroutine_swap(self, to); + qemu_coroutine_switch(self, to, COROUTINE_YIELD); }
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(). Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- qemu-coroutine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)