All of lore.kernel.org
 help / color / mirror / Atom feed
* Two small patches related to xenfb
@ 2008-09-26 14:05 Rafal Wojtczuk
  2008-09-26 14:45 ` Ian Jackson
  2008-09-29  9:13 ` Gerd Hoffmann
  0 siblings, 2 replies; 3+ messages in thread
From: Rafal Wojtczuk @ 2008-09-26 14:05 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 606 bytes --]

Hello,
Two minor issues:
row_stride_div0.patch: a malicious frontend can send row_stride==0 and force
qemu-dm to perform division by 0
vnc_resize_doublecheck.patch: there is an unchecked multiplication when
calculating framebuffer size. Cs 17630 sanitizes framebuffer dimensions
passed by the frontend, so most probably no integer overflow can happen, but
there should be a check for overflow close to the actual computation (to
make code review easier and to cope with other codepaths in the future). 

Diffs against xen-3.2-testing.hg.

Regards,
Rafal Wojtczuk
Principal Researcher
Invisible Things Lab


[-- Attachment #2: row_stride_div0.patch --]
[-- Type: text/plain, Size: 400 bytes --]

--- xen-3.2-testing.hg/tools/ioemu/hw/xenfb.c.orig	2008-09-26 11:16:55.000000000 +0200
+++ xen-3.2-testing.hg/tools/ioemu/hw/xenfb.c	2008-09-26 11:18:01.000000000 +0200
@@ -496,7 +496,7 @@
 			depth);
 		return -1;
 	}
-	if (row_stride < 0 || row_stride > fb_len) {
+	if (row_stride <= 0 || row_stride > fb_len) {
 		fprintf(stderr,
 			"FB: invalid frontend stride %d\n", row_stride);
 		return -1;

[-- Attachment #3: vnc_resize_doublecheck.patch --]
[-- Type: text/plain, Size: 920 bytes --]

--- xen-3.2-testing.hg/tools/ioemu/vnc.c.orig	2008-09-26 11:14:21.000000000 +0200
+++ xen-3.2-testing.hg/tools/ioemu/vnc.c	2008-09-26 11:37:25.000000000 +0200
@@ -329,13 +329,23 @@
 
     vnc_write_s32(vs, encoding);
 }
-
+static int mult_overflows(int x, int y)
+{
+    if (x<=0 || y<=0 || x*y<=0 || x>((unsigned int)(-1))/y)
+        return 1;
+    else return 0;
+}
 static void vnc_dpy_resize(DisplayState *ds, int w, int h)
 {
     int size_changed;
     VncState *vs = ds->opaque;
     int o;
 
+    if (mult_overflows(w, h) || mult_overflows(w*h, vs->depth) ||
+        mult_overflows(h, sizeof(vs->dirty_row[0])) {
+        fprintf(stderr, "vnc: suspicious vnc_dpy_resize arguments, exiting\n");
+        exit(1);
+    }
     ds->data = realloc(ds->data, w * h * vs->depth);
     vs->old_data = realloc(vs->old_data, w * h * vs->depth);
     vs->dirty_row = realloc(vs->dirty_row, h * sizeof(vs->dirty_row[0]));

[-- Attachment #4: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-09-29  9:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-26 14:05 Two small patches related to xenfb Rafal Wojtczuk
2008-09-26 14:45 ` Ian Jackson
2008-09-29  9:13 ` Gerd Hoffmann

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.