From: sashiko-bot@kernel.org
To: "Sasha Levin" <sashal@kernel.org>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH AUTOSEL 6.18-5.10] serial: 8250: fix possible ISR soft lockup
Date: Mon, 31 Aug 2026 13:58:32 +0000 [thread overview]
Message-ID: <20260831135833.13A931F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831133314.4125787-36-sashal@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Silent transmission data loss due to unconditionally clearing the TX FIFO in the generic ISR path.
- [Medium] Time-of-check to time-of-use (TOCTOU) race condition when clearing the RX FIFO leads to dropped incoming characters.
--
commit 0cb544a0f6cdcc5a3f0967c34cc3dc4a541bfc13
Author: Marco Felsch <m.felsch@pengutronix.de>
serial: 8250: fix possible ISR soft lockup
This commit addresses an ISR soft lockup on 8250 UARTs during startup
caused by unhandled FIFO error (FIFOE) interrupts. It prevents the
lockup by clearing the FIFO if a FIFO error is latched but no data is
ready (DR) in the generic IRQ handler.
Link: https://patch.msgid.link/20260519-v7-1-topic-serial-8250-v1-1-56b04293a246@pengutronix.de
> diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
> index 719faf92aa8ae..108f8fdbebac6 100644
> --- a/drivers/tty/serial/8250/8250_port.c
> +++ b/drivers/tty/serial/8250/8250_port.c
> @@ -1799,6 +1799,13 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
>
> status = serial_lsr_in(up);
>
> + /*
> + * Recover from no-data-ready and FIFO error condition to avoid getting
> + * stuck in the ISR.
> + */
> + if (!(status & UART_LSR_DR) && (status & UART_LSR_FIFOE))
> + serial8250_clear_and_reinit_fifos(up);
[Severity: High]
Does this code inadvertently cause silent data loss for outgoing
transmissions?
When serial8250_handle_irq() calls serial8250_clear_and_reinit_fifos(),
the helper function resets the hardware FIFOs. Looking at the implementation
of serial8250_clear_fifos(), it explicitly clears the TX FIFO alongside
the RX FIFO:
serial_out(p, UART_FCR, UART_FCR_ENABLE_FIFO |
UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT);
Any transient line noise or framing error that triggers this recovery path
on a full-duplex connection will indiscriminately wipe the TX FIFO. Because
the kernel has already advanced the transmit ring buffer assuming these bytes
were safely queued in hardware, the flushed bytes are permanently dropped
without error propagation to userspace or the TTY layer. Should the fix
isolate the hardware reset strictly to the RX FIFO by only issuing
UART_FCR_CLEAR_RCVR?
[Severity: Medium]
Can the gap between reading the LSR and resetting the hardware FIFOs create a
time-of-check to time-of-use (TOCTOU) race condition?
The ISR takes a software snapshot of the LSR register via serial_lsr_in()
and evaluates the error condition based on this snapshot. Between reading
the LSR and executing the hardware FIFO reset in
serial8250_clear_and_reinit_fifos(), new valid characters can arrive in
the hardware shift register and enter the RX FIFO.
The unconditional RX FIFO reset will silently flush these newly arrived bytes
before the driver can read them, leading to dropped incoming characters. Is
there a way to prevent newly received characters from being discarded during
this window?
> +
> /*
> * If port is stopped and there are no error conditions in the
> * FIFO, then don't drain the FIFO, as this may lead to TTY buffer
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260831133314.4125787-36-sashal@kernel.org?part=1
next prev parent reply other threads:[~2026-08-31 13:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260831133314.4125787-1-sashal@kernel.org>
2026-08-31 13:21 ` [PATCH AUTOSEL 6.18-5.10] serial: 8250: fix possible ISR soft lockup Sasha Levin
2026-08-31 13:58 ` sashiko-bot [this message]
2026-08-31 13:21 ` [PATCH AUTOSEL 6.18] tty: serial: 8250: protect against NULL uart->port.dev in register Sasha Levin
2026-08-31 14:21 ` sashiko-bot
2026-08-31 13:21 ` [PATCH AUTOSEL 6.18] serial: 8250_port: recognize UPIO_AU Sasha Levin
2026-08-31 14:19 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260831135833.13A931F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=sashal@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox