• Jiri Slaby's avatar
    TTY: ldisc, wait for ldisc infinitely in hangup · 0c73c08e
    Jiri Slaby authored
    For /dev/console case, we do not kill all ldisc users. It's due to
    redirected_tty_write test in __tty_hangup. In that case there still
    might be a process waiting e.g. in n_tty_read for input.
    
    We wait for such processes to disappear. The problem is that we use a
    timeout. After this timeout, we continue closing the ldisc and start
    freeing tty resources. It obviously leads to crashes when the other
    process is woken.
    
    So to fix this, we wait infinitely before reiniting the ldisc. (The
    tiocsetd remains untouched -- times out after 5s.)
    
    This is nicely reproducible with this run from shell:
      exec 0<>/dev/console 1<>/dev/console 2<>/dev/console
    and stopping a getty like:
      systemctl stop serial-getty@ttyS0.service
    
    The crash proper may be produced only under load or with constified
    timing the same as for 92f6fa09.
    Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
    Cc: Dave Young <hidave.darkstar@gmail.com>
    Cc: Dave Jones <davej@redhat.com>
    Cc: Ben Hutchings <ben@decadent.org.uk>
    Cc: Dmitriy Matrosov <sgf.dma@gmail.com>
    Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    0c73c08e
tty_ldisc.c 23.8 KB