[libvirt PATCH] remote: add mutex when freeing private callbacks
Martin Kletzander
mkletzan at redhat.com
Tue Mar 7 08:59:40 UTC 2023
On Mon, Mar 06, 2023 at 06:35:44PM +0000, Mike Pontillo wrote:
>This commit resolves illegal memory accesses observed via:
>
> remoteClientFreePrivateCallbacks()
> remoteClientCloseFunc()
> virNetServerClientCloseLocked()
> virNetServerProcessClients()
> daemonServerProcessClients()
> virHashForEach()
> virNetDaemonRun()
> main()
>
>Signed-off-by: Mike Pontillo <mpontillo at digitalocean.com>
>---
> src/remote/remote_daemon_dispatch.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
>diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
>index 250eb51e6b..8d043d0bce 100644
>--- a/src/remote/remote_daemon_dispatch.c
>+++ b/src/remote/remote_daemon_dispatch.c
>@@ -1711,6 +1711,8 @@ remoteClientFreePrivateCallbacks(struct daemonClientPrivate *priv)
> g_autoptr(virIdentity) sysident = virIdentityGetSystem();
> virIdentitySetCurrent(sysident);
>
>+ virMutexLock(&priv->lock);
>+
Good catch, we can make it even slicker with:
VIR_LOCK_GUARD lock = virLockGuardLock(&priv->lock);
and rely on automatic unlock at the return. Either way (let me know if
you're OK with the proposed change):
Reviewed-by: Martin Kletzander <mkletzan at redhat.com>
and I'll wait a bit for your answer before pushing.
> DEREG_CB(priv->conn, priv->domainEventCallbacks,
> priv->ndomainEventCallbacks,
> virConnectDomainEventDeregisterAny, "domain");
>@@ -1737,6 +1739,8 @@ remoteClientFreePrivateCallbacks(struct daemonClientPrivate *priv)
> }
>
> virIdentitySetCurrent(NULL);
>+
>+ virMutexUnlock(&priv->lock);
> }
> #undef DEREG_CB
>
>--
>2.34.1
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20230307/d83bb83d/attachment.sig>
More information about the libvir-list
mailing list