All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: xen-devel <xen-devel@lists.xensource.com>
Subject: security fix for CVE-2007-1320
Date: Wed, 26 Nov 2008 10:27:57 +0000	[thread overview]
Message-ID: <492D24AD.1080009@eu.citrix.com> (raw)

This patch adds bounds checks to the new cirrus rop functions,
completing the fix for CVE-2007-1320.

It is worth to apply it to xen 3.3 too.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

---

diff -r e6aa6e88eee4 hw/cirrus_vga_rop.h
--- a/hw/cirrus_vga_rop.h	Tue Nov 25 11:27:00 2008 +0000
+++ b/hw/cirrus_vga_rop.h	Tue Nov 25 11:51:45 2008 +0000
@@ -94,19 +94,25 @@
 
 static void
 glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
-						       uint8_t *dst,const uint8_t *src,
+						       uint8_t *dst_,const uint8_t *src_,
 						       int dstpitch,int srcpitch,
 						       int bltwidth,int bltheight)
 {
     int x,y;
     uint8_t p;
+    uint32_t dst, src;
+    uint8_t *dst_base, *src_base;
+    get_base(dst_, s, dst_base);
+    get_base(src_, s, src_base);
+    dst = dst_ - dst_base;
+    src = src_ - src_base;
     dstpitch -= bltwidth;
     srcpitch -= bltwidth;
     for (y = 0; y < bltheight; y++) {
         for (x = 0; x < bltwidth; x++) {
-	    p = *dst;
-            ROP_OP(p, *src);
-	    if (p != s->gr[0x34]) *dst = p;
+	    p = *(dst_base + m(dst));
+            ROP_OP(p, *(src_base + m(src)));
+	    if (p != s->gr[0x34]) *(dst_base + m(dst)) = p;
             dst++;
             src++;
         }
@@ -117,19 +123,25 @@
 
 static void
 glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
-							uint8_t *dst,const uint8_t *src,
+							uint8_t *dst_,const uint8_t *src_,
 							int dstpitch,int srcpitch,
 							int bltwidth,int bltheight)
 {
     int x,y;
     uint8_t p;
+    uint32_t dst, src;
+    uint8_t *dst_base, *src_base;
+    get_base(dst_, s, dst_base);
+    get_base(src_, s, src_base);
+    dst = dst_ - dst_base;
+    src = src_ - src_base;
     dstpitch += bltwidth;
     srcpitch += bltwidth;
     for (y = 0; y < bltheight; y++) {
         for (x = 0; x < bltwidth; x++) {
-	    p = *dst;
-            ROP_OP(p, *src);
-	    if (p != s->gr[0x34]) *dst = p;
+	    p = *(dst_base + m(dst));
+            ROP_OP(p, *(src_base + m(src)));
+	    if (p != s->gr[0x34]) *(dst_base + m(dst)) = p;
             dst--;
             src--;
         }
@@ -140,23 +152,29 @@
 
 static void
 glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
-							uint8_t *dst,const uint8_t *src,
+							uint8_t *dst_,const uint8_t *src_,
 							int dstpitch,int srcpitch,
 							int bltwidth,int bltheight)
 {
     int x,y;
     uint8_t p1, p2;
+    uint32_t dst, src;
+    uint8_t *dst_base, *src_base;
+    get_base(dst_, s, dst_base);
+    get_base(src_, s, src_base);
+    dst = dst_ - dst_base;
+    src = src_ - src_base;
     dstpitch -= bltwidth;
     srcpitch -= bltwidth;
     for (y = 0; y < bltheight; y++) {
         for (x = 0; x < bltwidth; x+=2) {
-	    p1 = *dst;
-	    p2 = *(dst+1);
-            ROP_OP(p1, *src);
-            ROP_OP(p2, *(src+1));
+	    p1 = *(dst_base + m(dst));
+	    p2 = *(dst_base + m(dst+1));
+            ROP_OP(p1, *(src_base + m(src)));
+            ROP_OP(p2, *(src_base + m(src+1)));
 	    if ((p1 != s->gr[0x34]) || (p2 != s->gr[0x35])) {
-		*dst = p1;
-		*(dst+1) = p2;
+		*(dst_base + m(dst)) = p1;
+		*(dst_base + m(dst+1)) = p2;
 	    }
             dst+=2;
             src+=2;
@@ -168,23 +186,29 @@
 
 static void
 glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
-							 uint8_t *dst,const uint8_t *src,
+							 uint8_t *dst_,const uint8_t *src_,
 							 int dstpitch,int srcpitch,
 							 int bltwidth,int bltheight)
 {
     int x,y;
     uint8_t p1, p2;
+    uint32_t dst, src;
+    uint8_t *dst_base, *src_base;
+    get_base(dst_, s, dst_base);
+    get_base(src_, s, src_base);
+    dst = dst_ - dst_base;
+    src = src_ - src_base;
     dstpitch += bltwidth;
     srcpitch += bltwidth;
     for (y = 0; y < bltheight; y++) {
         for (x = 0; x < bltwidth; x+=2) {
-	    p1 = *(dst-1);
-	    p2 = *dst;
-            ROP_OP(p1, *(src-1));
-            ROP_OP(p2, *src);
+	    p1 = *(dst_base + m(dst-1));
+	    p2 = *(dst_base + m(dst));
+            ROP_OP(p1, *(src_base + m(src-1)));
+            ROP_OP(p2, *(src_base + m(src)));
 	    if ((p1 != s->gr[0x34]) || (p2 != s->gr[0x35])) {
-		*(dst-1) = p1;
-		*dst = p2;
+		*(dst_base + m(dst-1)) = p1;
+		*(dst_base + m(dst)) = p2;
 	    }
             dst-=2;
             src-=2;

                 reply	other threads:[~2008-11-26 10:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=492D24AD.1080009@eu.citrix.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /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.