Blame SOURCES/kvm-cirrus-fix-oob-access-in-mode4and5-write-functions.patch

4a2fec
From 63d5677cbe031c52b37af8d123c27fdcb0f73af3 Mon Sep 17 00:00:00 2001
4a2fec
From: Gerd Hoffmann <kraxel@redhat.com>
4a2fec
Date: Fri, 20 Oct 2017 07:19:25 +0200
4a2fec
Subject: [PATCH 03/19] cirrus: fix oob access in mode4and5 write functions
4a2fec
4a2fec
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
4a2fec
Message-id: <20171020071925.9483-5-kraxel@redhat.com>
4a2fec
Patchwork-id: 77392
4a2fec
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 4/4] cirrus: fix oob access in mode4and5 write functions
4a2fec
Bugzilla: 1501301
4a2fec
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
4a2fec
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
4a2fec
4a2fec
Move dst calculation into the loop, so we apply the mask on each
4a2fec
interation and will not overflow vga memory.
4a2fec
4a2fec
Cc: Prasad J Pandit <pjp@fedoraproject.org>
4a2fec
Reported-by: Niu Guoxiang <niuguoxiang@huawei.com>
4a2fec
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
4a2fec
Message-id: 20171011084314.21752-1-kraxel@redhat.com
4a2fec
(cherry picked from commit eb38e1bc3740725ca29a535351de94107ec58d51)
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 hw/display/cirrus_vga.c | 6 ++----
4a2fec
 1 file changed, 2 insertions(+), 4 deletions(-)
4a2fec
4a2fec
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
4a2fec
index 15322b5..e53c6f2 100644
4a2fec
--- a/hw/display/cirrus_vga.c
4a2fec
+++ b/hw/display/cirrus_vga.c
4a2fec
@@ -2038,15 +2038,14 @@ static void cirrus_mem_writeb_mode4and5_8bpp(CirrusVGAState * s,
4a2fec
     unsigned val = mem_value;
4a2fec
     uint8_t *dst;
4a2fec
 
4a2fec
-    dst = s->vga.vram_ptr + (offset &= s->cirrus_addr_mask);
4a2fec
     for (x = 0; x < 8; x++) {
4a2fec
+        dst = s->vga.vram_ptr + ((offset + x) & s->cirrus_addr_mask);
4a2fec
 	if (val & 0x80) {
4a2fec
 	    *dst = s->cirrus_shadow_gr1;
4a2fec
 	} else if (mode == 5) {
4a2fec
 	    *dst = s->cirrus_shadow_gr0;
4a2fec
 	}
4a2fec
 	val <<= 1;
4a2fec
-	dst++;
4a2fec
     }
4a2fec
     memory_region_set_dirty(&s->vga.vram, offset, 8);
4a2fec
 }
4a2fec
@@ -2060,8 +2059,8 @@ static void cirrus_mem_writeb_mode4and5_16bpp(CirrusVGAState * s,
4a2fec
     unsigned val = mem_value;
4a2fec
     uint8_t *dst;
4a2fec
 
4a2fec
-    dst = s->vga.vram_ptr + (offset &= s->cirrus_addr_mask);
4a2fec
     for (x = 0; x < 8; x++) {
4a2fec
+        dst = s->vga.vram_ptr + ((offset + 2 * x) & s->cirrus_addr_mask & ~1);
4a2fec
 	if (val & 0x80) {
4a2fec
 	    *dst = s->cirrus_shadow_gr1;
4a2fec
 	    *(dst + 1) = s->vga.gr[0x11];
4a2fec
@@ -2070,7 +2069,6 @@ static void cirrus_mem_writeb_mode4and5_16bpp(CirrusVGAState * s,
4a2fec
 	    *(dst + 1) = s->vga.gr[0x10];
4a2fec
 	}
4a2fec
 	val <<= 1;
4a2fec
-	dst += 2;
4a2fec
     }
4a2fec
     memory_region_set_dirty(&s->vga.vram, offset, 16);
4a2fec
 }
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec