All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: hangaohuai <hangaohuai@huawei.com>,
	fangying <fangying1@huawei.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PULL for-2.9 1/7] fix :cirrus_vga fix OOB read case qemu Segmentation fault
Date: Thu, 16 Mar 2017 10:30:36 +0100	[thread overview]
Message-ID: <1489656642-12925-2-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1489656642-12925-1-git-send-email-kraxel@redhat.com>

From: hangaohuai <hangaohuai@huawei.com>

check the validity of parameters in cirrus_bitblt_rop_fwd_transp_xxx
and cirrus_bitblt_rop_fwd_xxx to avoid the OOB read which causes qemu Segmentation fault.

After the fix, we will touch the assert in
cirrus_invalidate_region:
assert(off_cur_end >= off_cur);

Signed-off-by: fangying <fangying1@huawei.com>
Signed-off-by: hangaohuai <hangaohuai@huawei.com>
Message-id: 20170314063919.16200-1-hangaohuai@huawei.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/display/cirrus_vga_rop.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/hw/display/cirrus_vga_rop.h b/hw/display/cirrus_vga_rop.h
index 0925a00..b7447f8 100644
--- a/hw/display/cirrus_vga_rop.h
+++ b/hw/display/cirrus_vga_rop.h
@@ -97,6 +97,11 @@ glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
     uint8_t p;
     dstpitch -= bltwidth;
     srcpitch -= bltwidth;
+
+    if (bltheight > 1 && (dstpitch < 0 || srcpitch < 0)) {
+        return;
+    }
+
     for (y = 0; y < bltheight; y++) {
         for (x = 0; x < bltwidth; x++) {
 	    p = *dst;
@@ -143,6 +148,11 @@ glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
     uint8_t p1, p2;
     dstpitch -= bltwidth;
     srcpitch -= bltwidth;
+
+    if (bltheight > 1 && (dstpitch < 0 || srcpitch < 0)) {
+        return;
+    }
+
     for (y = 0; y < bltheight; y++) {
         for (x = 0; x < bltwidth; x+=2) {
 	    p1 = *dst;
-- 
1.8.3.1

  reply	other threads:[~2017-03-16  9:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-16  9:30 [Qemu-devel] [PULL for-2.9 0/7] cirrus: more blitter security fixes Gerd Hoffmann
2017-03-16  9:30 ` Gerd Hoffmann [this message]
2017-03-16  9:30 ` [Qemu-devel] [PULL for-2.9 2/7] cirrus/vnc: zap bitblit support from console code Gerd Hoffmann
2017-03-16  9:30 ` [Qemu-devel] [PULL for-2.9 3/7] cirrus: switch to 4 MB video memory by default Gerd Hoffmann
2017-03-16  9:30 ` [Qemu-devel] [PULL for-2.9 4/7] cirrus: add option to disable blitter Gerd Hoffmann
2017-03-16  9:51   ` 李强
2017-03-16 11:07     ` Thomas Huth
2017-03-16 14:00     ` Gerd Hoffmann
2017-03-16  9:30 ` [Qemu-devel] [PULL for-2.9 5/7] cirrus: fix cirrus_invalidate_region Gerd Hoffmann
2017-03-16  9:30 ` [Qemu-devel] [PULL for-2.9 6/7] cirrus: stop passing around dst pointers in the blitter Gerd Hoffmann
2017-03-16  9:30 ` [Qemu-devel] [PULL for-2.9 7/7] cirrus: stop passing around src " Gerd Hoffmann
2017-03-16 17:53 ` [Qemu-devel] [PULL for-2.9 0/7] cirrus: more blitter security fixes Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1489656642-12925-2-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=fangying1@huawei.com \
    --cc=hangaohuai@huawei.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.