virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] virtio: console: Fix crash when hot-unplugging a port and read is blocked
@ 2010-05-27  7:54 Amit Shah
  2010-05-27  7:54 ` [PATCH 2/2] virtio: console: Fix crash when port is unplugged and blocked for write Amit Shah
  0 siblings, 1 reply; 4+ messages in thread
From: Amit Shah @ 2010-05-27  7:54 UTC (permalink / raw)
  To: Rusty Russell; +Cc: Amit Shah, Virtualization List

When removing a port we don't check if a program was blocked for read.
This leads to a crash when SIGTERM is sent to the program after
hot-unplugging the port.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 drivers/char/virtio_console.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 8c99bf1..e3fb529 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1099,6 +1099,13 @@ static int remove_port(struct port *port)
 {
 	struct port_buffer *buf;
 
+	if (port->guest_connected) {
+		port->guest_connected = false;
+		port->host_connected = false;
+		wake_up_interruptible(&port->waitqueue);
+		send_control_msg(port, VIRTIO_CONSOLE_PORT_OPEN, 0);
+	}
+
 	spin_lock_irq(&port->portdev->ports_lock);
 	list_del(&port->list);
 	spin_unlock_irq(&port->portdev->ports_lock);
@@ -1120,9 +1127,6 @@ static int remove_port(struct port *port)
 		hvc_remove(port->cons.hvc);
 #endif
 	}
-	if (port->guest_connected)
-		send_control_msg(port, VIRTIO_CONSOLE_PORT_OPEN, 0);
-
 	sysfs_remove_group(&port->dev->kobj, &port_attribute_group);
 	device_destroy(pdrvdata.class, port->dev->devt);
 	cdev_del(&port->cdev);
-- 
1.7.0.1

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

* [PATCH 2/2] virtio: console: Fix crash when port is unplugged and blocked for write
  2010-05-27  7:54 [PATCH 1/2] virtio: console: Fix crash when hot-unplugging a port and read is blocked Amit Shah
@ 2010-05-27  7:54 ` Amit Shah
  2010-05-31  7:55   ` Rusty Russell
  0 siblings, 1 reply; 4+ messages in thread
From: Amit Shah @ 2010-05-27  7:54 UTC (permalink / raw)
  To: Rusty Russell; +Cc: Amit Shah, Virtualization List

When a program that has a virtio port opened and blocked for a write
operation, a port hot-unplug event will later led to a crash when
SIGTERM was sent to the program. Fix that.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 drivers/char/virtio_console.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index e3fb529..942a982 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -529,6 +529,10 @@ static bool will_write_block(struct port *port)
 {
 	bool ret;
 
+	if (!port->guest_connected) {
+		/* Port got hot-unplugged. Let's exit. */
+		return false;
+	}
 	if (!port->host_connected)
 		return true;
 
-- 
1.7.0.1

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

* Re: [PATCH 2/2] virtio: console: Fix crash when port is unplugged and blocked for write
  2010-05-27  7:54 ` [PATCH 2/2] virtio: console: Fix crash when port is unplugged and blocked for write Amit Shah
@ 2010-05-31  7:55   ` Rusty Russell
  2010-05-31  7:58     ` Amit Shah
  0 siblings, 1 reply; 4+ messages in thread
From: Rusty Russell @ 2010-05-31  7:55 UTC (permalink / raw)
  To: Amit Shah; +Cc: Virtualization List

On Thu, 27 May 2010 05:24:40 pm Amit Shah wrote:
> When a program that has a virtio port opened and blocked for a write
> operation, a port hot-unplug event will later led to a crash when
> SIGTERM was sent to the program. Fix that.
> 
> Signed-off-by: Amit Shah <amit.shah@redhat.com>

Thanks, both applied.

Cheers,
Rusty.

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

* Re: [PATCH 2/2] virtio: console: Fix crash when port is unplugged and blocked for write
  2010-05-31  7:55   ` Rusty Russell
@ 2010-05-31  7:58     ` Amit Shah
  0 siblings, 0 replies; 4+ messages in thread
From: Amit Shah @ 2010-05-31  7:58 UTC (permalink / raw)
  To: Rusty Russell; +Cc: Virtualization List

On (Mon) May 31 2010 [17:25:35], Rusty Russell wrote:
> On Thu, 27 May 2010 05:24:40 pm Amit Shah wrote:
> > When a program that has a virtio port opened and blocked for a write
> > operation, a port hot-unplug event will later led to a crash when
> > SIGTERM was sent to the program. Fix that.
> > 
> > Signed-off-by: Amit Shah <amit.shah@redhat.com>
> 
> Thanks, both applied.

Please push for 2.6.35 as well. Thanks.

		Amit

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

end of thread, other threads:[~2010-05-31  7:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-27  7:54 [PATCH 1/2] virtio: console: Fix crash when hot-unplugging a port and read is blocked Amit Shah
2010-05-27  7:54 ` [PATCH 2/2] virtio: console: Fix crash when port is unplugged and blocked for write Amit Shah
2010-05-31  7:55   ` Rusty Russell
2010-05-31  7:58     ` Amit Shah

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