* [PATCH] serial: 8250: Lock saved status flag resets during startup
@ 2026-11-11 8:41 Zhu Jun
2026-11-11 8:49 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Zhu Jun @ 2026-11-11 8:41 UTC (permalink / raw)
To: jirislaby
Cc: gregkh, linux-serial, linux-kernel, syzbot+eebcc2b949c1c7663850,
Zhu Jun
serial8250_do_startup() clears lsr_saved_flags and msr_saved_flags after
installing the IRQ handler and starting the port timer. An interrupt or
console write can access these flags concurrently under the port lock,
as reported by KCSAN.
Hold the port lock while clearing the interrupt registers and resetting
the saved flags, so the reset is serialized with their other users.
Fixes: ad4c2aa6354f ("Serial 8250: handle saving the clear-on-read bits from the LSR and MSR")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
drivers/tty/serial/8250/8250_port.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 36b2b0a2c05c..dc5e002332be 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -2386,9 +2386,11 @@ int serial8250_do_startup(struct uart_port *port)
* saved flags to avoid getting false values from polling
* routines or the previous session.
*/
- serial8250_clear_interrupts(port);
- up->lsr_saved_flags = 0;
- up->msr_saved_flags = 0;
+ scoped_guard(uart_port_lock_irqsave, port) {
+ serial8250_clear_interrupts(port);
+ up->lsr_saved_flags = 0;
+ up->msr_saved_flags = 0;
+ }
/*
* Request DMA channels for both RX and TX.
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-11 8:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-11 8:41 [PATCH] serial: 8250: Lock saved status flag resets during startup Zhu Jun
2026-11-11 8:49 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox