cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-char-remove-watch-callback-on-chardev-detach-from-fr.patch

9ae3a8
From dd0ab2d849f8a93fe54a29eedb8a536fbc42fe5d Mon Sep 17 00:00:00 2001
9ae3a8
From: Amit Shah <amit.shah@redhat.com>
9ae3a8
Date: Tue, 8 Oct 2013 06:13:07 +0200
9ae3a8
Subject: [PATCH 08/11] char: remove watch callback on chardev detach from frontend
9ae3a8
9ae3a8
RH-Author: Amit Shah <amit.shah@redhat.com>
9ae3a8
Message-id: <0044db8c12053fd38667200f350132d7a3485cde.1381210228.git.amit.shah@redhat.com>
9ae3a8
Patchwork-id: 54729
9ae3a8
O-Subject: [RHEL7 qemu-kvm PATCH 3/3] char: remove watch callback on chardev detach from frontend
9ae3a8
Bugzilla: 1007222
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
9ae3a8
If a frontend device releases the chardev (via unplug), the chr handlers
9ae3a8
are set to NULL via qdev's exit callbacks invoking
9ae3a8
qemu_chr_add_handlers().  If the chardev had a pending operation, a
9ae3a8
callback will be invoked, which will try to access data in the
9ae3a8
just-released frontend, causing a segfault.
9ae3a8
9ae3a8
Ensure the callbacks are disabled when frontends release chardevs.
9ae3a8
9ae3a8
This was seen when a virtio-serial port was unplugged when heavy
9ae3a8
guest->host IO was in progress (causing a callback to be registered).
9ae3a8
In the window in which the throttling was active, unplugging ports
9ae3a8
caused a qemu segfault.
9ae3a8
9ae3a8
https://bugzilla.redhat.com/show_bug.cgi?id=985205
9ae3a8
9ae3a8
CC: <qemu-stable@nongnu.org>
9ae3a8
Reported-by: Sibiao Luo <sluo@redhat.com>
9ae3a8
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Signed-off-by: Amit Shah <amit.shah@redhat.com>
9ae3a8
---
9ae3a8
 qemu-char.c | 3 +++
9ae3a8
 1 file changed, 3 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 qemu-char.c |    3 +++
9ae3a8
 1 files changed, 3 insertions(+), 0 deletions(-)
9ae3a8
9ae3a8
diff --git a/qemu-char.c b/qemu-char.c
9ae3a8
index 8d46f98..2fb876c 100644
9ae3a8
--- a/qemu-char.c
9ae3a8
+++ b/qemu-char.c
9ae3a8
@@ -195,6 +195,8 @@ void qemu_chr_fe_printf(CharDriverState *s, const char *fmt, ...)
9ae3a8
     va_end(ap);
9ae3a8
 }
9ae3a8
 
9ae3a8
+static void remove_fd_in_watch(CharDriverState *chr);
9ae3a8
+
9ae3a8
 void qemu_chr_add_handlers(CharDriverState *s,
9ae3a8
                            IOCanReadHandler *fd_can_read,
9ae3a8
                            IOReadHandler *fd_read,
9ae3a8
@@ -205,6 +207,7 @@ void qemu_chr_add_handlers(CharDriverState *s,
9ae3a8
 
9ae3a8
     if (!opaque && !fd_can_read && !fd_read && !fd_event) {
9ae3a8
         fe_open = 0;
9ae3a8
+        remove_fd_in_watch(s);
9ae3a8
     } else {
9ae3a8
         fe_open = 1;
9ae3a8
     }
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8