Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP2:GA
qemu-linux-user.7444
0268-input-limit-kbd-queue-depth.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0268-input-limit-kbd-queue-depth.patch of Package qemu-linux-user.7444
From 42a8caf06737a5facde379730b9fd3f70d47ace0 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann <kraxel@redhat.com> Date: Fri, 28 Apr 2017 10:42:37 +0200 Subject: [PATCH] input: limit kbd queue depth Apply a limit to the number of items we accept into the keyboard queue. Impact: Without this limit vnc clients can exhaust host memory by sending keyboard events faster than qemu feeds them to the guest. Fixes: CVE-2017-8379 Cc: P J P <ppandit@redhat.com> Cc: Huawei PSIRT <PSIRT@huawei.com> Reported-by: jiangxin1@huawei.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20170428084237.23960-1-kraxel@redhat.com (cherry picked from commit fa18f36a461984eae50ab957e47ec78dae3c14fc) [BR: BSC#1037334] Signed-off-by: Bruce Rogers <brogers@suse.com> --- ui/input.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ui/input.c b/ui/input.c index eeeabe844c..cf374bd472 100644 --- a/ui/input.c +++ b/ui/input.c @@ -38,6 +38,8 @@ static QTAILQ_HEAD(QemuInputEventQueueHead, QemuInputEventQueue) kbd_queue = QTAILQ_HEAD_INITIALIZER(kbd_queue); static QEMUTimer *kbd_timer; static uint32_t kbd_default_delay_ms = 10; +static uint32_t queue_count; +static uint32_t queue_limit = 1024; QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev, QemuInputHandler *handler) @@ -258,6 +260,7 @@ static void qemu_input_queue_process(void *opaque) break; } QTAILQ_REMOVE(queue, item, node); + queue_count--; g_free(item); } } @@ -272,6 +275,7 @@ static void qemu_input_queue_delay(struct QemuInputEventQueueHead *queue, item->delay_ms = delay_ms; item->timer = timer; QTAILQ_INSERT_TAIL(queue, item, node); + queue_count++; if (start_timer) { timer_mod(item->timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) @@ -288,6 +292,7 @@ static void qemu_input_queue_event(struct QemuInputEventQueueHead *queue, item->src = src; item->evt = evt; QTAILQ_INSERT_TAIL(queue, item, node); + queue_count++; } static void qemu_input_queue_sync(struct QemuInputEventQueueHead *queue) @@ -296,6 +301,7 @@ static void qemu_input_queue_sync(struct QemuInputEventQueueHead *queue) item->type = QEMU_INPUT_QUEUE_SYNC; QTAILQ_INSERT_TAIL(queue, item, node); + queue_count++; } void qemu_input_event_send(QemuConsole *src, InputEvent *evt) @@ -361,7 +367,7 @@ void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down) qemu_input_event_send(src, evt); qemu_input_event_sync(); qapi_free_InputEvent(evt); - } else { + } else if (queue_count < queue_limit) { qemu_input_queue_event(&kbd_queue, src, evt); qemu_input_queue_sync(&kbd_queue); } @@ -389,8 +395,10 @@ void qemu_input_event_send_key_delay(uint32_t delay_ms) kbd_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, qemu_input_queue_process, &kbd_queue); } - qemu_input_queue_delay(&kbd_queue, kbd_timer, - delay_ms ? delay_ms : kbd_default_delay_ms); + if (queue_count < queue_limit) { + qemu_input_queue_delay(&kbd_queue, kbd_timer, + delay_ms ? delay_ms : kbd_default_delay_ms); + } } InputEvent *qemu_input_event_new_btn(InputButton btn, bool down)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor