diff mbox series

serial: drop debugging WARN_ON_ONCE() from uart_write()

Message ID d775ae2d-a2ac-439e-8e2b-134749f60f30@I-love.SAKURA.ne.jp
State New
Headers show
Series serial: drop debugging WARN_ON_ONCE() from uart_write() | expand

Commit Message

Tetsuo Handa May 28, 2024, 3:05 p.m. UTC
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@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=f78380e4eae53c64125c
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
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?

 drivers/tty/serial/serial_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jiri Slaby June 3, 2024, 7:10 a.m. UTC | #1
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@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=f78380e4eae53c64125c
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>

Ugh, definitely:

Acked-by: Jiri Slaby <jirislaby@kernel.org>

> ---
> 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;
>   	}
diff mbox series

Patch

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 2c1a0254d3f4..0c4d60976663 100644
--- 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;
 	}