qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/1] chardev: fix pty_chr_timer
@ 2013-09-12  8:01 Gerd Hoffmann
  2013-09-12  8:01 ` [Qemu-devel] [PATCH 1/1] " Gerd Hoffmann
  0 siblings, 1 reply; 2+ messages in thread
From: Gerd Hoffmann @ 2013-09-12  8:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

Bugfix for the pty chardev which might segfault on unplug.
Has been on the list for quite a while, wasn't picked up so far,
so I'll try a single-patch-pull-request now ...

please pull,
  Gerd

The following changes since commit 2d1fe1873a984d1c2c89ffa3d12949cafc718551:

  Merge remote-tracking branch 'pmaydell/tags/pull-target-arm-20130910' into staging (2013-09-11 14:46:52 -0500)

are available in the git repository at:


  git://git.kraxel.org/qemu chardev.7

for you to fetch changes up to b0d768c35e08d2057b63e8e77e7a513c447199fa:

  chardev: fix pty_chr_timer (2013-09-12 09:58:18 +0200)

----------------------------------------------------------------
Gerd Hoffmann (1):
      chardev: fix pty_chr_timer

 qemu-char.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

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

* [Qemu-devel] [PATCH 1/1] chardev: fix pty_chr_timer
  2013-09-12  8:01 [Qemu-devel] [PULL 0/1] chardev: fix pty_chr_timer Gerd Hoffmann
@ 2013-09-12  8:01 ` Gerd Hoffmann
  0 siblings, 0 replies; 2+ messages in thread
From: Gerd Hoffmann @ 2013-09-12  8:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Anthony Liguori, qemu-stable

pty_chr_timer first calls pty_chr_update_read_handler(), then clears
timer_tag (because it is a one-shot timer).   This is the wrong order
though.  pty_chr_update_read_handler might re-arm time timer, and the
new timer_tag gets overwitten in that case.

This leads to crashes when unplugging a pty chardev:  pty_chr_close
thinks no timer is running -> timer isn't canceled -> pty_chr_timer gets
called with stale CharDevState -> BOOM.

This patch fixes the ordering.
Kill the pointless goto while being at it.

https://bugzilla.redhat.com/show_bug.cgi?id=994414

Cc: qemu-stable@nongnu.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 qemu-char.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index 6259496..f7f5464 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1026,15 +1026,11 @@ static gboolean pty_chr_timer(gpointer opaque)
     struct CharDriverState *chr = opaque;
     PtyCharDriver *s = chr->opaque;
 
-    if (s->connected) {
-        goto out;
-    }
-
-    /* Next poll ... */
-    pty_chr_update_read_handler(chr);
-
-out:
     s->timer_tag = 0;
+    if (!s->connected) {
+        /* Next poll ... */
+        pty_chr_update_read_handler(chr);
+    }
     return FALSE;
 }
 
-- 
1.8.3.1

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

end of thread, other threads:[~2013-09-12  8:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-12  8:01 [Qemu-devel] [PULL 0/1] chardev: fix pty_chr_timer Gerd Hoffmann
2013-09-12  8:01 ` [Qemu-devel] [PATCH 1/1] " Gerd Hoffmann

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).