• Peter Hurley's avatar
    serial: core: Prevent unsafe uart port access, part 1 · 4047b371
    Peter Hurley authored
    uart_remove_one_port() may race with every serial core operation
    requiring a valid dereference of state->uart_port. In particular,
    uart_remove_one_port() may unlink the uart port concurrently with
    any serial core operation that may dereference same.
    
    Ensure safe dereference for those operations that already claim
    the port->mutex, and extend that guarantee for trivial cases,
    such as the ioctl handlers. Introduce the uart_port_check() helper
    which asserts port->mutex is held (only when lockdep is on).
    
    For ioctls, return -EIO as if the port has been hung up (since it has).
    Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    4047b371
serial_core.c 72.9 KB