Blame 0106-io-monitor-encoutput-buffer-size-from-websocket-GSou.patch

59eb7a
From: "Daniel P. Berrange" <berrange@redhat.com>
59eb7a
Date: Mon, 9 Oct 2017 14:43:42 +0100
59eb7a
Subject: [PATCH] io: monitor encoutput buffer size from websocket GSource
59eb7a
59eb7a
The websocket GSource is monitoring the size of the rawoutput
59eb7a
buffer to determine if the channel can accepts more writes.
59eb7a
The rawoutput buffer, however, is merely a temporary staging
59eb7a
buffer before data is copied into the encoutput buffer. Thus
59eb7a
its size will always be zero when the GSource runs.
59eb7a
59eb7a
This flaw causes the encoutput buffer to grow without bound
59eb7a
if the other end of the underlying data channel doesn't
59eb7a
read data being sent. This can be seen with VNC if a client
59eb7a
is on a slow WAN link and the guest OS is sending many screen
59eb7a
updates. A malicious VNC client can act like it is on a slow
59eb7a
link by playing a video in the guest and then reading data
59eb7a
very slowly, causing QEMU host memory to expand arbitrarily.
59eb7a
59eb7a
This issue is assigned CVE-2017-15268, publically reported in
59eb7a
59eb7a
  https://bugs.launchpad.net/qemu/+bug/1718964
59eb7a
59eb7a
Reviewed-by: Eric Blake <eblake@redhat.com>
59eb7a
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
59eb7a
(cherry picked from commit a7b20a8efa28e5f22c26c06cd06c2f12bc863493)
59eb7a
---
59eb7a
 io/channel-websock.c | 4 ++--
59eb7a
 1 file changed, 2 insertions(+), 2 deletions(-)
59eb7a
59eb7a
diff --git a/io/channel-websock.c b/io/channel-websock.c
59eb7a
index 5a3badbec2..c02c2a66c9 100644
59eb7a
--- a/io/channel-websock.c
59eb7a
+++ b/io/channel-websock.c
59eb7a
@@ -26,7 +26,7 @@
59eb7a
 #include "trace.h"
59eb7a
 
59eb7a
 
59eb7a
-/* Max amount to allow in rawinput/rawoutput buffers */
59eb7a
+/* Max amount to allow in rawinput/encoutput buffers */
59eb7a
 #define QIO_CHANNEL_WEBSOCK_MAX_BUFFER 8192
59eb7a
 
59eb7a
 #define QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN 24
59eb7a
@@ -1006,7 +1006,7 @@ qio_channel_websock_source_prepare(GSource *source,
59eb7a
     if (wsource->wioc->rawinput.offset) {
59eb7a
         cond |= G_IO_IN;
59eb7a
     }
59eb7a
-    if (wsource->wioc->rawoutput.offset < QIO_CHANNEL_WEBSOCK_MAX_BUFFER) {
59eb7a
+    if (wsource->wioc->encoutput.offset < QIO_CHANNEL_WEBSOCK_MAX_BUFFER) {
59eb7a
         cond |= G_IO_OUT;
59eb7a
     }
59eb7a