linux/drivers/tty/hvc
Raghavendra Rao Ananta e2bd1dcbe1 tty: hvc: Fix data abort due to race in hvc_open
Potentially, hvc_open() can be called in parallel when two tasks calls
open() on /dev/hvcX. In such a scenario, if the hp->ops->notifier_add()
callback in the function fails, where it sets the tty->driver_data to
NULL, the parallel hvc_open() can see this NULL and cause a memory abort.
Hence, serialize hvc_open and check if tty->private_data is NULL before
proceeding ahead.

The issue can be easily reproduced by launching two tasks simultaneously
that does nothing but open() and close() on /dev/hvcX.
For example:
$ ./simple_open_close /dev/hvc0 & ./simple_open_close /dev/hvc0 &

Signed-off-by: Raghavendra Rao Ananta <rananta@codeaurora.org>
Link: https://lore.kernel.org/r/20200428032601.22127-1-rananta@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-28 14:38:55 +02:00
..
hvc_console.c tty: hvc: Fix data abort due to race in hvc_open 2020-04-28 14:38:55 +02:00
hvc_console.h tty: hvc: Use the correct style for SPDX License Identifier 2020-03-18 13:01:05 +01:00
hvc_dcc.c hvc: dcc: Add earlycon support 2019-10-11 08:38:07 +02:00
hvc_irq.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hvc_iucv.c treewide: kzalloc() -> kcalloc() 2018-06-12 16:19:22 -07:00
hvc_opal.c tty: Use of_node_name_{eq,prefix} for node name comparisons 2018-12-17 16:12:17 +01:00
hvc_riscv_sbi.c tty: Don't force RISCV SBI console as preferred console 2019-05-16 20:42:11 -07:00
hvc_rtas.c tty: hvc: Remove redundant license text 2017-11-08 13:08:12 +01:00
hvc_udbg.c tty: hvc: Remove redundant license text 2017-11-08 13:08:12 +01:00
hvc_vio.c powerpc/pseries/hvconsole: Fix stack overread via udbg 2019-06-14 15:35:53 +10:00
hvc_xen.c tty: hvc_xen: Mark expected switch fall-through 2019-02-26 12:30:44 +01:00
hvcs.c tty: hvc: remove hvcs_driver_string 2020-04-23 15:59:08 +02:00
hvsi_lib.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hvsi.c tty: hvc: Remove redundant license text 2017-11-08 13:08:12 +01:00
Kconfig tty: source all tty Kconfig files in one place 2020-03-12 17:17:30 +01:00
Makefile TTY/Serial driver patches for 4.17-rc1 2018-04-04 18:43:49 -07:00