]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu: avoid corruption of domain hashtable and misuse of freed domains
authorLaine Stump <laine@laine.org>
Thu, 3 Mar 2011 18:21:07 +0000 (13:21 -0500)
committerLaine Stump <laine@laine.org>
Fri, 4 Mar 2011 13:13:11 +0000 (08:13 -0500)
commitf8ac67909de87c2e0bd926850efa887ffc32f2c3
tree84d36c6d23fad88878ba0347cdd59bc78d7a3537
parente570ca1246667a72517357be7e8f75d217065880
qemu: avoid corruption of domain hashtable and misuse of freed domains

This was also found while investigating

   https://bugzilla.redhat.com/show_bug.cgi?id=670848

An EOF on a domain's monitor socket results in an event being queued
to handle the EOF. The handler calls qemuProcessHandleMonitorEOF. If
it is a transient domain, this leads to a call to
virDomainRemoveInactive, which removes the domain from the driver's
hashtable and unref's it. Nowhere in this code is the qemu driver lock
acquired.

However, all modifications to the driver's domain hashtable *must* be
done while holding the driver lock, otherwise the hashtable can become
corrupt, and (even more likely) another thread could call a different
hashtable function and acquire a pointer to the domain that is in the
process of being destroyed.

To prevent such a disaster, qemuProcessHandleMonitorEOF must get the
qemu driver lock *before* it gets the DomainObj's lock, and hold it
until it is finished with the DomainObj. This guarantees that nobody
else modifies the hashtable at the same time, and that anyone who had
already gotten the DomainObj from the hashtable prior to this call has
finished with it before we remove/destroy it.
src/qemu/qemu_process.c