qemu-e2k/ui
Daniel P. Berrange ada8d2e436 ui: fix VNC client throttling when forced update is requested
The VNC server must throttle data sent to the client to prevent the 'output'
buffer size growing without bound, if the client stops reading data off the
socket (either maliciously or due to stalled/slow network connection).

The current throttling is very crude because it simply checks whether the
output buffer offset is zero. This check is disabled if the client has requested
a forced update, because we want to send these as soon as possible.

As a result, the VNC client can cause QEMU to allocate arbitrary amounts of RAM.
They can first start something in the guest that triggers lots of framebuffer
updates eg play a youtube video. Then repeatedly send full framebuffer update
requests, but never read data back from the server. This can easily make QEMU's
VNC server send buffer consume 100MB of RAM per second, until the OOM killer
starts reaping processes (hopefully the rogue QEMU process, but it might pick
others...).

To address this we make the throttling more intelligent, so we can throttle
full updates. When we get a forced update request, we keep track of exactly how
much data we put on the output buffer. We will not process a subsequent forced
update request until this data has been fully sent on the wire. We always allow
one forced update request to be in flight, regardless of what data is queued
for incremental updates or audio data. The slight complication is that we do
not initially know how much data an update will send, as this is done in the
background by the VNC job thread. So we must track the fact that the job thread
has an update pending, and not process any further updates until this job is
has been completed & put data on the output buffer.

This unbounded memory growth affects all VNC server configurations supported by
QEMU, with no workaround possible. The mitigating factor is that it can only be
triggered by a client that has authenticated with the VNC server, and who is
able to trigger a large quantity of framebuffer updates or audio samples from
the guest OS. Mostly they'll just succeed in getting the OOM killer to kill
their own QEMU process, but its possible other processes can get taken out as
collateral damage.

This is a more general variant of the similar unbounded memory usage flaw in
the websockets server, that was previously assigned CVE-2017-15268, and fixed
in 2.11 by:

  commit a7b20a8efa
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Mon Oct 9 14:43:42 2017 +0100

    io: monitor encoutput buffer size from websocket GSource

This new general memory usage flaw has been assigned CVE-2017-15124, and is
partially fixed by this patch.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-id: 20171218191228.31018-11-berrange@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-01-12 13:48:54 +01:00
..
keycodemapdb@10739aa260 ui: pull in latest keycodemapdb 2017-10-23 10:50:02 +02:00
shader opengl: add flipping vertex shader 2017-10-17 10:25:42 +02:00
cocoa.m ui/cocoa.m: Send ctrl-alt key combos to guest if QEMU isn't using them 2017-11-07 10:14:14 +00:00
console-gl.c ui: use QEMU_IS_ALIGNED macro 2017-11-10 14:27:29 +01:00
console.c ui: fix dcl unregister 2017-11-10 11:06:43 +01:00
curses_keys.h
curses.c console: purge curses bits from console.h 2017-09-29 10:36:33 +02:00
cursor_hidden.xpm
cursor_left_ptr.xpm
cursor.c ui: use DIV_ROUND_UP 2017-08-31 12:29:07 +02:00
egl-context.c
egl-headless.c egl-headless: add dmabuf support 2017-10-17 10:25:42 +02:00
egl-helpers.c egl-helpers: add egl_texture_blit and egl_texture_blend 2017-10-17 10:25:42 +02:00
gtk-egl.c opengl: move shader init from console-gl.c to shader.c 2017-10-17 10:25:42 +02:00
gtk-gl-area.c ui: opengl updates for dma-buf support. 2017-10-19 12:09:53 +01:00
gtk.c ui/gtk: Fix deprecation of vte_terminal_copy_clipboard 2017-10-16 14:50:54 +02:00
input-keymap.c ui: generate qcode to linux mappings 2017-12-14 15:24:30 -08:00
input-legacy.c ui: fix crash with sendkey and raw key numbers 2017-10-23 10:50:02 +02:00
input-linux.c
input.c ui: normalize the 'sysrq' key into the 'print' key 2017-10-23 10:50:02 +02:00
keymaps.c General warn report fixups 2017-09-19 14:09:34 +02:00
keymaps.h
Makefile.objs buildsys: Move sdl cflags/libs to per object 2017-09-22 10:20:34 +08:00
qemu-pixman.c pixman: drop submodule 2017-09-13 10:15:43 +02:00
qemu-x509.h
sdl2-2d.c
sdl2-gl.c opengl: move shader init from console-gl.c to shader.c 2017-10-17 10:25:42 +02:00
sdl2-input.c
sdl2-keymap.h
sdl2.c sdl2: Fix broken display updating after the window is hidden 2017-11-16 09:57:47 +01:00
sdl_keysym.h
sdl_zoom_template.h
sdl_zoom.c
sdl_zoom.h
sdl.c
shader.c opengl: add flipping vertex shader 2017-10-17 10:25:42 +02:00
spice-core.c
spice-display.c opengl: move shader init from console-gl.c to shader.c 2017-10-17 10:25:42 +02:00
spice-input.c
trace-events ui: add tracing of VNC authentication process 2017-09-29 10:36:34 +02:00
vgafont.h
vnc_keysym.h
vnc-auth-sasl.c ui: fix VNC client throttling when forced update is requested 2018-01-12 13:48:54 +01:00
vnc-auth-sasl.h ui: track how much decoded data we consumed when doing SASL encoding 2018-01-12 13:48:54 +01:00
vnc-auth-vencrypt.c ui: Always remove an old VNC channel watch before adding a new one 2017-10-04 13:21:53 +01:00
vnc-auth-vencrypt.h
vnc-enc-hextile-template.h
vnc-enc-hextile.c
vnc-enc-tight.c
vnc-enc-tight.h
vnc-enc-zlib.c
vnc-enc-zrle-template.c
vnc-enc-zrle.c
vnc-enc-zrle.h
vnc-enc-zywrle-template.c
vnc-enc-zywrle.h
vnc-jobs.c ui: fix VNC client throttling when forced update is requested 2018-01-12 13:48:54 +01:00
vnc-jobs.h
vnc-palette.c
vnc-palette.h
vnc-ws.c ui: Always remove an old VNC channel watch before adding a new one 2017-10-04 13:21:53 +01:00
vnc-ws.h
vnc.c ui: fix VNC client throttling when forced update is requested 2018-01-12 13:48:54 +01:00
vnc.h ui: fix VNC client throttling when forced update is requested 2018-01-12 13:48:54 +01:00
x_keymap.c
x_keymap.h