fix CVE-2022-4144
Signed-off-by: yezengruan <yezengruan@huawei.com>
This commit is contained in:
parent
4a62ecf36f
commit
cb6a9a42d3
31
hw-display-qxl-Assert-memory-slot-fits-in-preallocat.patch
Normal file
31
hw-display-qxl-Assert-memory-slot-fits-in-preallocat.patch
Normal file
@ -0,0 +1,31 @@
|
||||
From 77af3f7f295a8b775adac7191a76136e779ac1c3 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@linaro.org>
|
||||
Date: Mon, 28 Nov 2022 21:27:41 +0100
|
||||
Subject: [PATCH 5/5] hw/display/qxl: Assert memory slot fits in preallocated
|
||||
MemoryRegion
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Message-Id: <20221128202741.4945-6-philmd@linaro.org>
|
||||
---
|
||||
hw/display/qxl.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
|
||||
index b34f2bd9b1..5a923d30de 100644
|
||||
--- a/hw/display/qxl.c
|
||||
+++ b/hw/display/qxl.c
|
||||
@@ -1400,6 +1400,7 @@ static int qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta,
|
||||
qxl_set_guest_bug(d, "%s: pci_region = %d", __func__, pci_region);
|
||||
return 1;
|
||||
}
|
||||
+ assert(guest_end - pci_start <= memory_region_size(mr));
|
||||
|
||||
virt_start = (intptr_t)memory_region_get_ram_ptr(mr);
|
||||
memslot.slot_id = slot_id;
|
||||
--
|
||||
2.27.0
|
||||
|
||||
109
hw-display-qxl-Avoid-buffer-overrun-in-qxl_phys2virt.patch
Normal file
109
hw-display-qxl-Avoid-buffer-overrun-in-qxl_phys2virt.patch
Normal file
@ -0,0 +1,109 @@
|
||||
From 5bcfd2b545b0b0830a2237cbdd3a3c2cdee9c5d2 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@linaro.org>
|
||||
Date: Mon, 28 Nov 2022 21:27:40 +0100
|
||||
Subject: [PATCH 4/5] hw/display/qxl: Avoid buffer overrun in qxl_phys2virt
|
||||
(CVE-2022-4144)
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Have qxl_get_check_slot_offset() return false if the requested
|
||||
buffer size does not fit within the slot memory region.
|
||||
|
||||
Similarly qxl_phys2virt() now returns NULL in such case, and
|
||||
qxl_dirty_one_surface() aborts.
|
||||
|
||||
This avoids buffer overrun in the host pointer returned by
|
||||
memory_region_get_ram_ptr().
|
||||
|
||||
Fixes: CVE-2022-4144 (out-of-bounds read)
|
||||
Reported-by: Wenxu Yin (@awxylitol)
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1336
|
||||
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Message-Id: <20221128202741.4945-5-philmd@linaro.org>
|
||||
---
|
||||
hw/display/qxl.c | 27 +++++++++++++++++++++++----
|
||||
hw/display/qxl.h | 2 +-
|
||||
2 files changed, 24 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
|
||||
index 7badb2aceb..b34f2bd9b1 100644
|
||||
--- a/hw/display/qxl.c
|
||||
+++ b/hw/display/qxl.c
|
||||
@@ -1440,11 +1440,13 @@ static void qxl_reset_surfaces(PCIQXLDevice *d)
|
||||
|
||||
/* can be also called from spice server thread context */
|
||||
static bool qxl_get_check_slot_offset(PCIQXLDevice *qxl, QXLPHYSICAL pqxl,
|
||||
- uint32_t *s, uint64_t *o)
|
||||
+ uint32_t *s, uint64_t *o,
|
||||
+ size_t size_requested)
|
||||
{
|
||||
uint64_t phys = le64_to_cpu(pqxl);
|
||||
uint32_t slot = (phys >> (64 - 8)) & 0xff;
|
||||
uint64_t offset = phys & 0xffffffffffff;
|
||||
+ uint64_t size_available;
|
||||
|
||||
if (slot >= NUM_MEMSLOTS) {
|
||||
qxl_set_guest_bug(qxl, "slot too large %d >= %d", slot,
|
||||
@@ -1468,6 +1470,23 @@ static bool qxl_get_check_slot_offset(PCIQXLDevice *qxl, QXLPHYSICAL pqxl,
|
||||
slot, offset, qxl->guest_slots[slot].size);
|
||||
return false;
|
||||
}
|
||||
+ size_available = memory_region_size(qxl->guest_slots[slot].mr);
|
||||
+ if (qxl->guest_slots[slot].offset + offset >= size_available) {
|
||||
+ qxl_set_guest_bug(qxl,
|
||||
+ "slot %d offset %"PRIu64" > region size %"PRIu64"\n",
|
||||
+ slot, qxl->guest_slots[slot].offset + offset,
|
||||
+ size_available);
|
||||
+ return false;
|
||||
+ }
|
||||
+ size_available -= qxl->guest_slots[slot].offset + offset;
|
||||
+ if (size_requested > size_available) {
|
||||
+ qxl_set_guest_bug(qxl,
|
||||
+ "slot %d offset %"PRIu64" size %zu: "
|
||||
+ "overrun by %"PRIu64" bytes\n",
|
||||
+ slot, offset, size_requested,
|
||||
+ size_requested - size_available);
|
||||
+ return false;
|
||||
+ }
|
||||
|
||||
*s = slot;
|
||||
*o = offset;
|
||||
@@ -1487,7 +1506,7 @@ void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id,
|
||||
offset = le64_to_cpu(pqxl) & 0xffffffffffff;
|
||||
return (void *)(intptr_t)offset;
|
||||
case MEMSLOT_GROUP_GUEST:
|
||||
- if (!qxl_get_check_slot_offset(qxl, pqxl, &slot, &offset)) {
|
||||
+ if (!qxl_get_check_slot_offset(qxl, pqxl, &slot, &offset, size)) {
|
||||
return NULL;
|
||||
}
|
||||
ptr = memory_region_get_ram_ptr(qxl->guest_slots[slot].mr);
|
||||
@@ -1945,9 +1964,9 @@ static void qxl_dirty_one_surface(PCIQXLDevice *qxl, QXLPHYSICAL pqxl,
|
||||
uint32_t slot;
|
||||
bool rc;
|
||||
|
||||
- rc = qxl_get_check_slot_offset(qxl, pqxl, &slot, &offset);
|
||||
- assert(rc == true);
|
||||
size = (uint64_t)height * abs(stride);
|
||||
+ rc = qxl_get_check_slot_offset(qxl, pqxl, &slot, &offset, size);
|
||||
+ assert(rc == true);
|
||||
trace_qxl_surfaces_dirty(qxl->id, offset, size);
|
||||
qxl_set_dirty(qxl->guest_slots[slot].mr,
|
||||
qxl->guest_slots[slot].offset + offset,
|
||||
diff --git a/hw/display/qxl.h b/hw/display/qxl.h
|
||||
index d6856c9f23..80b82bca94 100644
|
||||
--- a/hw/display/qxl.h
|
||||
+++ b/hw/display/qxl.h
|
||||
@@ -158,7 +158,7 @@ typedef struct PCIQXLDevice {
|
||||
*
|
||||
* Returns a host pointer to a buffer placed at offset @phys within the
|
||||
* active slot @group_id of the PCI VGA RAM memory region associated with
|
||||
- * the @qxl device. If the slot is inactive, or the offset is out
|
||||
+ * the @qxl device. If the slot is inactive, or the offset + size are out
|
||||
* of the memory region, returns NULL.
|
||||
*
|
||||
* Use with care; by the time this function returns, the returned pointer is
|
||||
--
|
||||
2.27.0
|
||||
|
||||
49
hw-display-qxl-Document-qxl_phys2virt.patch
Normal file
49
hw-display-qxl-Document-qxl_phys2virt.patch
Normal file
@ -0,0 +1,49 @@
|
||||
From 77889818eff8ccadb7fe08579cedaa4ec5e8f39d Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@linaro.org>
|
||||
Date: Mon, 28 Nov 2022 21:27:38 +0100
|
||||
Subject: [PATCH 2/5] hw/display/qxl: Document qxl_phys2virt()
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Message-Id: <20221128202741.4945-3-philmd@linaro.org>
|
||||
---
|
||||
hw/display/qxl.h | 19 +++++++++++++++++++
|
||||
1 file changed, 19 insertions(+)
|
||||
|
||||
diff --git a/hw/display/qxl.h b/hw/display/qxl.h
|
||||
index 4adfdb1e5d..ceda12d28b 100644
|
||||
--- a/hw/display/qxl.h
|
||||
+++ b/hw/display/qxl.h
|
||||
@@ -148,6 +148,25 @@ typedef struct PCIQXLDevice {
|
||||
#define QXL_DEFAULT_REVISION QXL_REVISION_STABLE_V12
|
||||
|
||||
/* qxl.c */
|
||||
+/**
|
||||
+ * qxl_phys2virt: Get a pointer within a PCI VRAM memory region.
|
||||
+ *
|
||||
+ * @qxl: QXL device
|
||||
+ * @phys: physical offset of buffer within the VRAM
|
||||
+ * @group_id: memory slot group
|
||||
+ *
|
||||
+ * Returns a host pointer to a buffer placed at offset @phys within the
|
||||
+ * active slot @group_id of the PCI VGA RAM memory region associated with
|
||||
+ * the @qxl device. If the slot is inactive, or the offset is out
|
||||
+ * of the memory region, returns NULL.
|
||||
+ *
|
||||
+ * Use with care; by the time this function returns, the returned pointer is
|
||||
+ * not protected by RCU anymore. If the caller is not within an RCU critical
|
||||
+ * section and does not hold the iothread lock, it must have other means of
|
||||
+ * protecting the pointer, such as a reference to the region that includes
|
||||
+ * the incoming ram_addr_t.
|
||||
+ *
|
||||
+ */
|
||||
void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL phys, int group_id);
|
||||
void qxl_set_guest_bug(PCIQXLDevice *qxl, const char *msg, ...)
|
||||
GCC_FMT_ATTR(2, 3);
|
||||
--
|
||||
2.27.0
|
||||
|
||||
53
hw-display-qxl-Have-qxl_log_command-Return-early-if-.patch
Normal file
53
hw-display-qxl-Have-qxl_log_command-Return-early-if-.patch
Normal file
@ -0,0 +1,53 @@
|
||||
From 15907e2ec54501b2e323774f40221f5396bb7281 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@linaro.org>
|
||||
Date: Mon, 28 Nov 2022 21:27:37 +0100
|
||||
Subject: [PATCH 1/5] hw/display/qxl: Have qxl_log_command Return early if no
|
||||
log_cmd handler
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Only 3 command types are logged: no need to call qxl_phys2virt()
|
||||
for the other types. Using different cases will help to pass
|
||||
different structure sizes to qxl_phys2virt() in a pair of commits.
|
||||
|
||||
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Message-Id: <20221128202741.4945-2-philmd@linaro.org>
|
||||
---
|
||||
hw/display/qxl-logger.c | 11 +++++++++++
|
||||
1 file changed, 11 insertions(+)
|
||||
|
||||
diff --git a/hw/display/qxl-logger.c b/hw/display/qxl-logger.c
|
||||
index 2ec6d8fa3d..551c274c27 100644
|
||||
--- a/hw/display/qxl-logger.c
|
||||
+++ b/hw/display/qxl-logger.c
|
||||
@@ -249,6 +249,16 @@ int qxl_log_command(PCIQXLDevice *qxl, const char *ring, QXLCommandExt *ext)
|
||||
qxl_name(qxl_type, ext->cmd.type),
|
||||
compat ? "(compat)" : "");
|
||||
|
||||
+ switch (ext->cmd.type) {
|
||||
+ case QXL_CMD_DRAW:
|
||||
+ break;
|
||||
+ case QXL_CMD_SURFACE:
|
||||
+ break;
|
||||
+ case QXL_CMD_CURSOR:
|
||||
+ break;
|
||||
+ default:
|
||||
+ goto out;
|
||||
+ }
|
||||
data = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id);
|
||||
if (!data) {
|
||||
return 1;
|
||||
@@ -271,6 +281,7 @@ int qxl_log_command(PCIQXLDevice *qxl, const char *ring, QXLCommandExt *ext)
|
||||
qxl_log_cmd_cursor(qxl, data, ext->group_id);
|
||||
break;
|
||||
}
|
||||
+out:
|
||||
fprintf(stderr, "\n");
|
||||
return 0;
|
||||
}
|
||||
--
|
||||
2.27.0
|
||||
|
||||
213
hw-display-qxl-Pass-requested-buffer-size-to-qxl_phy.patch
Normal file
213
hw-display-qxl-Pass-requested-buffer-size-to-qxl_phy.patch
Normal file
@ -0,0 +1,213 @@
|
||||
From b1a77b00f8ad5f7393553b02110be8211abcde5e Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@linaro.org>
|
||||
Date: Mon, 28 Nov 2022 21:27:39 +0100
|
||||
Subject: [PATCH 3/5] hw/display/qxl: Pass requested buffer size to
|
||||
qxl_phys2virt()
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Currently qxl_phys2virt() doesn't check for buffer overrun.
|
||||
In order to do so in the next commit, pass the buffer size
|
||||
as argument.
|
||||
|
||||
For QXLCursor in qxl_render_cursor() -> qxl_cursor() we
|
||||
verify the size of the chunked data ahead, checking we can
|
||||
access 'sizeof(QXLCursor) + chunk->data_size' bytes.
|
||||
Since in the SPICE_CURSOR_TYPE_MONO case the cursor is
|
||||
assumed to fit in one chunk, no change are required.
|
||||
In SPICE_CURSOR_TYPE_ALPHA the ahead read is handled in
|
||||
qxl_unpack_chunks().
|
||||
|
||||
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
|
||||
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Message-Id: <20221128202741.4945-4-philmd@linaro.org>
|
||||
---
|
||||
hw/display/qxl-logger.c | 11 ++++++++---
|
||||
hw/display/qxl-render.c | 20 ++++++++++++++++----
|
||||
hw/display/qxl.c | 14 +++++++++-----
|
||||
hw/display/qxl.h | 4 +++-
|
||||
4 files changed, 36 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/hw/display/qxl-logger.c b/hw/display/qxl-logger.c
|
||||
index 551c274c27..031ddfecc1 100644
|
||||
--- a/hw/display/qxl-logger.c
|
||||
+++ b/hw/display/qxl-logger.c
|
||||
@@ -106,7 +106,7 @@ static int qxl_log_image(PCIQXLDevice *qxl, QXLPHYSICAL addr, int group_id)
|
||||
QXLImage *image;
|
||||
QXLImageDescriptor *desc;
|
||||
|
||||
- image = qxl_phys2virt(qxl, addr, group_id);
|
||||
+ image = qxl_phys2virt(qxl, addr, group_id, sizeof(QXLImage));
|
||||
if (!image) {
|
||||
return 1;
|
||||
}
|
||||
@@ -216,7 +216,8 @@ int qxl_log_cmd_cursor(PCIQXLDevice *qxl, QXLCursorCmd *cmd, int group_id)
|
||||
cmd->u.set.position.y,
|
||||
cmd->u.set.visible ? "yes" : "no",
|
||||
cmd->u.set.shape);
|
||||
- cursor = qxl_phys2virt(qxl, cmd->u.set.shape, group_id);
|
||||
+ cursor = qxl_phys2virt(qxl, cmd->u.set.shape, group_id,
|
||||
+ sizeof(QXLCursor));
|
||||
if (!cursor) {
|
||||
return 1;
|
||||
}
|
||||
@@ -238,6 +239,7 @@ int qxl_log_command(PCIQXLDevice *qxl, const char *ring, QXLCommandExt *ext)
|
||||
{
|
||||
bool compat = ext->flags & QXL_COMMAND_FLAG_COMPAT;
|
||||
void *data;
|
||||
+ size_t datasz;
|
||||
int ret;
|
||||
|
||||
if (!qxl->cmdlog) {
|
||||
@@ -251,15 +253,18 @@ int qxl_log_command(PCIQXLDevice *qxl, const char *ring, QXLCommandExt *ext)
|
||||
|
||||
switch (ext->cmd.type) {
|
||||
case QXL_CMD_DRAW:
|
||||
+ datasz = compat ? sizeof(QXLCompatDrawable) : sizeof(QXLDrawable);
|
||||
break;
|
||||
case QXL_CMD_SURFACE:
|
||||
+ datasz = sizeof(QXLSurfaceCmd);
|
||||
break;
|
||||
case QXL_CMD_CURSOR:
|
||||
+ datasz = sizeof(QXLCursorCmd);
|
||||
break;
|
||||
default:
|
||||
goto out;
|
||||
}
|
||||
- data = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id);
|
||||
+ data = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id, datasz);
|
||||
if (!data) {
|
||||
return 1;
|
||||
}
|
||||
diff --git a/hw/display/qxl-render.c b/hw/display/qxl-render.c
|
||||
index bcef2a5fb0..c2a619095b 100644
|
||||
--- a/hw/display/qxl-render.c
|
||||
+++ b/hw/display/qxl-render.c
|
||||
@@ -106,7 +106,9 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl)
|
||||
qxl->guest_primary.resized = 0;
|
||||
qxl->guest_primary.data = qxl_phys2virt(qxl,
|
||||
qxl->guest_primary.surface.mem,
|
||||
- MEMSLOT_GROUP_GUEST);
|
||||
+ MEMSLOT_GROUP_GUEST,
|
||||
+ qxl->guest_primary.abs_stride
|
||||
+ * height);
|
||||
if (!qxl->guest_primary.data) {
|
||||
return;
|
||||
}
|
||||
@@ -221,7 +223,8 @@ static void qxl_unpack_chunks(void *dest, size_t size, PCIQXLDevice *qxl,
|
||||
if (offset == size) {
|
||||
return;
|
||||
}
|
||||
- chunk = qxl_phys2virt(qxl, chunk->next_chunk, group_id);
|
||||
+ chunk = qxl_phys2virt(qxl, chunk->next_chunk, group_id,
|
||||
+ sizeof(QXLDataChunk) + chunk->data_size);
|
||||
if (!chunk) {
|
||||
return;
|
||||
}
|
||||
@@ -288,7 +291,8 @@ fail:
|
||||
/* called from spice server thread context only */
|
||||
int qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext)
|
||||
{
|
||||
- QXLCursorCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id);
|
||||
+ QXLCursorCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id,
|
||||
+ sizeof(QXLCursorCmd));
|
||||
QXLCursor *cursor;
|
||||
QEMUCursor *c;
|
||||
|
||||
@@ -307,7 +311,15 @@ int qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext)
|
||||
}
|
||||
switch (cmd->type) {
|
||||
case QXL_CURSOR_SET:
|
||||
- cursor = qxl_phys2virt(qxl, cmd->u.set.shape, ext->group_id);
|
||||
+ /* First read the QXLCursor to get QXLDataChunk::data_size ... */
|
||||
+ cursor = qxl_phys2virt(qxl, cmd->u.set.shape, ext->group_id,
|
||||
+ sizeof(QXLCursor));
|
||||
+ if (!cursor) {
|
||||
+ return 1;
|
||||
+ }
|
||||
+ /* Then read including the chunked data following QXLCursor. */
|
||||
+ cursor = qxl_phys2virt(qxl, cmd->u.set.shape, ext->group_id,
|
||||
+ sizeof(QXLCursor) + cursor->chunk.data_size);
|
||||
if (!cursor) {
|
||||
return 1;
|
||||
}
|
||||
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
|
||||
index 98c7410032..7badb2aceb 100644
|
||||
--- a/hw/display/qxl.c
|
||||
+++ b/hw/display/qxl.c
|
||||
@@ -272,7 +272,8 @@ static void qxl_spice_monitors_config_async(PCIQXLDevice *qxl, int replay)
|
||||
QXL_IO_MONITORS_CONFIG_ASYNC));
|
||||
}
|
||||
|
||||
- cfg = qxl_phys2virt(qxl, qxl->guest_monitors_config, MEMSLOT_GROUP_GUEST);
|
||||
+ cfg = qxl_phys2virt(qxl, qxl->guest_monitors_config, MEMSLOT_GROUP_GUEST,
|
||||
+ sizeof(QXLMonitorsConfig));
|
||||
if (cfg != NULL && cfg->count == 1) {
|
||||
qxl->guest_primary.resized = 1;
|
||||
qxl->guest_head0_width = cfg->heads[0].width;
|
||||
@@ -457,7 +458,8 @@ static int qxl_track_command(PCIQXLDevice *qxl, struct QXLCommandExt *ext)
|
||||
switch (le32_to_cpu(ext->cmd.type)) {
|
||||
case QXL_CMD_SURFACE:
|
||||
{
|
||||
- QXLSurfaceCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id);
|
||||
+ QXLSurfaceCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id,
|
||||
+ sizeof(QXLSurfaceCmd));
|
||||
|
||||
if (!cmd) {
|
||||
return 1;
|
||||
@@ -491,7 +493,8 @@ static int qxl_track_command(PCIQXLDevice *qxl, struct QXLCommandExt *ext)
|
||||
}
|
||||
case QXL_CMD_CURSOR:
|
||||
{
|
||||
- QXLCursorCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id);
|
||||
+ QXLCursorCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id,
|
||||
+ sizeof(QXLCursorCmd));
|
||||
|
||||
if (!cmd) {
|
||||
return 1;
|
||||
@@ -1472,7 +1475,8 @@ static bool qxl_get_check_slot_offset(PCIQXLDevice *qxl, QXLPHYSICAL pqxl,
|
||||
}
|
||||
|
||||
/* can be also called from spice server thread context */
|
||||
-void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id)
|
||||
+void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id,
|
||||
+ size_t size)
|
||||
{
|
||||
uint64_t offset;
|
||||
uint32_t slot;
|
||||
@@ -1972,7 +1976,7 @@ static void qxl_dirty_surfaces(PCIQXLDevice *qxl)
|
||||
}
|
||||
|
||||
cmd = qxl_phys2virt(qxl, qxl->guest_surfaces.cmds[i],
|
||||
- MEMSLOT_GROUP_GUEST);
|
||||
+ MEMSLOT_GROUP_GUEST, sizeof(QXLSurfaceCmd));
|
||||
assert(cmd);
|
||||
assert(cmd->type == QXL_SURFACE_CMD_CREATE);
|
||||
qxl_dirty_one_surface(qxl, cmd->u.surface_create.data,
|
||||
diff --git a/hw/display/qxl.h b/hw/display/qxl.h
|
||||
index ceda12d28b..d6856c9f23 100644
|
||||
--- a/hw/display/qxl.h
|
||||
+++ b/hw/display/qxl.h
|
||||
@@ -154,6 +154,7 @@ typedef struct PCIQXLDevice {
|
||||
* @qxl: QXL device
|
||||
* @phys: physical offset of buffer within the VRAM
|
||||
* @group_id: memory slot group
|
||||
+ * @size: size of the buffer
|
||||
*
|
||||
* Returns a host pointer to a buffer placed at offset @phys within the
|
||||
* active slot @group_id of the PCI VGA RAM memory region associated with
|
||||
@@ -167,7 +168,8 @@ typedef struct PCIQXLDevice {
|
||||
* the incoming ram_addr_t.
|
||||
*
|
||||
*/
|
||||
-void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL phys, int group_id);
|
||||
+void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL phys, int group_id,
|
||||
+ size_t size);
|
||||
void qxl_set_guest_bug(PCIQXLDevice *qxl, const char *msg, ...)
|
||||
GCC_FMT_ATTR(2, 3);
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
||||
10
qemu.spec
10
qemu.spec
@ -1,6 +1,6 @@
|
||||
Name: qemu
|
||||
Version: 4.1.0
|
||||
Release: 75
|
||||
Release: 76
|
||||
Epoch: 10
|
||||
Summary: QEMU is a generic and open source machine emulator and virtualizer
|
||||
License: GPLv2 and BSD and MIT and CC-BY-SA-4.0
|
||||
@ -377,6 +377,11 @@ Patch0364: scsi-lsi53c895a-fix-use-after-free-in-lsi_do_msgout-.patch
|
||||
Patch0365: scsi-lsi53c895a-really-fix-use-after-free-in-lsi_do_.patch
|
||||
Patch0366: hw-usb-hcd-xhci-Fix-unbounded-loop-in-xhci_ring_chai.patch
|
||||
Patch0367: hw-display-ati_2d-Fix-buffer-overflow-in-ati_2d_blt-.patch
|
||||
Patch0368: hw-display-qxl-Have-qxl_log_command-Return-early-if-.patch
|
||||
Patch0369: hw-display-qxl-Document-qxl_phys2virt.patch
|
||||
Patch0370: hw-display-qxl-Pass-requested-buffer-size-to-qxl_phy.patch
|
||||
Patch0371: hw-display-qxl-Avoid-buffer-overrun-in-qxl_phys2virt.patch
|
||||
Patch0372: hw-display-qxl-Assert-memory-slot-fits-in-preallocat.patch
|
||||
|
||||
BuildRequires: flex
|
||||
BuildRequires: bison
|
||||
@ -777,6 +782,9 @@ getent passwd qemu >/dev/null || \
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Mon Dec 05 2022 yezengruan <yezengruan@huawei.com>
|
||||
- fix CVE-2022-4144
|
||||
|
||||
* Fri Sep 30 2022 yezengruan <yezengruan@huawei.com>
|
||||
- hw/display/ati_2d: Fix buffer overflow in ati_2d_blt (CVE-2021-3638)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user