Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "tty: pty: Fix race condition between release_one_tty and pty_write"

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>

-10
-7
drivers/tty/pty.c
··· 116 116 if (tty->stopped) 117 117 return 0; 118 118 119 - mutex_lock(&tty_mutex); 120 - if (to->magic != TTY_MAGIC) { 121 - mutex_unlock(&tty_mutex); 122 - return -EIO; 123 - } 124 - 125 119 if (c > 0) { 126 120 spin_lock_irqsave(&to->port->lock, flags); 127 121 /* Stuff the data into the input queue of the other end */ ··· 125 131 tty_flip_buffer_push(to->port); 126 132 spin_unlock_irqrestore(&to->port->lock, flags); 127 133 } 128 - mutex_unlock(&tty_mutex); 129 134 return c; 130 135 } 131 136
-3
drivers/tty/tty_io.c
··· 1448 1448 struct tty_driver *driver = tty->driver; 1449 1449 struct module *owner = driver->owner; 1450 1450 1451 - mutex_lock(&tty_mutex); 1452 1451 if (tty->ops->cleanup) 1453 1452 tty->ops->cleanup(tty); 1454 1453 1455 1454 tty->magic = 0; 1456 - mutex_unlock(&tty_mutex); 1457 - 1458 1455 tty_driver_kref_put(driver); 1459 1456 module_put(owner); 1460 1457