]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
serial_core: Check for port state when tty is in error state
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Thu, 3 Dec 2020 05:58:34 +0000 (16:58 +1100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 20 Jan 2021 13:25:31 +0000 (14:25 +0100)
commit09533e72a9e5def40a410dfbac17bc7e76516fd5
tree6b344f99339d212c99f1b82e871b3f92e6e945af
parenta6213baa0b5e5dc9205a2b37dc352b2ce23a05e1
serial_core: Check for port state when tty is in error state

BugLink: https://bugs.launchpad.net/bugs/1910822
commit 2f70e49ed860020f5abae4f7015018ebc10e1f0e upstream.

At the moment opening a serial device node (such as /dev/ttyS3)
succeeds even if there is no actual serial device behind it.
Reading/writing/ioctls fail as expected because the uart port is not
initialized (the type is PORT_UNKNOWN) and the TTY_IO_ERROR error state
bit is set fot the tty.

However setting line discipline does not have these checks
8250_port.c (8250 is the default choice made by univ8250_console_init()).
As the result of PORT_UNKNOWN, uart_port::iobase is NULL which
a platform translates onto some address accessing which produces a crash
like below.

This adds tty_port_initialized() to uart_set_ldisc() to prevent the crash.

Found by syzkaller.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Link: https://lore.kernel.org/r/20201203055834.45838-1-aik@ozlabs.ru
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
drivers/tty/serial/serial_core.c