Re: [PATCH] serial: drop debugging WARN_ON_ONCE() from uart_write()

From: Jiri Slaby
Date: Mon Jun 03 2024 - 03:10:37 EST


On 28. 05. 24, 17:05, Tetsuo Handa wrote:
syzbot is reporting lockdep warning upon

int disc = 7;
ioctl(open("/dev/ttyS3", O_RDONLY), TIOCSETD, &disc);

sequence. Do like what commit 5f1149d2f4bf ("serial: drop debugging
WARN_ON_ONCE() from uart_put_char()") does.

Reported-by: syzbot+f78380e4eae53c64125c@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=f78380e4eae53c64125c
Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>

Ugh, definitely:

Acked-by: Jiri Slaby <jirislaby@xxxxxxxxxx>

---
Example is https://syzkaller.appspot.com/text?tag=CrashReport&x=100271ec980000 .
But not using this example, for this link will disappear eventually.

By the way, do we want to also guard uart_port_lock'ed section using
printk_deferred_enter()/printk_deferred_exit(), for trying to use e.g.
WARN_ON() inside such section will result in the same lockdep warning?
At this point, I don't know the answer.

--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -622,7 +622,7 @@ static ssize_t uart_write(struct tty_struct *tty, const u8 *buf, size_t count)
return -EL3HLT;
port = uart_port_lock(state, flags);
- if (WARN_ON_ONCE(!state->port.xmit_buf)) {
+ if (!state->port.xmit_buf) {
uart_port_unlock(port, flags);
return 0;
}

--
js
suse labs