All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] serial: tegra: fix RX/TX DMA descriptor use-after-free
@ 2026-10-15  3:29 ` Austin Schlegel
  0 siblings, 0 replies; 8+ messages in thread
From: Austin Schlegel via B4 Relay @ 2026-10-15  3:29 UTC (permalink / raw)
  To: Laxman Dewangan, Greg Kroah-Hartman, Jiri Slaby, Thierry Reding,
	Jonathan Hunter
  Cc: linux-kernel, linux-serial, linux-tegra, Austin Schlegel,
	Austin Schlegel, stable

Both patches in this series fix the same bug pattern in
drivers/tty/serial/serial-tegra.c: dmaengine_terminate_all() is called
before async_tx_ack() on the DMA descriptor it just terminated. With
the GPC DMA driver (tegra186-gpc-dma.c, used on Tegra194/Tegra234),
terminating a channel frees the active descriptor synchronously via
vchan_dma_desc_free_list(), so the subsequent ack touches freed
memory. dmaengine clients are not allowed to touch a descriptor once
it has been terminated.

Patch 1/2 (RX) was found via a KFENCE use-after-free report on a
Jetson AGX Orin (Tegra234) under UART loopback traffic, and the fix
has since been soak tested for 24+ hours with
kfence.sample_interval=1 with zero further reports. It keeps the
descriptor-leak fix from commit b31245b94207 ("serial: tegra: ack
the rx dma desc after transfer terminated") intact: the ack still
happens for every terminated RX transfer, just before the descriptor
is freed instead of after.

Patch 2/2 (TX) is the same ordering bug in the analogous TX path
(tegra_uart_stop_tx()), present since the driver was added, and found
by code inspection once the RX bug was understood. It has not been
reproduced on hardware - triggering it requires stopping an in-flight
TX DMA transfer at the right moment, which did not occur during RX
testing - but it is the identical dmaengine_terminate_all()-then-ack
pattern in the same driver against the same DMA engine, so I'm sending
it alongside the RX fix rather than leaving it unfixed.

Testing was done on Tegra234 (Jetson AGX Orin) only.

Signed-off-by: Austin Schlegel <schlegelas@outlook.com>
---
Changes in v2:
- Commit message updates only; no code changes.
- Patch 1: removed an inaccurate statement that the freed descriptor
  is accessed in tegra_uart_rx_dma_complete(); updated the soak test
  duration to 24+ hours.
- Patch 2: removed an inaccurate flush example; added Fixes: tag.
- Switched to my personal email address (v1 was sent from
  austin.schlegel@arthrex.com).
- Link to v1: https://lore.kernel.org/r/20261001-tty-linus-v1-0-ecb8576c802d@arthrex.com

---
Austin Schlegel (2):
      serial: tegra: fix RX DMA descriptor use-after-free
      serial: tegra: fix TX DMA descriptor use-after-free

 drivers/tty/serial/serial-tegra.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
base-commit: a90ee4305c4a5df72c11b31dacfdc76e00fcf78a
change-id: 20261014-serial-tegra-dma-uaf-39ed62701ab6

Best regards,
-- 
Austin Schlegel <schlegelas@outlook.com>



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-10-15  3:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-15  3:29 [PATCH v2 0/2] serial: tegra: fix RX/TX DMA descriptor use-after-free Austin Schlegel via B4 Relay
2026-10-15  3:29 ` Austin Schlegel
2026-10-15  3:30 ` [PATCH v2 1/2] serial: tegra: fix RX " Austin Schlegel via B4 Relay
2026-10-15  3:30   ` Austin Schlegel
2026-10-15  3:43   ` sashiko-bot
2026-10-15  3:30 ` [PATCH v2 2/2] serial: tegra: fix TX " Austin Schlegel via B4 Relay
2026-10-15  3:30   ` Austin Schlegel
2026-10-15  3:41   ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.