|
|
0727d3 |
From 87a318f0b8758f940a316831a77b6ebebca42b19 Mon Sep 17 00:00:00 2001
|
|
|
0727d3 |
From: Jon Maloy <jmaloy@redhat.com>
|
|
|
0727d3 |
Date: Wed, 4 May 2022 10:35:17 -0400
|
|
|
0727d3 |
Subject: [PATCH 3/3] ui/cursor: fix integer overflow in cursor_alloc
|
|
|
0727d3 |
(CVE-2021-4206)
|
|
|
0727d3 |
MIME-Version: 1.0
|
|
|
0727d3 |
Content-Type: text/plain; charset=UTF-8
|
|
|
0727d3 |
Content-Transfer-Encoding: 8bit
|
|
|
0727d3 |
|
|
|
0727d3 |
RH-Author: Jon Maloy <jmaloy@redhat.com>
|
|
|
0727d3 |
RH-MergeRequest: 180: ui/cursor: fix integer overflow in cursor_alloc (CVE-2021-4206)
|
|
|
0727d3 |
RH-Commit: [1/1] 7ad711347bc6248dc5aefa45401ca74448dee5e5 (jmaloy/qemu-kvm)
|
|
|
0727d3 |
RH-Bugzilla: 2040734
|
|
|
0727d3 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
0727d3 |
RH-Acked-by: Mauro Matteo Cascella <None>
|
|
|
0727d3 |
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
0727d3 |
|
|
|
0727d3 |
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2040734
|
|
|
0727d3 |
Upstream: Merged
|
|
|
0727d3 |
CVE: CVE-2021-4206
|
|
|
0727d3 |
|
|
|
0727d3 |
commit fa892e9abb728e76afcf27323ab29c57fb0fe7aa
|
|
|
0727d3 |
Author: Mauro Matteo Cascella <mcascell@redhat.com>
|
|
|
0727d3 |
Date: Thu Apr 7 10:17:12 2022 +0200
|
|
|
0727d3 |
|
|
|
0727d3 |
ui/cursor: fix integer overflow in cursor_alloc (CVE-2021-4206)
|
|
|
0727d3 |
|
|
|
0727d3 |
Prevent potential integer overflow by limiting 'width' and 'height' to
|
|
|
0727d3 |
512x512. Also change 'datasize' type to size_t. Refer to security
|
|
|
0727d3 |
advisory https://starlabs.sg/advisories/22-4206/ for more information.
|
|
|
0727d3 |
|
|
|
0727d3 |
Fixes: CVE-2021-4206
|
|
|
0727d3 |
Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
|
|
|
0727d3 |
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
0727d3 |
Message-Id: <20220407081712.345609-1-mcascell@redhat.com>
|
|
|
0727d3 |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
0727d3 |
|
|
|
0727d3 |
(cherry picked from commit fa892e9abb728e76afcf27323ab29c57fb0fe7aa)
|
|
|
0727d3 |
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
|
|
|
0727d3 |
---
|
|
|
0727d3 |
hw/display/qxl-render.c | 7 +++++++
|
|
|
0727d3 |
hw/display/vmware_vga.c | 2 ++
|
|
|
0727d3 |
ui/cursor.c | 8 +++++++-
|
|
|
0727d3 |
3 files changed, 16 insertions(+), 1 deletion(-)
|
|
|
0727d3 |
|
|
|
0727d3 |
diff --git a/hw/display/qxl-render.c b/hw/display/qxl-render.c
|
|
|
0727d3 |
index 237ed293ba..ca217004bf 100644
|
|
|
0727d3 |
--- a/hw/display/qxl-render.c
|
|
|
0727d3 |
+++ b/hw/display/qxl-render.c
|
|
|
0727d3 |
@@ -247,6 +247,13 @@ static QEMUCursor *qxl_cursor(PCIQXLDevice *qxl, QXLCursor *cursor,
|
|
|
0727d3 |
size_t size;
|
|
|
0727d3 |
|
|
|
0727d3 |
c = cursor_alloc(cursor->header.width, cursor->header.height);
|
|
|
0727d3 |
+
|
|
|
0727d3 |
+ if (!c) {
|
|
|
0727d3 |
+ qxl_set_guest_bug(qxl, "%s: cursor %ux%u alloc error", __func__,
|
|
|
0727d3 |
+ cursor->header.width, cursor->header.height);
|
|
|
0727d3 |
+ goto fail;
|
|
|
0727d3 |
+ }
|
|
|
0727d3 |
+
|
|
|
0727d3 |
c->hot_x = cursor->header.hot_spot_x;
|
|
|
0727d3 |
c->hot_y = cursor->header.hot_spot_y;
|
|
|
0727d3 |
switch (cursor->header.type) {
|
|
|
0727d3 |
diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
|
|
|
0727d3 |
index e2969a6c81..2b81d6122f 100644
|
|
|
0727d3 |
--- a/hw/display/vmware_vga.c
|
|
|
0727d3 |
+++ b/hw/display/vmware_vga.c
|
|
|
0727d3 |
@@ -509,6 +509,8 @@ static inline void vmsvga_cursor_define(struct vmsvga_state_s *s,
|
|
|
0727d3 |
int i, pixels;
|
|
|
0727d3 |
|
|
|
0727d3 |
qc = cursor_alloc(c->width, c->height);
|
|
|
0727d3 |
+ assert(qc != NULL);
|
|
|
0727d3 |
+
|
|
|
0727d3 |
qc->hot_x = c->hot_x;
|
|
|
0727d3 |
qc->hot_y = c->hot_y;
|
|
|
0727d3 |
switch (c->bpp) {
|
|
|
0727d3 |
diff --git a/ui/cursor.c b/ui/cursor.c
|
|
|
0727d3 |
index 1d62ddd4d0..835f0802f9 100644
|
|
|
0727d3 |
--- a/ui/cursor.c
|
|
|
0727d3 |
+++ b/ui/cursor.c
|
|
|
0727d3 |
@@ -46,6 +46,8 @@ static QEMUCursor *cursor_parse_xpm(const char *xpm[])
|
|
|
0727d3 |
|
|
|
0727d3 |
/* parse pixel data */
|
|
|
0727d3 |
c = cursor_alloc(width, height);
|
|
|
0727d3 |
+ assert(c != NULL);
|
|
|
0727d3 |
+
|
|
|
0727d3 |
for (pixel = 0, y = 0; y < height; y++, line++) {
|
|
|
0727d3 |
for (x = 0; x < height; x++, pixel++) {
|
|
|
0727d3 |
idx = xpm[line][x];
|
|
|
0727d3 |
@@ -91,7 +93,11 @@ QEMUCursor *cursor_builtin_left_ptr(void)
|
|
|
0727d3 |
QEMUCursor *cursor_alloc(int width, int height)
|
|
|
0727d3 |
{
|
|
|
0727d3 |
QEMUCursor *c;
|
|
|
0727d3 |
- int datasize = width * height * sizeof(uint32_t);
|
|
|
0727d3 |
+ size_t datasize = width * height * sizeof(uint32_t);
|
|
|
0727d3 |
+
|
|
|
0727d3 |
+ if (width > 512 || height > 512) {
|
|
|
0727d3 |
+ return NULL;
|
|
|
0727d3 |
+ }
|
|
|
0727d3 |
|
|
|
0727d3 |
c = g_malloc0(sizeof(QEMUCursor) + datasize);
|
|
|
0727d3 |
c->width = width;
|
|
|
0727d3 |
--
|
|
|
0727d3 |
2.35.1
|
|
|
0727d3 |
|