]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Revert "tty: pty: Fix race condition between release_one_tty and pty_write"
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 29 Mar 2019 14:47:40 +0000 (15:47 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 29 Mar 2019 14:47:40 +0000 (15:47 +0100)
This reverts commit b9ca5f8560af244489b4a1bc1ae88b341f24bc95 as 0-day
shows it has a circular locking dependency.

Fixes: b9ca5f8560af ("tty: pty: Fix race condition between release_one_tty and pty_write")
Reported-by: kernel test robot <lkp@intel.com>
Cc: Sahara <keun-o.park@darkmatter.ae>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/pty.c
drivers/tty/tty_io.c

index ef72031ab5b95ddf7af62660acfea79ce52b824d..00099a8439d219184c131f5d24c1e60fa2c20285 100644 (file)
@@ -116,12 +116,6 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
        if (tty->stopped)
                return 0;
 
-       mutex_lock(&tty_mutex);
-       if (to->magic != TTY_MAGIC) {
-               mutex_unlock(&tty_mutex);
-               return -EIO;
-       }
-
        if (c > 0) {
                spin_lock_irqsave(&to->port->lock, flags);
                /* Stuff the data into the input queue of the other end */
@@ -131,7 +125,6 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
                        tty_flip_buffer_push(to->port);
                spin_unlock_irqrestore(&to->port->lock, flags);
        }
-       mutex_unlock(&tty_mutex);
        return c;
 }
 
index c27777f3b8c4426045fcf68ce4546ea85aabcad6..5fa250157025686e92c2399f3a46631421e79068 100644 (file)
@@ -1448,13 +1448,10 @@ static void release_one_tty(struct work_struct *work)
        struct tty_driver *driver = tty->driver;
        struct module *owner = driver->owner;
 
-       mutex_lock(&tty_mutex);
        if (tty->ops->cleanup)
                tty->ops->cleanup(tty);
 
        tty->magic = 0;
-       mutex_unlock(&tty_mutex);
-
        tty_driver_kref_put(driver);
        module_put(owner);