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.0-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.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.


>From 671bdea2b9f210566610603ecbb6584c8a201c8c Mon Sep 17 00:00:00 2001
From: Amit Shah <[email protected]>
Date: Mon, 29 Jul 2013 14:17:13 +0930
Subject: virtio: console: fix race in port_fops_open() and port unplug

From: Amit Shah <[email protected]>

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 <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
 drivers/char/virtio_console.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -786,6 +786,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 [email protected] are

queue-3.0/virtio-console-fix-raising-sigio-after-port-unplug.patch
queue-3.0/virtio-console-clean-up-port-data-immediately-at-time-of-unplug.patch
queue-3.0/virtio-console-fix-race-in-port_fops_open-and-port-unplug.patch
queue-3.0/virtio-console-return-enodev-on-all-read-operations-after-unplug.patch
queue-3.0/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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to