qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Chris Webb <chris@arachsys.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH, RESEND] Fix SIGFPE race for vnc display resize
Date: Thu, 26 Aug 2010 12:43:55 +0100	[thread overview]
Message-ID: <20100826114355.GA455@arachsys.com> (raw)

cc39a92cbfc8 fixed a SIGFPE where the screen is resized to width/hight 1 and
then receives a mouse click. However, there is a still a tiny window here for
a race between the test for width/height > 1 and the division.

Signed-off-by: Chris Webb <chris@arachsys.com>
---
Sending this as I've just seen a SIGFPE from one of the qemu-kvm VMs running
in our public-facing cluster. Running gdb on the resulting core dump pointed
at line #1424 of vnc.c:

   1423     if (vs->absolute) {
   1424         kbd_mouse_event(ds_get_width(vs->ds) > 1 ?
   1425                           x * 0x7FFF / (ds_get_width(vs->ds) - 1) : 0x4000,
   1426                         ds_get_height(vs->ds) > 1 ?
   1427                           y * 0x7FFF / (ds_get_height(vs->ds) - 1) : 0x4000,
   1428                         dz, buttons);

I think this must have been a (tight) race between the comparison and the
division. This should probably go to the 0.12-stable branch too as that's
where I saw the crash. I can send a rebased patch if that's more convenient?

A pity this crash happened just after the release of 0.12.5 rather than a
week or two earlier!

 ui/vnc.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 7fc40ac..e04ebdf 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -1410,10 +1410,10 @@ static void pointer_event(VncState *vs, int button_mask,
         dz = 1;
 
     if (vs->absolute) {
-        kbd_mouse_event(ds_get_width(vs->ds) > 1 ?
-                          x * 0x7FFF / (ds_get_width(vs->ds) - 1) : 0x4000,
-                        ds_get_height(vs->ds) > 1 ?
-                          y * 0x7FFF / (ds_get_height(vs->ds) - 1) : 0x4000,
+        int width = ds_get_width(vs->ds);
+        int height = ds_get_height(vs->ds);
+        kbd_mouse_event(width > 1 ? x * 0x7FFF / (width - 1) : 0x4000,
+                        height > 1 ? y * 0x7FFF / (height - 1) : 0x4000,
                         dz, buttons);
     } else if (vnc_has_feature(vs, VNC_FEATURE_POINTER_TYPE_CHANGE)) {
         x -= 0x7FFF;
-- 
1.7.1.1

             reply	other threads:[~2010-08-26 11:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-26 11:43 Chris Webb [this message]
2011-09-30  8:49 ` [Qemu-devel] How to use macvtap/macvlan correctly Chris Webb
2011-10-02 19:46   ` Chris Webb

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=20100826114355.GA455@arachsys.com \
    --to=chris@arachsys.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).