linux_dsm_epyc7002/drivers/tty
Nguyen Dinh Phi c2e390c4df tty: Fix data race between tiocsti() and flush_to_ldisc()
commit bb2853a6a421a052268eee00fd5d3f6b3504b2b1 upstream.

The ops->receive_buf() may be accessed concurrently from these two
functions.  If the driver flushes data to the line discipline
receive_buf() method while tiocsti() is waiting for the
ops->receive_buf() to finish its work, the data race will happen.

For example:
tty_ioctl			|tty_ldisc_receive_buf
 ->tioctsi			| ->tty_port_default_receive_buf
				|  ->tty_ldisc_receive_buf
   ->hci_uart_tty_receive	|   ->hci_uart_tty_receive
    ->h4_recv                   |    ->h4_recv

In this case, the h4 receive buffer will be overwritten by the
latecomer, and we will lost the data.

Hence, change tioctsi() function to use the exclusive lock interface
from tty_buffer to avoid the data race.

Reported-by: syzbot+97388eb9d31b997fe1d0@syzkaller.appspotmail.com
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
Link: https://lore.kernel.org/r/20210823000641.2082292-1-phind.uet@gmail.com
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-07-05 19:13:40 +02:00
..
hvc
ipwireless
serdev
serial tty: serial: fsl_lpuart: fix the wrong mapbase value 2024-07-05 19:12:32 +02:00
vt init: add dsm gpl source 2024-07-05 18:00:04 +02:00
amiserial.c tty: amiserial: fix TIOCSSERIAL permission check 2021-05-14 09:49:55 +02:00
cyclades.c
ehv_bytechan.c
goldfish.c
isicom.c
Kconfig
Makefile
mips_ejtag_fdc.c
moxa.c tty: moxa: fix TIOCSSERIAL permission check 2021-05-14 09:49:56 +02:00
moxa.h
mxser.c
mxser.h
n_gsm.c tty: n_gsm: check error while registering tty devices 2021-05-11 14:47:21 +02:00
n_hdlc.c tty: convert tty_ldisc_ops 'read()' function to take a kernel pointer 2021-03-04 11:37:36 +01:00
n_null.c tty: convert tty_ldisc_ops 'read()' function to take a kernel pointer 2021-03-04 11:37:36 +01:00
n_r3964.c tty: convert tty_ldisc_ops 'read()' function to take a kernel pointer 2021-03-04 11:37:36 +01:00
n_tracerouter.c tty: convert tty_ldisc_ops 'read()' function to take a kernel pointer 2021-03-04 11:37:36 +01:00
n_tracesink.c tty: convert tty_ldisc_ops 'read()' function to take a kernel pointer 2021-03-04 11:37:36 +01:00
n_tracesink.h
n_tty.c init: add dsm gpl source 2024-07-05 18:00:04 +02:00
nozomi.c tty: nozomi: Fix the error handling path of 'nozomi_card_init()' 2021-07-14 16:56:39 +02:00
pty.c
rocket_int.h
rocket.c
rocket.h
synclink_gt.c
synclink.c
synclinkmp.c
sysrq.c init: add dsm gpl source 2024-07-05 18:00:04 +02:00
tty_audit.c
tty_baudrate.c
tty_buffer.c
tty_io.c tty: Fix data race between tiocsti() and flush_to_ldisc() 2024-07-05 19:13:40 +02:00
tty_ioctl.c tty: fix return value for unsupported termiox ioctls 2021-05-14 09:50:19 +02:00
tty_jobctrl.c tty: Fix ->session locking 2020-12-04 17:39:58 +01:00
tty_ldisc.c
tty_ldsem.c
tty_mutex.c
tty_port.c
ttynull.c
vcc.c