linux/drivers/tty
Ilpo Järvinen f8d6e9d3ca serial: 8250: Fix __stop_tx() & DMA Tx restart races
Commit e8ffbb71f7 ("serial: 8250: use THRE & __stop_tx also with
DMA") changed __dma_tx_complete() to enable THRI that is cleared in
__stop_tx() once THRE is asserted as UART runs out bits to transmit. It
is possible, however, that more data arrives in between in which case
serial8250_tx_dma() resumes Tx. THRI is not supposed to be on during
DMA Tx because DMA is based on completion handler, therefore THRI must
be cleared unconditionally in serial8250_tx_dma().

When Tx is about to start, another race window exists with
serial8250_handle_irq() leading to a call into __stop_tx() while the
Tx has already been resumed:

__tx_complete():
  -> spin_lock(port->lock)
  -> dma->tx_running = 0
  -> serial8250_set_THRI()
  -> spin_unlock(port->lock)

uart_start():
				serial8250_handle_irq():
  -> spin_lock(port->lock)
  -> serial8250_tx_dma():
    -> dma->tx_running = 1
  -> spin_unlock(port->lock)
				  -> spin_lock(port->lock)
				  -> __stop_tx()

Close this race by checking !dma->tx_running before calling into
__stop_tx().

Fixes: e8ffbb71f7 ("serial: 8250: use THRE & __stop_tx also with DMA")
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20220615090651.15340-2-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-06-27 14:47:57 +02:00
..
hvc xen: branch for v5.19-rc1b 2022-06-04 13:42:53 -07:00
ipwireless
serdev tty: Replace acpi_bus_get_device() 2022-01-31 14:30:06 +01:00
serial serial: 8250: Fix __stop_tx() & DMA Tx restart races 2022-06-27 14:47:57 +02:00
vt vt_ioctl: fix potential spectre v1 in VT_DISALLOCATE 2022-03-18 14:35:01 +01:00
amiserial.c tty: remove CMSPAR ifdefs 2022-05-19 18:26:16 +02:00
ehv_bytechan.c
goldfish.c tty: goldfish: Fix free_irq() on remove 2022-06-10 13:31:31 +02:00
Kconfig
Makefile
mips_ejtag_fdc.c
moxa.c
mxser.c tty: remove BOTHER ifdefs 2022-05-19 18:26:17 +02:00
n_gsm.c tty: n_gsm: Debug output allocation must use GFP_ATOMIC 2022-06-10 13:30:11 +02:00
n_hdlc.c Linux 5.16-rc6 2021-12-20 10:00:30 +01:00
n_null.c
n_tty.c tty: Rework receive flow control char logic 2022-05-19 18:33:34 +02:00
nozomi.c
pty.c
rpmsg_tty.c tty: rpmsg: Fix race condition releasing tty port 2022-01-26 14:50:26 +01:00
synclink_gt.c tty: synclink_gt: Fix null-pointer-dereference in slgt_clean() 2022-04-14 18:26:30 +02:00
sysrq.c TTY / Serial driver changes for 5.19-rc1 2022-06-03 11:08:40 -07:00
tty.h
tty_audit.c
tty_baudrate.c tty: remove IBSHIFT ifdefs 2022-05-19 18:26:17 +02:00
tty_buffer.c tty: fix deadlock caused by calling printk() under tty_port->lock 2022-05-12 20:38:37 -07:00
tty_io.c memcg: enable accounting for tty-related objects 2022-03-22 15:57:04 -07:00
tty_ioctl.c tty: remove BOTHER ifdefs 2022-05-19 18:26:17 +02:00
tty_jobctrl.c signal: Replace __group_send_sig_info with send_signal_locked 2022-05-11 14:33:17 -05:00
tty_ldisc.c
tty_ldsem.c tty/ldsem: Fix syntax errors in comments 2021-12-21 09:15:49 +01:00
tty_mutex.c
tty_port.c tty: Drop duplicate NULL check in TTY port functions 2022-02-04 16:58:25 +01:00
ttynull.c
vcc.c