dfb8478
From: Li Qiang <liqiang6-s@360.cn>
dfb8478
Date: Wed, 1 Feb 2017 09:35:01 +0100
dfb8478
Subject: [PATCH] cirrus: fix oob access issue (CVE-2017-2615)
dfb8478
dfb8478
When doing bitblt copy in backward mode, we should minus the
dfb8478
blt width first just like the adding in the forward mode. This
dfb8478
can avoid the oob access of the front of vga's vram.
dfb8478
dfb8478
Signed-off-by: Li Qiang <liqiang6-s@360.cn>
dfb8478
dfb8478
{ kraxel: with backward blits (negative pitch) addr is the topmost
dfb8478
          address, so check it as-is against vram size ]
dfb8478
dfb8478
Cc: qemu-stable@nongnu.org
dfb8478
Cc: P J P <ppandit@redhat.com>
dfb8478
Cc: Laszlo Ersek <lersek@redhat.com>
dfb8478
Cc: Paolo Bonzini <pbonzini@redhat.com>
dfb8478
Cc: Wolfgang Bumiller <w.bumiller@proxmox.com>
dfb8478
Fixes: d3532a0db02296e687711b8cdc7791924efccea0 (CVE-2014-8106)
dfb8478
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
dfb8478
Message-id: 1485938101-26602-1-git-send-email-kraxel@redhat.com
dfb8478
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
dfb8478
(cherry picked from commit 62d4c6bd5263bb8413a06c80144fc678df6dfb64)
dfb8478
---
dfb8478
 hw/display/cirrus_vga.c | 7 +++----
dfb8478
 1 file changed, 3 insertions(+), 4 deletions(-)
dfb8478
dfb8478
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
dfb8478
index 7db6409..16f27e8 100644
dfb8478
--- a/hw/display/cirrus_vga.c
dfb8478
+++ b/hw/display/cirrus_vga.c
dfb8478
@@ -274,10 +274,9 @@ static bool blit_region_is_unsafe(struct CirrusVGAState *s,
dfb8478
 {
dfb8478
     if (pitch < 0) {
dfb8478
         int64_t min = addr
dfb8478
-            + ((int64_t)s->cirrus_blt_height-1) * pitch;
dfb8478
-        int32_t max = addr
dfb8478
-            + s->cirrus_blt_width;
dfb8478
-        if (min < 0 || max > s->vga.vram_size) {
dfb8478
+            + ((int64_t)s->cirrus_blt_height - 1) * pitch
dfb8478
+            - s->cirrus_blt_width;
dfb8478
+        if (min < -1 || addr >= s->vga.vram_size) {
dfb8478
             return true;
dfb8478
         }
dfb8478
     } else {