The commit is pushed to "branch-rh7-3.10.0-327.3.1-vz7.10.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.3.1.vz7.10.8
------>
commit ab9f5d42ce7c9c35e7e2e9066f7873a0a9f889a1
Author: Cyrill Gorcunov <[email protected]>
Date:   Fri Jan 29 18:49:15 2016 +0400

    ms/tty: Invert tty_lock/ldisc_sem lock order
    
    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]>
---
 drivers/tty/tty_ldisc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index d389c82..d1b8ef5 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -524,9 +524,11 @@ int tty_set_ldisc(struct tty_struct *tty, int ldisc)
        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, int ldisc)
        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, int ldisc)
        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