97168e
From 100f33ff8a1d55986e43b99ba8726abc29ee8d26 Mon Sep 17 00:00:00 2001
32790f
From: Jon Maloy <jmaloy@redhat.com>
32790f
Date: Mon, 5 Dec 2022 15:32:55 -0500
97168e
Subject: [PATCH 5/5] hw/display/qxl: Assert memory slot fits in preallocated
32790f
 MemoryRegion
32790f
MIME-Version: 1.0
32790f
Content-Type: text/plain; charset=UTF-8
32790f
Content-Transfer-Encoding: 8bit
32790f
32790f
RH-Author: Jon Maloy <jmaloy@redhat.com>
97168e
RH-MergeRequest: 240: hw/display/qxl: Have qxl_log_command Return early if no log_cmd handler
97168e
RH-Bugzilla: 2148545
32790f
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
32790f
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
97168e
RH-Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
97168e
RH-Commit: [5/5] f809ce48e7989dd6547b7c8bf1a5efc3fdcacbac (jmaloy/jons-qemu-kvm)
32790f
97168e
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2148545
32790f
CVE: CVE-2022-4144
32790f
Upstream: Merged
32790f
32790f
commit 86fdb0582c653a9824183679403a85f588260d62
32790f
Author: Philippe Mathieu-Daudé <philmd@linaro.org>
32790f
Date:   Mon Nov 28 21:27:41 2022 +0100
32790f
32790f
    hw/display/qxl: Assert memory slot fits in preallocated MemoryRegion
32790f
32790f
    Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
32790f
    Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
32790f
    Message-Id: <20221128202741.4945-6-philmd@linaro.org>
32790f
32790f
(cherry picked from commit 86fdb0582c653a9824183679403a85f588260d62)
32790f
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
32790f
---
32790f
 hw/display/qxl.c | 1 +
32790f
 1 file changed, 1 insertion(+)
32790f
32790f
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
32790f
index 2a4b2d4158..bcd9e8716a 100644
32790f
--- a/hw/display/qxl.c
32790f
+++ b/hw/display/qxl.c
32790f
@@ -1372,6 +1372,7 @@ static int qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta,
32790f
         qxl_set_guest_bug(d, "%s: pci_region = %d", __func__, pci_region);
32790f
         return 1;
32790f
     }
32790f
+    assert(guest_end - pci_start <= memory_region_size(mr));
32790f
 
32790f
     virt_start = (intptr_t)memory_region_get_ram_ptr(mr);
32790f
     memslot.slot_id = slot_id;
32790f
-- 
32790f
2.37.3
32790f