]> git.karo-electronics.de Git - linux-beck.git/commit
serial: core: Prevent unsafe uart port access, part 1
authorPeter Hurley <peter@hurleysoftware.com>
Sun, 10 Apr 2016 01:56:33 +0000 (18:56 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 30 Apr 2016 16:26:55 +0000 (09:26 -0700)
commit4047b37122d1be8dd8e8c504f6f596930b660188
tree678ddab05db8005e3f637d5b91149e5f99e2f2dc
parent49c02304fe97f88ee65f92368fe3f473201a7976
serial: core: Prevent unsafe uart port access, part 1

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: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/serial_core.c