• Johan Hovold's avatar
    tty: close race between device register and open · 6a7e6f78
    Johan Hovold authored
    The tty class device is currently not registered until after the
    character device has been registered thereby leaving a small window
    were a racing open could end up with a NULL tty->dev pointer due to the
    class-device lookup failing in alloc_tty_struct.
    
    Close this race by registering the class device before the character
    device while making sure to defer the user-space uevent notification
    until after the character device has been registered.
    
    Note that some tty drivers expect a valid tty->dev and would misbehave
    or crash otherwise. Some line disciplines also currently dereference the
    class device unconditionally despite the fact that not every tty is
    guaranteed to have one (Unix98 pty), but this is being fixed separately.
    Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    6a7e6f78
tty_io.c 90.4 KB