ML: c8483bc9deff9bf9118aaab2e840b973b75cac3e

From: Peter Hurley <[email protected]>
Date: Wed, 5 Nov 2014 12:12:45 -0500

Dropping the tty lock to acquire the tty->ldisc_sem allows several
race conditions (such as hangup while changing the ldisc) which requires
extra states and testing. The ldisc_sem->tty_lock lock order has
not been required since tty buffer ownership was moved to tty_port.

Reviewed-by: Alan Cox <[email protected]>
Signed-off-by: Peter Hurley <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

https://jira.sw.ru/browse/PSBM-43454

Signed-off-by: Cyrill Gorcunov <[email protected]>
CC: Vladimir Davydov <[email protected]>
CC: Konstantin Khorenko <[email protected]>
---

Kostya, it's an addition to PSBM-43454.

 drivers/tty/tty_ldisc.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: linux-pcs7.git/drivers/tty/tty_ldisc.c
===================================================================
--- linux-pcs7.git.orig/drivers/tty/tty_ldisc.c
+++ linux-pcs7.git/drivers/tty/tty_ldisc.c
@@ -524,9 +524,11 @@ int tty_set_ldisc(struct tty_struct *tty
        if (IS_ERR(new_ldisc))
                return PTR_ERR(new_ldisc);
 
+       tty_lock(tty);
        retval = tty_ldisc_lock_pair_timeout(tty, o_tty, 5 * HZ);
        if (retval) {
                tty_ldisc_put(new_ldisc);
+               tty_unlock(tty);
                return retval;
        }
 
@@ -537,6 +539,7 @@ int tty_set_ldisc(struct tty_struct *tty
        if (tty->ldisc->ops->num == ldisc) {
                tty_ldisc_enable_pair(tty, o_tty);
                tty_ldisc_put(new_ldisc);
+               tty_unlock(tty);
                return 0;
        }
 
@@ -544,7 +547,6 @@ int tty_set_ldisc(struct tty_struct *tty
        tty->receive_room = 0;
 
        o_ldisc = tty->ldisc;
-       tty_lock(tty);
 
        /* FIXME: for testing only */
        WARN_ON(test_bit(TTY_HUPPED, &tty->flags));
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to