Re: [libvirt PATCH] remote: add mutex when freeing private callbacks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx>
---
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@xxxxxxxxxx>

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

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux