All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] vmsvga: correct bitmap and pixmap size checks
@ 2016-09-08 12:45 P J P
  2016-09-13  7:02 ` P J P
  2016-09-13  7:26 ` Gerd Hoffmann
  0 siblings, 2 replies; 3+ messages in thread
From: P J P @ 2016-09-08 12:45 UTC (permalink / raw)
  To: Qemu Developers; +Cc: Gerd Hoffmann, Qinghao Tang, Li Qiang, Prasad J Pandit

From: Prasad J Pandit <pjp@fedoraproject.org>

When processing svga command DEFINE_CURSOR in vmsvga_fifo_run,
the computed BITMAP and PIXMAP size are checked against the
'cursor.mask[]' and 'cursor.image[]' array sizes in bytes.
Correct these checks to avoid OOB memory access.

Reported-by: Qinghao Tang <luodalongde@gmail.com>
Reported-by: Li Qiang <liqiang6-s@360.cn>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
 hw/display/vmware_vga.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index e51a05e..6599cf0 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -676,11 +676,13 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s)
             cursor.bpp = vmsvga_fifo_read(s);
 
             args = SVGA_BITMAP_SIZE(x, y) + SVGA_PIXMAP_SIZE(x, y, cursor.bpp);
-            if (cursor.width > 256 ||
-                cursor.height > 256 ||
-                cursor.bpp > 32 ||
-                SVGA_BITMAP_SIZE(x, y) > sizeof cursor.mask ||
-                SVGA_PIXMAP_SIZE(x, y, cursor.bpp) > sizeof cursor.image) {
+            if (cursor.width > 256
+                || cursor.height > 256
+                || cursor.bpp > 32
+                || SVGA_BITMAP_SIZE(x, y)
+                    > sizeof(cursor.mask) / sizeof(cursor.mask[0])
+                || SVGA_PIXMAP_SIZE(x, y, cursor.bpp)
+                    > sizeof(cursor.image) / sizeof(cursor.image[0])) {
                     goto badcmd;
             }
 
-- 
2.5.5

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

* Re: [Qemu-devel] [PATCH] vmsvga: correct bitmap and pixmap size checks
  2016-09-08 12:45 [Qemu-devel] [PATCH] vmsvga: correct bitmap and pixmap size checks P J P
@ 2016-09-13  7:02 ` P J P
  2016-09-13  7:26 ` Gerd Hoffmann
  1 sibling, 0 replies; 3+ messages in thread
From: P J P @ 2016-09-13  7:02 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Qemu Developers, Qinghao Tang, Li Qiang

+-- On Thu, 8 Sep 2016, P J P wrote --+
| From: Prasad J Pandit <pjp@fedoraproject.org>
| 
| When processing svga command DEFINE_CURSOR in vmsvga_fifo_run,
| the computed BITMAP and PIXMAP size are checked against the
| 'cursor.mask[]' and 'cursor.image[]' array sizes in bytes.
| Correct these checks to avoid OOB memory access.
| 
| Reported-by: Qinghao Tang <luodalongde@gmail.com>
| Reported-by: Li Qiang <liqiang6-s@360.cn>
| Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
| ---
|  hw/display/vmware_vga.c | 12 +++++++-----
|  1 file changed, 7 insertions(+), 5 deletions(-)
| 
| diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
| index e51a05e..6599cf0 100644
| --- a/hw/display/vmware_vga.c
| +++ b/hw/display/vmware_vga.c
| @@ -676,11 +676,13 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s)
|              cursor.bpp = vmsvga_fifo_read(s);
|  
|              args = SVGA_BITMAP_SIZE(x, y) + SVGA_PIXMAP_SIZE(x, y, cursor.bpp);
| -            if (cursor.width > 256 ||
| -                cursor.height > 256 ||
| -                cursor.bpp > 32 ||
| -                SVGA_BITMAP_SIZE(x, y) > sizeof cursor.mask ||
| -                SVGA_PIXMAP_SIZE(x, y, cursor.bpp) > sizeof cursor.image) {
| +            if (cursor.width > 256
| +                || cursor.height > 256
| +                || cursor.bpp > 32
| +                || SVGA_BITMAP_SIZE(x, y)
| +                    > sizeof(cursor.mask) / sizeof(cursor.mask[0])
| +                || SVGA_PIXMAP_SIZE(x, y, cursor.bpp)
| +                    > sizeof(cursor.image) / sizeof(cursor.image[0])) {
|                      goto badcmd;
|              }

Ping...!
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F

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

* Re: [Qemu-devel] [PATCH] vmsvga: correct bitmap and pixmap size checks
  2016-09-08 12:45 [Qemu-devel] [PATCH] vmsvga: correct bitmap and pixmap size checks P J P
  2016-09-13  7:02 ` P J P
@ 2016-09-13  7:26 ` Gerd Hoffmann
  1 sibling, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2016-09-13  7:26 UTC (permalink / raw)
  To: P J P; +Cc: Qemu Developers, Qinghao Tang, Li Qiang, Prasad J Pandit

On Do, 2016-09-08 at 18:15 +0530, P J P wrote:
> From: Prasad J Pandit <pjp@fedoraproject.org>
> 
> When processing svga command DEFINE_CURSOR in vmsvga_fifo_run,
> the computed BITMAP and PIXMAP size are checked against the
> 'cursor.mask[]' and 'cursor.image[]' array sizes in bytes.
> Correct these checks to avoid OOB memory access.

Added to vga patch queue.

thanks,
  Gerd

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

end of thread, other threads:[~2016-09-13  7:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-08 12:45 [Qemu-devel] [PATCH] vmsvga: correct bitmap and pixmap size checks P J P
2016-09-13  7:02 ` P J P
2016-09-13  7:26 ` 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.