Amit Shah
2010-May-27 07:54 UTC
[PATCH 1/2] virtio: console: Fix crash when hot-unplugging a port and read is blocked
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 at 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
Amit Shah
2010-May-27 07:54 UTC
[PATCH 2/2] virtio: console: Fix crash when port is unplugged and blocked for write
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 at 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
Rusty Russell
2010-May-31 07:55 UTC
[PATCH 2/2] virtio: console: Fix crash when port is unplugged and blocked for write
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 at redhat.com>Thanks, both applied. Cheers, Rusty.
Amit Shah
2010-May-31 07:58 UTC
[PATCH 2/2] virtio: console: Fix crash when port is unplugged and blocked for write
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 at redhat.com> > > Thanks, both applied.Please push for 2.6.35 as well. Thanks. Amit
Possibly Parallel Threads
- [PATCH 1/2] virtio: console: Fix crash when hot-unplugging a port and read is blocked
- [PATCH 00/14] virtio: console: Hot-unplug fixes
- [PATCH 00/14] virtio: console: Hot-unplug fixes
- [PATCH 4/4] virtio: disable multiport console support.
- [PATCH 4/4] virtio: disable multiport console support.