]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/spice/0006-reds-Avoid-buffer-overflows-handling-monitor-configu.patch
woff2: fix build on m68k
[coffee/buildroot.git] / package / spice / 0006-reds-Avoid-buffer-overflows-handling-monitor-configu.patch
1 From a957a90baf2c62d31f3547e56bba7d0e812d2331 Mon Sep 17 00:00:00 2001
2 From: Frediano Ziglio <fziglio@redhat.com>
3 Date: Mon, 15 May 2017 15:57:28 +0100
4 Subject: [PATCH] reds: Avoid buffer overflows handling monitor
5  configuration
6
7 It was also possible for a malicious client to set
8 VDAgentMonitorsConfig::num_of_monitors to a number larger
9 than the actual size of VDAgentMOnitorsConfig::monitors.
10 This would lead to buffer overflows, which could allow the guest to
11 read part of the host memory. This might cause write overflows in the
12 host as well, but controlling the content of such buffers seems
13 complicated.
14
15 Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
16 Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
17 ---
18  server/reds.c | 7 +++++++
19  1 file changed, 7 insertions(+)
20
21 diff --git a/server/reds.c b/server/reds.c
22 index e1c8c108..3a42c375 100644
23 --- a/server/reds.c
24 +++ b/server/reds.c
25 @@ -1000,6 +1000,7 @@ static void reds_on_main_agent_monitors_config(
26      VDAgentMessage *msg_header;
27      VDAgentMonitorsConfig *monitors_config;
28      RedsClientMonitorsConfig *cmc = &reds->client_monitors_config;
29 +    uint32_t max_monitors;
30  
31      // limit size of message sent by the client as this can cause a DoS through
32      // memory exhaustion, or potentially some integer overflows
33 @@ -1028,6 +1029,12 @@ static void reds_on_main_agent_monitors_config(
34          goto overflow;
35      }
36      monitors_config = (VDAgentMonitorsConfig *)(cmc->buffer + sizeof(*msg_header));
37 +    // limit the monitor number to avoid buffer overflows
38 +    max_monitors = (msg_header->size - sizeof(VDAgentMonitorsConfig)) /
39 +                   sizeof(VDAgentMonConfig);
40 +    if (monitors_config->num_of_monitors > max_monitors) {
41 +        goto overflow;
42 +    }
43      spice_debug("%s: %d", __func__, monitors_config->num_of_monitors);
44      red_dispatcher_client_monitors_config(monitors_config);
45      reds_client_monitors_config_cleanup();
46 -- 
47 2.11.0
48