From 03288d0de6894e18c9be187e2ace0cc50f15ceaa Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Fri, 27 Sep 2013 15:46:07 +0100 Subject: [PATCH] Fix crash in libvirtd when events are registered & ACLs active When a client disconnects from libvirtd, all event callbacks must be removed. This involves running the public API virConnectDomainEventDeregisterAny This code does not run in normal API dispatch context, so no identity was set. The result was that the access control drivers denied the attempt to deregister callbacks. The callbacks thus continued to trigger after the client was free'd causing fairly predictable use of free memory & a crash. This can be triggered by any client with readonly access when the ACL drivers are active. Signed-off-by: Daniel P. Berrange (cherry picked from commit 8294aa0c1750dcb49d6345cd9bd97bf421580d8b) Conflicts: daemon/remote.c: int/size_t changes --- daemon/remote.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/daemon/remote.c b/daemon/remote.c index 37572dedd5..c0a5618688 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -638,8 +638,11 @@ void remoteClientFreeFunc(void *data) /* Deregister event delivery callback */ if (priv->conn) { + virIdentityPtr sysident = virIdentityGetSystem(); int i; + virIdentitySetCurrent(sysident); + for (i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i++) { if (priv->domainEventCallbackID[i] != -1) { VIR_DEBUG("Deregistering to relay remote events %d", i); @@ -650,6 +653,9 @@ void remoteClientFreeFunc(void *data) } virConnectClose(priv->conn); + + virIdentitySetCurrent(NULL); + virObjectUnref(sysident); } VIR_FREE(priv); -- GitLab