[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 25/25] block/monitor/block-hmp-cmds.c: Fix crash when execute hmp_
From: |
Kevin Wolf |
Subject: |
[PULL 25/25] block/monitor/block-hmp-cmds.c: Fix crash when execute hmp_commit |
Date: |
Tue, 25 Apr 2023 15:13:59 +0200 |
From: Wang Liang <wangliangzz@inspur.com>
hmp_commit() calls blk_is_available() from a non-coroutine context (and in
the main loop). blk_is_available() is a co_wrapper_mixed_bdrv_rdlock
function, and in the non-coroutine context it calls AIO_WAIT_WHILE(),
which crashes if the aio_context lock is not taken before.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1615
Signed-off-by: Wang Liang <wangliangzz@inspur.com>
Message-Id: <20230424103902.45265-1-wangliangzz@126.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/monitor/block-hmp-cmds.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index 2846083546..ca2599de44 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -214,15 +214,17 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
error_report("Device '%s' not found", device);
return;
}
- if (!blk_is_available(blk)) {
- error_report("Device '%s' has no medium", device);
- return;
- }
bs = bdrv_skip_implicit_filters(blk_bs(blk));
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
+ if (!blk_is_available(blk)) {
+ error_report("Device '%s' has no medium", device);
+ aio_context_release(aio_context);
+ return;
+ }
+
ret = bdrv_commit(bs);
aio_context_release(aio_context);
--
2.40.0
- [PULL 07/25] block: convert bdrv_drain_all_begin() to AIO_WAIT_WHILE_UNLOCKED(), (continued)
- [PULL 07/25] block: convert bdrv_drain_all_begin() to AIO_WAIT_WHILE_UNLOCKED(), Kevin Wolf, 2023/04/25
- [PULL 11/25] block: add missing coroutine_fn to bdrv_sum_allocated_file_size(), Kevin Wolf, 2023/04/25
- [PULL 22/25] tests: mark more coroutine_fns, Kevin Wolf, 2023/04/25
- [PULL 15/25] thread-pool: avoid passing the pool parameter every time, Kevin Wolf, 2023/04/25
- [PULL 16/25] vvfat: mark various functions as coroutine_fn, Kevin Wolf, 2023/04/25
- [PULL 05/25] block: convert blk_exp_close_all_type() to AIO_WAIT_WHILE_UNLOCKED(), Kevin Wolf, 2023/04/25
- [PULL 18/25] mirror: make mirror_flush a coroutine_fn, do not use co_wrappers, Kevin Wolf, 2023/04/25
- [PULL 21/25] qemu-pr-helper: mark more coroutine_fns, Kevin Wolf, 2023/04/25
- [PULL 19/25] nbd: mark more coroutine_fns, do not use co_wrappers, Kevin Wolf, 2023/04/25
- [PULL 23/25] qcow2: mark various functions as coroutine_fn and GRAPH_RDLOCK, Kevin Wolf, 2023/04/25
- [PULL 25/25] block/monitor/block-hmp-cmds.c: Fix crash when execute hmp_commit,
Kevin Wolf <=
- [PULL 14/25] thread-pool: use ThreadPool from the running thread, Kevin Wolf, 2023/04/25
- [PULL 20/25] 9pfs: mark more coroutine_fns, Kevin Wolf, 2023/04/25
- [PULL 12/25] linux-aio: use LinuxAioState from the running thread, Kevin Wolf, 2023/04/25
- [PULL 24/25] vmdk: make vmdk_is_cid_valid a coroutine_fn, Kevin Wolf, 2023/04/25
- [PULL 13/25] io_uring: use LuringState from the running thread, Kevin Wolf, 2023/04/25
- [PULL 17/25] blkdebug: add missing coroutine_fn annotation, Kevin Wolf, 2023/04/25
- Re: [PULL 00/25] Block layer patches, Richard Henderson, 2023/04/26