Commit 808365500e for qemu.org

commit 808365500e6697b1ee6673dcdb17e56c2fddbede
Author: Peter Maydell <peter.maydell@linaro.org>
Date:   Tue Nov 24 09:57:19 2026 +0000

    hw/display/vmware-vga: Check incoming migration width and height

    The vmware-vga code sanitizes the screen width and height when the
    guest tries to set them.  Apply similar checks on the incoming
    migration data.  This prevents a manipulated migration stream from
    being able to cause us to create a surface that exceeds the size of
    vram.

    Since we already put in a check against creating a surface that
    is too large, the checks here are for:
     * ruling out a negative width and height
     * catching the issue and failing migration rather than letting
       it pass and then coping with the out-of-range values later

    Cc: qemu-stable@nongnu.org
    Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3870
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
    Message-ID: <20261124095719.4126146-5-peter.maydell@linaro.org>
    Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>

diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index d4fff46198..8db29eb7a8 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -1211,6 +1211,11 @@ static int vmsvga_post_load(void *opaque, int version_id)
 {
     struct vmsvga_state_s *s = opaque;

+    if (s->new_width < 0 || s->new_width > SVGA_MAX_WIDTH ||
+        s->new_height < 0 || s->new_height > SVGA_MAX_HEIGHT) {
+        return -1;
+    }
+
     s->invalidated = 1;
     if (s->config) {
         s->fifo = (uint32_t *) s->fifo_ptr;