yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-fix-cirrus_vga-fix-OOB-read-case-qemu-Segmentation-f.patch

976a86
From d27fae125c1efd59ba3263260d41f8e054b070a2 Mon Sep 17 00:00:00 2001
976a86
From: Gerd Hoffmann <kraxel@redhat.com>
976a86
Date: Tue, 21 Mar 2017 09:58:01 +0100
976a86
Subject: [PATCH 1/7] fix :cirrus_vga fix OOB read case qemu Segmentation fault
976a86
976a86
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
976a86
Message-id: <1490090287-1503-2-git-send-email-kraxel@redhat.com>
976a86
Patchwork-id: 74419
976a86
O-Subject: [RHEL-7.4 qemu-kvm PATCH 1/7] fix :cirrus_vga fix OOB read case qemu Segmentation fault
976a86
Bugzilla: 1430059
976a86
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
976a86
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
976a86
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
976a86
976a86
From: hangaohuai <hangaohuai@huawei.com>
976a86
976a86
check the validity of parameters in cirrus_bitblt_rop_fwd_transp_xxx
976a86
and cirrus_bitblt_rop_fwd_xxx to avoid the OOB read which causes qemu Segmentation fault.
976a86
976a86
After the fix, we will touch the assert in
976a86
cirrus_invalidate_region:
976a86
assert(off_cur_end >= off_cur);
976a86
976a86
Signed-off-by: fangying <fangying1@huawei.com>
976a86
Signed-off-by: hangaohuai <hangaohuai@huawei.com>
976a86
Message-id: 20170314063919.16200-1-hangaohuai@huawei.com
976a86
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
976a86
(cherry picked from commit 215902d7b6fb50c6fc216fc74f770858278ed904)
976a86
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
976a86
---
976a86
 hw/display/cirrus_vga_rop.h | 10 ++++++++++
976a86
 1 file changed, 10 insertions(+)
976a86
976a86
diff --git a/hw/display/cirrus_vga_rop.h b/hw/display/cirrus_vga_rop.h
976a86
index 9c7bb09..a4f96c6 100644
976a86
--- a/hw/display/cirrus_vga_rop.h
976a86
+++ b/hw/display/cirrus_vga_rop.h
976a86
@@ -98,6 +98,11 @@ glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
976a86
     uint8_t p;
976a86
     dstpitch -= bltwidth;
976a86
     srcpitch -= bltwidth;
976a86
+
976a86
+    if (bltheight > 1 && (dstpitch < 0 || srcpitch < 0)) {
976a86
+        return;
976a86
+    }
976a86
+
976a86
     for (y = 0; y < bltheight; y++) {
976a86
         for (x = 0; x < bltwidth; x++) {
976a86
 	    p = *dst;
976a86
@@ -144,6 +149,11 @@ glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
976a86
     uint8_t p1, p2;
976a86
     dstpitch -= bltwidth;
976a86
     srcpitch -= bltwidth;
976a86
+
976a86
+    if (bltheight > 1 && (dstpitch < 0 || srcpitch < 0)) {
976a86
+        return;
976a86
+    }
976a86
+
976a86
     for (y = 0; y < bltheight; y++) {
976a86
         for (x = 0; x < bltwidth; x+=2) {
976a86
 	    p1 = *dst;
976a86
-- 
976a86
1.8.3.1
976a86