From: Peng Liang Date: Wed, 24 Feb 2021 11:28:23 +0000 (+0800) Subject: qemu: Add missing lock in qemuProcessHandleMonitorEOF X-Git-Tag: v7.1.0-rc2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ac703a7d0789e46833f4013a3876c2e3af18ec7;p=thirdparty%2Flibvirt.git qemu: Add missing lock in qemuProcessHandleMonitorEOF qemuMonitorUnregister will be called in multiple threads (e.g. threads in rpc worker pool and the vm event thread). In some cases, it isn't protected by the monitor lock, which may lead to call g_source_unref more than one time and a use-after-free problem eventually. Add the missing lock in qemuProcessHandleMonitorEOF (which is the only position missing lock of monitor I found). Suggested-by: Michal Privoznik Signed-off-by: Peng Liang Signed-off-by: Michal Privoznik Reviewed-by: Michal Privoznik --- diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d930ff9a74..bfa742577f 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -318,7 +318,9 @@ qemuProcessHandleMonitorEOF(qemuMonitorPtr mon, /* We don't want this EOF handler to be called over and over while the * thread is waiting for a job. */ + virObjectLock(mon); qemuMonitorUnregister(mon); + virObjectUnlock(mon); /* We don't want any cleanup from EOF handler (or any other * thread) to enter qemu namespace. */