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