sheepdog: Fix crash in co_read_response()
PATCH 1/1 sheepdog: Fix crash in co_read_response()
This fixes a regression introduced in commit 9d456654.
aio_co_wake() can only be used to reenter a coroutine that was already previously entered, otherwise co->ctx is uninitialised and we access garbage. Using it immediately after qemu_coroutine_create() like in co_read_response() is wrong and causes segfaults.
Replace the call with aio_co_enter(), which gets an explicit AioContext parameter and works even for new coroutines.
--- block/sheepdog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/sheepdog.c +1 -1
@@ -942,7 +942,7 @@ static void co_read_response(void *opaque) s->co_recv =qemu_coroutine_create (aio_read_response, opaque); } -aio_co_wake (s->co_recv); +aio_co_enter (s->aio_context, s->co_recv); }static void co_write_request (void *opaque)
Signature · 1 line
1.8.3.1
Quoted 7 lines · Kevin Wolf
This fixes a regression introduced in commit
9d456654.
aio_co_wake()can only be used to reenter a coroutine that was already previously entered, otherwiseco->ctxis uninitialised and we access garbage. Using it immediately afterqemu_coroutine_create()like inco_read_response()is wrong and causes segfaults.
Quoted 8 lines
Replace the call with
aio_co_enter(), which gets an explicit AioContext parameter and works even for new coroutines.Signed-off-by Kevin Wolf <[email protected]>Tested-by Kashyap Chamarthy <[email protected]>--- block/sheepdog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 7 lines · Kevin Wolf
This fixes a regression introduced in commit
9d456654.
aio_co_wake()can only be used to reenter a coroutine that was already previously entered, otherwiseco->ctxis uninitialised and we access garbage. Using it immediately afterqemu_coroutine_create()like inco_read_response()is wrong and causes segfaults.
Quoted 5 lines
Replace the call with
aio_co_enter(), which gets an explicit AioContext parameter and works even for new coroutines.Signed-off-by Kevin Wolf <[email protected]>Tested-by Kashyap Chamarthy <[email protected]>
Thanks.
The test evidence was posted on IRC. But just for archives' sake, I was here (on Git) when I applied this patch:
$ git describe
v2.9.0-rc3-45-gaa388ddAnd that was the specific test:
$ qemu-img convert -t directsync \ ./cirros-0.3.5.qcow2 sheepdog:cirros0.3.5vm
After applying this patch, the segfault is gone, and the qemu-img convert happens successfully.
That was my Sheepdog environment:
https://kashyapc.fedorapeople.org/virt/sheepdog-qemu-corosync.txt
Quoted 20 lines
--- block/sheepdog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/sheepdog.c +1
-1@@ -942,7 +942,7 @@ static void co_read_response(void *opaque) s->co_recv =qemu_coroutine_create (aio_read_response, opaque); } -aio_co_wake (s->co_recv); +aio_co_enter (s->aio_context, s->co_recv); }static void co_write_request (void *opaque)Signature · 1 line
1.8.3.1
Signature · 1 line
/kashyap
Peter Maydell
AppliedQuoted 30 lines · Kevin Wolf
This fixes a regression introduced in commit
9d456654.
aio_co_wake()can only be used to reenter a coroutine that was already previously entered, otherwiseco->ctxis uninitialised and we access garbage. Using it immediately afterqemu_coroutine_create()like inco_read_response()is wrong and causes segfaults.Replace the call with
aio_co_enter(), which gets an explicit AioContext parameter and works even for new coroutines.Signed-off-by Kevin Wolf <[email protected]>Tested-by Kashyap Chamarthy <[email protected]>--- block/sheepdog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/sheepdog.c +1
-2@@ -942,7 +942,7 @@ static void co_read_response(void *opaque) s->co_recv =qemu_coroutine_create (aio_read_response, opaque); } -aio_co_wake (s->co_recv); +aio_co_enter (s->aio_context, s->co_recv); }static void co_write_request (void *opaque) --
Quoted 2 lines
1.8.3.1
Applied, thanks.
-- PMM