summaryrefslogtreecommitdiffstats
path: root/recipes-support/spice/files/CVE-2017-7506-1.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-support/spice/files/CVE-2017-7506-1.patch')
-rw-r--r--recipes-support/spice/files/CVE-2017-7506-1.patch81
1 files changed, 81 insertions, 0 deletions
diff --git a/recipes-support/spice/files/CVE-2017-7506-1.patch b/recipes-support/spice/files/CVE-2017-7506-1.patch
new file mode 100644
index 0000000..1975aca
--- /dev/null
+++ b/recipes-support/spice/files/CVE-2017-7506-1.patch
@@ -0,0 +1,81 @@
1From 2e521a9db27e1ed31bf5fbed437208bf7f1c77a1 Mon Sep 17 00:00:00 2001
2From: Frediano Ziglio <fziglio@redhat.com>
3Date: Mon, 15 May 2017 15:57:28 +0100
4Subject: [PATCH 1/3] reds: Disconnect when receiving overly big
5 ClientMonitorsConfig
6
7Total message size received from the client was unlimited. There is
8a 2kiB size check on individual agent messages, but the MonitorsConfig
9message can be split in multiple chunks, and the size of the
10non-chunked MonitorsConfig message was never checked. This could easily
11lead to memory exhaustion on the host.
12
13Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
14
15Upstream-Status: Backport
16[https://cgit.freedesktop.org/spice/spice/commit/?h=0.12&id=f1e7ec03e26ab6b8ca9b7ec060846a5b706a963d]
17
18CVE: CVE-2017-7506
19
20Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
21---
22 server/reds.c | 25 +++++++++++++++++++++++--
23 1 file changed, 23 insertions(+), 2 deletions(-)
24
25diff --git a/server/reds.c b/server/reds.c
26index 30d0652..701d5d8 100644
27--- a/server/reds.c
28+++ b/server/reds.c
29@@ -1086,19 +1086,34 @@ static void reds_client_monitors_config_cleanup(void)
30 static void reds_on_main_agent_monitors_config(
31 MainChannelClient *mcc, void *message, size_t size)
32 {
33+ const unsigned int MAX_MONITORS = 256;
34+ const unsigned int MAX_MONITOR_CONFIG_SIZE =
35+ sizeof(VDAgentMonitorsConfig) + MAX_MONITORS * sizeof(VDAgentMonConfig);
36+
37 VDAgentMessage *msg_header;
38 VDAgentMonitorsConfig *monitors_config;
39 RedsClientMonitorsConfig *cmc = &reds->client_monitors_config;
40
41+ // limit size of message sent by the client as this can cause a DoS through
42+ // memory exhaustion, or potentially some integer overflows
43+ if (sizeof(VDAgentMessage) + MAX_MONITOR_CONFIG_SIZE - cmc->buffer_size < size) {
44+ goto overflow;
45+ }
46 cmc->buffer_size += size;
47 cmc->buffer = realloc(cmc->buffer, cmc->buffer_size);
48 spice_assert(cmc->buffer);
49 cmc->mcc = mcc;
50 memcpy(cmc->buffer + cmc->buffer_pos, message, size);
51 cmc->buffer_pos += size;
52+ if (sizeof(VDAgentMessage) > cmc->buffer_size) {
53+ spice_debug("not enough data yet. %d", cmc->buffer_size);
54+ return;
55+ }
56 msg_header = (VDAgentMessage *)cmc->buffer;
57- if (sizeof(VDAgentMessage) > cmc->buffer_size ||
58- msg_header->size > cmc->buffer_size - sizeof(VDAgentMessage)) {
59+ if (msg_header->size > MAX_MONITOR_CONFIG_SIZE) {
60+ goto overflow;
61+ }
62+ if (msg_header->size > cmc->buffer_size - sizeof(VDAgentMessage)) {
63 spice_debug("not enough data yet. %d\n", cmc->buffer_size);
64 return;
65 }
66@@ -1106,6 +1121,12 @@ static void reds_on_main_agent_monitors_config(
67 spice_debug("%s: %d\n", __func__, monitors_config->num_of_monitors);
68 red_dispatcher_client_monitors_config(monitors_config);
69 reds_client_monitors_config_cleanup();
70+ return;
71+
72+overflow:
73+ spice_warning("received invalid MonitorsConfig request from client, disconnecting");
74+ red_channel_client_disconnect(main_channel_client_get_base(mcc));
75+ reds_client_monitors_config_cleanup();
76 }
77
78 void reds_on_main_agent_data(MainChannelClient *mcc, void *message, size_t size)
79--
802.7.4
81