From: Wen Congyang <wency@cn.fujitsu.com>
To: qemu-devel <qemu-devel@nongnu.org>,
Stefan Weil <weil@mail.berlios.de>,
Anthony Liguori <aliguori@us.ibm.com>,
Corentin Chary <corentin.chary@gmail.com>
Subject: [Qemu-devel] [PATCH RESEND 2/2] vnc: Fix heap corruption
Date: Wed, 02 Mar 2011 11:58:35 +0800 [thread overview]
Message-ID: <4D6DC06B.6070308@cn.fujitsu.com> (raw)
In-Reply-To: <4D6DBDA4.3050909@cn.fujitsu.com>
This bug is reported by Stefan Weil:
========
Commit bc2429b9174ac2d3c56b7fd35884b0d89ec7fb02 introduced
a severe bug (heap corruption).
bitmap_clear was called with a wrong argument
which caused out-of-bound writes to width_mask.
This bug was detected with QEMU running on windows.
It also occurs with wine:
*** stack smashing detected ***: terminated
wine: Unhandled illegal instruction at address 0x6115c7 (thread 0009), starting debugger...
The bug is not windows specific!
========
The third argument of bitmap_clear() is number of bits to be cleared, but we pass
the end bits to be cleared to bitmap_clear().
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Reported-by: Stefan Weil <weil@mail.berlios.de>
---
ui/vnc.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/ui/vnc.c b/ui/vnc.c
index e3761b0..e7d0b5b 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2390,6 +2390,7 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
unsigned long width_mask[VNC_DIRTY_WORDS];
VncState *vs;
int has_dirty = 0;
+ const size_t width = ds_get_width(vd->ds) / 16;
struct timeval tv = { 0, 0 };
@@ -2403,9 +2404,8 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
* Check and copy modified bits from guest to server surface.
* Update server dirty map.
*/
- bitmap_set(width_mask, 0, (ds_get_width(vd->ds) / 16));
- bitmap_clear(width_mask, (ds_get_width(vd->ds) / 16),
- VNC_DIRTY_WORDS * BITS_PER_LONG);
+ bitmap_set(width_mask, 0, width);
+ bitmap_clear(width_mask, width, VNC_DIRTY_WORDS * BITS_PER_LONG - width);
cmp_bytes = 16 * ds_get_bytes_per_pixel(vd->ds);
guest_row = vd->guest.ds->data;
server_row = vd->server->data;
--
1.7.1
next prev parent reply other threads:[~2011-03-02 3:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-02 3:46 [Qemu-devel] [PATCH RESEND v2 1/2] fix vnc regression Wen Congyang
2011-03-02 3:58 ` Wen Congyang [this message]
2011-03-02 10:57 ` [Qemu-devel] Re: [PATCH RESEND 2/2] vnc: Fix heap corruption Corentin Chary
2011-03-02 18:36 ` Stefan Weil
2011-03-02 18:47 ` Peter Maydell
2011-03-02 22:01 ` Stefan Weil
2011-03-02 22:27 ` Stefan Weil
2011-03-03 1:37 ` Wen Congyang
2011-03-02 22:40 ` Peter Maydell
2011-03-02 10:56 ` [Qemu-devel] Re: [PATCH RESEND v2 1/2] fix vnc regression Corentin Chary
2011-03-03 2:44 ` [Qemu-devel] [PATCH 3/3] correct VNC_DIRTY_WORDS on 64 bit machine Wen Congyang
2011-03-03 6:41 ` [Qemu-devel] " Corentin Chary
2011-03-03 6:42 ` Wen Congyang
2011-03-03 6:49 ` [Qemu-devel] [PATCH v2 " Wen Congyang
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=4D6DC06B.6070308@cn.fujitsu.com \
--to=wency@cn.fujitsu.com \
--cc=aliguori@us.ibm.com \
--cc=corentin.chary@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=weil@mail.berlios.de \
/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.