cryptospore / 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

619821
From f9b9adc4b66f991e655f51f2ef67dac46f6bd7d4 Mon Sep 17 00:00:00 2001
976a86
From: Gerd Hoffmann <kraxel@redhat.com>
619821
Date: Mon, 27 Mar 2017 10:01:16 +0200
976a86
Subject: [PATCH 1/7] fix :cirrus_vga fix OOB read case qemu Segmentation fault
976a86
976a86
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
619821
Message-id: <1490608882-10242-2-git-send-email-kraxel@redhat.com>
619821
Patchwork-id: 74553
619821
O-Subject: [RHEL-7.4 qemu-kvm PATCH v2 1/7] fix :cirrus_vga fix OOB read case qemu Segmentation fault
619821
Bugzilla: 1430060
976a86
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
976a86
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
619821
RH-Acked-by: Paolo Bonzini <pbonzini@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