Skip to content

tty/serial: Fix tcsetattr() TCSADRAIN/FLUSH and write() races

Ilpo Järvinen linux-serial lkml stable 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 2 repliesIn review
  2. v12 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- Switch DMA Tx running / LSR Tx empty checks order due to fast/slowness
- Calculate the result in serial8250_tx_empty() directly

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSHdrivers/tty/tty.h drivers/tty/tty_io.c drivers/tty/tty_ioctl.c+37 -140 replies
2/2serial: 8250: Fix serial8250_tx_empty() race with DMA Txdrivers/tty/serial/8250/8250.h drivers/tty/serial/8250/8250_port.c+16 -32 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] tty/serial: Fix tcsetattr() TCSADRAIN/FLUSH and write() races

Fix two races related TCSADRAIN/FLUSH. One in tty core and the other that can occur when 8250 UART is using DMA for Tx.

These might be slightly controversial as it requires userspace to race write() with tcsetattr() to trigger these races. But since the races still seem fixable on kernel side, I made these patches.

v2:
- Switch DMA Tx running / LSR Tx empty checks order due to fast/slowness
- Calculate the result in serial8250_tx_empty() directly

Ilpo Järvinen (2):
tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSH
serial: 8250: Fix serial8250_tx_empty() race with DMA Tx

 drivers/tty/serial/8250/8250.h      | 12 ++++++++
 drivers/tty/serial/8250/8250_port.c |  7 +++--
 drivers/tty/tty.h                   |  2 ++
 drivers/tty/tty_io.c                |  4 +--
 drivers/tty/tty_ioctl.c             | 45 +++++++++++++++++++++--------
 5 files changed, 53 insertions(+), 17 deletions(-)
Signature · 1 line
2.30.2