• Peter Hurley's avatar
    tty: Fix ioctl(FIOASYNC) on hungup file · a8f3a297
    Peter Hurley authored
    A small race window exists which allows signal-driven async i/o to be
    enabled for the tty when the file ptr has already been hungup and
    signal-driven i/o has been disabled:
    
    CPU 0                                CPU 1
    -----                                ------
    ioctl_fioasync(on)
      filp->f_op->fasync(on)             __tty_hangup()
        tty_fasync(on)                     tty_lock()
          tty_lock()                       ...
            .                              filp->f_op = &hung_up_tty_fops;
          (waiting)                       __tty_fasync(off)
            .                              tty_unlock()
          /* gets tty lock  */
          /* enables FASYNC */
    
    Check the tty has not been hungup while holding tty_lock.
    Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    a8f3a297
tty_io.c 90.1 KB