render / rpms / libvirt

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