render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
53ef0a
From 22b8106dabd9bbcaa78e6bcdd08b1c376f1a824d Mon Sep 17 00:00:00 2001
53ef0a
Message-Id: <22b8106dabd9bbcaa78e6bcdd08b1c376f1a824d@dist-git>
53ef0a
From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
53ef0a
Date: Tue, 24 Jul 2018 15:52:39 -0400
53ef0a
Subject: [PATCH] daemon: fix rpc event leak on error path in
53ef0a
 remoteDispatchObjectEventSend
53ef0a
MIME-Version: 1.0
53ef0a
Content-Type: text/plain; charset=UTF-8
53ef0a
Content-Transfer-Encoding: 8bit
53ef0a
53ef0a
RHEL 7.6: https://bugzilla.redhat.com/show_bug.cgi?id=1598032
53ef0a
RHEL 7.5.z: https://bugzilla.redhat.com/show_bug.cgi?id=1607752
53ef0a
53ef0a
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
53ef0a
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
53ef0a
(cherry picked from commit 8fafbf630fb366f54ed7478af46574be21a0e37c)
53ef0a
53ef0a
NB: Some valgrind data from bz:
53ef0a
53ef0a
  ==00:00:32:56.936 16421== 1,638,500 bytes in 25 blocks are possibly lost in loss record 2,349 of 2,351
53ef0a
  ==00:00:32:56.936 16421==    at 0x4C29B0D: malloc (vg_replace_malloc.c:298)
53ef0a
  ==00:00:32:56.936 16421==    by 0x4C2BAD9: realloc (vg_replace_malloc.c:785)
53ef0a
  ==00:00:32:56.936 16421==    by 0x54BB5AF: virReallocN (viralloc.c:245)
53ef0a
  ==00:00:32:56.936 16421==    by 0x165AD3: virNetMessageEncodeHeader (virnetmessage.c:234)
53ef0a
  ==00:00:32:56.936 16421==    by 0x125472: remoteDispatchObjectEventSend (remote.c:3996)
53ef0a
  ==00:00:32:56.936 16421==    by 0x129A7F: remoteRelayDomainEventLifecycle (remote.c:329)
53ef0a
  ==00:00:32:56.936 16421==    by 0x5599091: virDomainEventDispatchDefaultFunc (domain_event.c:1779)
53ef0a
  ==00:00:32:56.936 16421==    by 0x55975A6: virObjectEventStateDispatchCallbacks (object_event.c:715)
53ef0a
  ==00:00:32:56.936 16421==    by 0x55975A6: virObjectEventStateQueueDispatch (object_event.c:729)
53ef0a
  ==00:00:32:56.936 16421==    by 0x55975A6: virObjectEventStateFlush (object_event.c:830)
53ef0a
  ==00:00:32:56.936 16421==    by 0x55975A6: virObjectEventTimer (object_event.c:560)
53ef0a
  ==00:00:32:56.936 16421==    by 0x54DCC68: virEventPollDispatchTimeouts (vireventpoll.c:457)
53ef0a
  ==00:00:32:56.936 16421==    by 0x54DCC68: virEventPollRunOnce (vireventpoll.c:653)
53ef0a
  ==00:00:32:56.936 16421==    by 0x54DB5C1: virEventRunDefaultImpl (virevent.c:327)
53ef0a
  ==00:00:32:56.936 16421==    by 0x565991C: virNetDaemonRun (virnetdaemon.c:837)
53ef0a
  ==00:00:32:56.936 16421==    by 0x1240AD: main (libvirtd.c:1494)
53ef0a
  ==00:00:32:56.936 16421==
53ef0a
  ==00:00:32:56.936 16421== 55,668,712 (90,792 direct, 55,577,920 indirect) bytes in 873 blocks are definitely lost in loss record 2,351 of 2,351
53ef0a
  ==00:00:32:56.936 16421==    at 0x4C2B955: calloc (vg_replace_malloc.c:711)
53ef0a
  ==00:00:32:56.936 16421==    by 0x54BB4B3: virAlloc (viralloc.c:144)
53ef0a
  ==00:00:32:56.936 16421==    by 0x165425: virNetMessageNew (virnetmessage.c:42)
53ef0a
  ==00:00:32:56.936 16421==    by 0x125433: remoteDispatchObjectEventSend (remote.c:3986)
53ef0a
  ==00:00:32:56.936 16421==    by 0x129A7F: remoteRelayDomainEventLifecycle (remote.c:329)
53ef0a
  ==00:00:32:56.936 16421==    by 0x5599091: virDomainEventDispatchDefaultFunc (domain_event.c:1779)
53ef0a
  ==00:00:32:56.936 16421==    by 0x55975A6: virObjectEventStateDispatchCallbacks (object_event.c:715)
53ef0a
  ==00:00:32:56.936 16421==    by 0x55975A6: virObjectEventStateQueueDispatch (object_event.c:729)
53ef0a
  ==00:00:32:56.936 16421==    by 0x55975A6: virObjectEventStateFlush (object_event.c:830)
53ef0a
  ==00:00:32:56.936 16421==    by 0x55975A6: virObjectEventTimer (object_event.c:560)
53ef0a
  ==00:00:32:56.936 16421==    by 0x54DCC68: virEventPollDispatchTimeouts (vireventpoll.c:457)
53ef0a
  ==00:00:32:56.936 16421==    by 0x54DCC68: virEventPollRunOnce (vireventpoll.c:653)
53ef0a
  ==00:00:32:56.936 16421==    by 0x54DB5C1: virEventRunDefaultImpl (virevent.c:327)
53ef0a
  ==00:00:32:56.936 16421==    by 0x565991C: virNetDaemonRun (virnetdaemon.c:837)
53ef0a
  ==00:00:32:56.936 16421==    by 0x1240AD: main (libvirtd.c:1494)
53ef0a
  ==00:00:32:56.936 16421==
53ef0a
53ef0a
Signed-off-by: John Ferlan <jferlan@redhat.com>
53ef0a
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
53ef0a
---
53ef0a
 daemon/remote.c | 3 ++-
53ef0a
 1 file changed, 2 insertions(+), 1 deletion(-)
53ef0a
53ef0a
diff --git a/daemon/remote.c b/daemon/remote.c
53ef0a
index 3f7d2d3440..806479e72d 100644
53ef0a
--- a/daemon/remote.c
53ef0a
+++ b/daemon/remote.c
53ef0a
@@ -4000,7 +4000,8 @@ remoteDispatchObjectEventSend(virNetServerClientPtr client,
53ef0a
         goto cleanup;
53ef0a
 
53ef0a
     VIR_DEBUG("Queue event %d %zu", procnr, msg->bufferLength);
53ef0a
-    virNetServerClientSendMessage(client, msg);
53ef0a
+    if (virNetServerClientSendMessage(client, msg) < 0)
53ef0a
+        goto cleanup;
53ef0a
 
53ef0a
     xdr_free(proc, data);
53ef0a
     return;
53ef0a
-- 
53ef0a
2.18.0
53ef0a