forked from pool/libvirt
a026aabb02
- qemu: avoid denial of service reading from QEMU guest agent CVE-2018-1064 fbf31e1a-CVE-2018-1064.patch bsc#1083625 - virtlockd: fix loosing lock on re-exec 464889ff-rpc-aquire-ref-dispatch.patch, c6f1d519-rpc-simplify-dispatch.patch, 06e7ebb6-rpc-invoke-dispatch-unlocked.patch, 86cae503-rpc-fix-pre-exec.patch, eefabb38-rpc-virtlockd-virtlogd-single-thread.patch bsc#1076861 - libvirtd: fix potential deadlock when reloading 33c6eb96-fix-libvirtd-reload-deadlock.patch bsc#1079150 OBS-URL: https://build.opensuse.org/request/show/586966 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=676
118 lines
4.3 KiB
Diff
118 lines
4.3 KiB
Diff
commit c6f1d5190bbe62dae6b32081c0edd141ee19e82f
|
|
Author: Daniel P. Berrangé <berrange@redhat.com>
|
|
Date: Tue Mar 6 16:44:34 2018 +0000
|
|
|
|
rpc: simplify calling convention of virNetServerClientDispatchFunc
|
|
|
|
Currently virNetServerClientDispatchFunc implementations are only
|
|
responsible for free'ing the "msg" parameter upon success. Simplify the
|
|
calling convention by making it their unconditional responsibility to
|
|
free the "msg", and close the client if desired.
|
|
|
|
Reviewed-by: John Ferlan <jferlan@redhat.com>
|
|
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
|
|
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
|
Index: libvirt-4.1.0/src/rpc/virnetserver.c
|
|
===================================================================
|
|
--- libvirt-4.1.0.orig/src/rpc/virnetserver.c
|
|
+++ libvirt-4.1.0/src/rpc/virnetserver.c
|
|
@@ -182,15 +182,14 @@ static void virNetServerHandleJob(void *
|
|
VIR_FREE(job);
|
|
}
|
|
|
|
-static int virNetServerDispatchNewMessage(virNetServerClientPtr client,
|
|
- virNetMessagePtr msg,
|
|
- void *opaque)
|
|
+static void virNetServerDispatchNewMessage(virNetServerClientPtr client,
|
|
+ virNetMessagePtr msg,
|
|
+ void *opaque)
|
|
{
|
|
virNetServerPtr srv = opaque;
|
|
virNetServerProgramPtr prog = NULL;
|
|
unsigned int priority = 0;
|
|
size_t i;
|
|
- int ret = -1;
|
|
|
|
VIR_DEBUG("server=%p client=%p message=%p",
|
|
srv, client, msg);
|
|
@@ -207,7 +206,7 @@ static int virNetServerDispatchNewMessag
|
|
virNetServerJobPtr job;
|
|
|
|
if (VIR_ALLOC(job) < 0)
|
|
- goto cleanup;
|
|
+ goto error;
|
|
|
|
job->client = client;
|
|
job->msg = msg;
|
|
@@ -218,21 +217,24 @@ static int virNetServerDispatchNewMessag
|
|
}
|
|
|
|
virObjectRef(client);
|
|
- ret = virThreadPoolSendJob(srv->workers, priority, job);
|
|
-
|
|
- if (ret < 0) {
|
|
+ if (virThreadPoolSendJob(srv->workers, priority, job) < 0) {
|
|
virObjectUnref(client);
|
|
VIR_FREE(job);
|
|
virObjectUnref(prog);
|
|
+ goto error;
|
|
}
|
|
} else {
|
|
- ret = virNetServerProcessMsg(srv, client, prog, msg);
|
|
+ if (virNetServerProcessMsg(srv, client, prog, msg) < 0)
|
|
+ goto error;
|
|
}
|
|
|
|
- cleanup:
|
|
virObjectUnlock(srv);
|
|
+ return;
|
|
|
|
- return ret;
|
|
+ error:
|
|
+ virNetMessageFree(msg);
|
|
+ virNetServerClientClose(client);
|
|
+ virObjectUnlock(srv);
|
|
}
|
|
|
|
/**
|
|
Index: libvirt-4.1.0/src/rpc/virnetserverclient.c
|
|
===================================================================
|
|
--- libvirt-4.1.0.orig/src/rpc/virnetserverclient.c
|
|
+++ libvirt-4.1.0/src/rpc/virnetserverclient.c
|
|
@@ -1315,11 +1315,11 @@ static void virNetServerClientDispatchRe
|
|
|
|
/* Send off to for normal dispatch to workers */
|
|
if (msg) {
|
|
- if (!client->dispatchFunc ||
|
|
- client->dispatchFunc(client, msg, client->dispatchOpaque) < 0) {
|
|
+ if (!client->dispatchFunc) {
|
|
virNetMessageFree(msg);
|
|
client->wantClose = true;
|
|
- return;
|
|
+ } else {
|
|
+ client->dispatchFunc(client, msg, client->dispatchOpaque);
|
|
}
|
|
}
|
|
|
|
Index: libvirt-4.1.0/src/rpc/virnetserverclient.h
|
|
===================================================================
|
|
--- libvirt-4.1.0.orig/src/rpc/virnetserverclient.h
|
|
+++ libvirt-4.1.0/src/rpc/virnetserverclient.h
|
|
@@ -36,9 +36,12 @@ typedef virNetServer *virNetServerPtr;
|
|
typedef struct _virNetServerClient virNetServerClient;
|
|
typedef virNetServerClient *virNetServerClientPtr;
|
|
|
|
-typedef int (*virNetServerClientDispatchFunc)(virNetServerClientPtr client,
|
|
- virNetMessagePtr msg,
|
|
- void *opaque);
|
|
+/* This function owns the "msg" pointer it is passed and
|
|
+ * must arrange for virNetMessageFree to be called on it
|
|
+ */
|
|
+typedef void (*virNetServerClientDispatchFunc)(virNetServerClientPtr client,
|
|
+ virNetMessagePtr msg,
|
|
+ void *opaque);
|
|
|
|
typedef int (*virNetServerClientFilterFunc)(virNetServerClientPtr client,
|
|
virNetMessagePtr msg,
|