]> git.ipfire.org Git - thirdparty/qemu.git/commit
monitor/qmp: fix race on CHR_EVENT_CLOSED without OOB
authorStefan Reiter <s.reiter@proxmox.com>
Mon, 22 Mar 2021 15:40:24 +0000 (16:40 +0100)
committerMichael Roth <michael.roth@amd.com>
Thu, 14 Oct 2021 19:49:46 +0000 (14:49 -0500)
commit318b07635651ca284f0e3f60f1c117a5fda41463
tree330e17e6badb837805533a0a833ac23a0f1c6b75
parentc1d1c0b4c3a3a96b25b8dff091ae9874705e39b1
monitor/qmp: fix race on CHR_EVENT_CLOSED without OOB

The QMP dispatcher coroutine holds the qmp_queue_lock over a yield
point, where it expects to be rescheduled from the main context. If a
CHR_EVENT_CLOSED event is received just then, it can race and block the
main thread on the mutex in monitor_qmp_cleanup_queue_and_resume.

monitor_resume does not need to be called from main context, so we can
call it immediately after popping a request from the queue, which allows
us to drop the qmp_queue_lock mutex before yielding.

Suggested-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Message-Id: <20210322154024.15011-1-s.reiter@proxmox.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
(cherry picked from commit a67b996e7894edfafbcd3fd007c9f58f26d25908)
Signed-off-by: Michael Roth <michael.roth@amd.com>
monitor/qmp.c