This is a note to let you know that I've just added the patch titled virtio: console: fix race in port_fops_open() and port unplug to the 3.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: virtio-console-fix-race-in-port_fops_open-and-port-unplug.patch and it can be found in the queue-3.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 671bdea2b9f210566610603ecbb6584c8a201c8c Mon Sep 17 00:00:00 2001 From: Amit Shah <amit.shah@xxxxxxxxxx> Date: Mon, 29 Jul 2013 14:17:13 +0930 Subject: virtio: console: fix race in port_fops_open() and port unplug From: Amit Shah <amit.shah@xxxxxxxxxx> commit 671bdea2b9f210566610603ecbb6584c8a201c8c upstream. Between open() being called and processed, the port can be unplugged. Check if this happened, and bail out. A simple test script to reproduce this is: while true; do for i in $(seq 1 100); do echo $i > /dev/vport0p3; done; done; This opens and closes the port a lot of times; unplugging the port while this is happening triggers the bug. Signed-off-by: Amit Shah <amit.shah@xxxxxxxxxx> Signed-off-by: Rusty Russell <rusty@xxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/char/virtio_console.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -1041,6 +1041,10 @@ static int port_fops_open(struct inode * /* We get the port with a kref here */ port = find_port_by_devt(cdev->dev); + if (!port) { + /* Port was unplugged before we could proceed */ + return -ENXIO; + } filp->private_data = port; /* Patches currently in stable-queue which might be from amit.shah@xxxxxxxxxx are queue-3.10/virtio-console-fix-raising-sigio-after-port-unplug.patch queue-3.10/virtio-console-clean-up-port-data-immediately-at-time-of-unplug.patch queue-3.10/virtio-console-quit-from-splice_write-if-pipe-nrbufs-is-0.patch queue-3.10/virtio-console-fix-race-in-port_fops_open-and-port-unplug.patch queue-3.10/virtio-console-add-pipe_lock-unlock-for-splice_write.patch queue-3.10/virtio-console-return-enodev-on-all-read-operations-after-unplug.patch queue-3.10/virtio-console-fix-race-with-port-unplug-and-open-close.patch -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html