syzbot


possible deadlock in uart_write (2)

Status: upstream: reported on 2024/04/25 04:00
Subsystems: serial
[Documentation on labels]
Reported-by: syzbot+57cc2f20a84cb4346354@syzkaller.appspotmail.com
First crash: 31d, last: 17d
Discussions (2)
Title Replies (including bot) Last reply
[syzbot] Monthly serial report (May 2024) 0 (1) 2024/05/06 13:18
[syzbot] [serial?] possible deadlock in uart_write (2) 0 (1) 2024/04/25 04:00
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in uart_write serial C done unreliable 609 885d 1608d 0/26 auto-obsoleted due to no activity on 2022/10/21 10:26
linux-4.19 possible deadlock in uart_write C 839 450d 1569d 0/1 upstream: reported C repro on 2020/02/04 05:05
linux-4.14 possible deadlock in uart_write C error 394 455d 1578d 0/1 upstream: reported C repro on 2020/01/26 11:10

Sample crash report:
sp0: Synchronizing with TNC
------------[ cut here ]------------
======================================================
WARNING: possible circular locking dependency detected
6.9.0-rc6-next-20240503-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.2/10514 is trying to acquire lock:
ffffffff8e327fa0 (console_owner){....}-{0:0}, at: console_trylock_spinning kernel/printk/printk.c:1994 [inline]
ffffffff8e327fa0 (console_owner){....}-{0:0}, at: vprintk_emit+0x3cf/0x770 kernel/printk/printk.c:2344

but task is already holding lock:
ffffffff94ad0858 (&port_lock_key){-.-.}-{2:2}, at: uart_port_lock_irqsave include/linux/serial_core.h:618 [inline]
ffffffff94ad0858 (&port_lock_key){-.-.}-{2:2}, at: uart_write+0x10e/0x320 drivers/tty/serial/serial_core.c:624

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&port_lock_key){-.-.}-{2:2}:
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5754
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0xd5/0x120 kernel/locking/spinlock.c:162
       uart_port_lock_irqsave include/linux/serial_core.h:618 [inline]
       serial8250_console_write+0x1a8/0x1770 drivers/tty/serial/8250/8250_port.c:3352
       console_emit_next_record kernel/printk/printk.c:2928 [inline]
       console_flush_all+0x867/0xfd0 kernel/printk/printk.c:2994
       console_unlock+0x13b/0x4d0 kernel/printk/printk.c:3063
       vprintk_emit+0x5a6/0x770 kernel/printk/printk.c:2345
       _printk+0xd5/0x120 kernel/printk/printk.c:2370
       register_console+0x722/0xce0 kernel/printk/printk.c:3596
       univ8250_console_init+0x49/0x50 drivers/tty/serial/8250/8250_core.c:723
       console_init+0x1b8/0x6f0 kernel/printk/printk.c:3742
       start_kernel+0x2d3/0x500 init/main.c:1036
       x86_64_start_reservations+0x2a/0x30 arch/x86/kernel/head64.c:507
       x86_64_start_kernel+0x99/0xa0 arch/x86/kernel/head64.c:488
       common_startup_64+0x13e/0x147

-> #0 (console_owner){....}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3134 [inline]
       check_prevs_add kernel/locking/lockdep.c:3253 [inline]
       validate_chain+0x18cb/0x58e0 kernel/locking/lockdep.c:3869
       __lock_acquire+0x1346/0x1fd0 kernel/locking/lockdep.c:5137
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5754
       console_trylock_spinning kernel/printk/printk.c:1994 [inline]
       vprintk_emit+0x3ec/0x770 kernel/printk/printk.c:2344
       _printk+0xd5/0x120 kernel/printk/printk.c:2370
       __report_bug lib/bug.c:195 [inline]
       report_bug+0x346/0x500 lib/bug.c:219
       handle_bug+0x3e/0x70 arch/x86/kernel/traps.c:239
       exc_invalid_op+0x1a/0x50 arch/x86/kernel/traps.c:260
       asm_exc_invalid_op+0x1a/0x20 arch/x86/include/asm/idtentry.h:621
       uart_write+0x2b0/0x320 drivers/tty/serial/serial_core.c:625
       tnc_init drivers/net/hamradio/6pack.c:531 [inline]
       sixpack_open+0x790/0xa80 drivers/net/hamradio/6pack.c:628
       tty_ldisc_open drivers/tty/tty_ldisc.c:432 [inline]
       tty_ldisc_reinit+0x2d4/0x4a0 drivers/tty/tty_ldisc.c:661
       tty_reopen+0x20b/0x2d0 drivers/tty/tty_io.c:1366
       tty_open_by_driver drivers/tty/tty_io.c:2082 [inline]
       tty_open+0xa26/0xdf0 drivers/tty/tty_io.c:2135
       chrdev_open+0x5b0/0x630 fs/char_dev.c:414
       do_dentry_open+0x95a/0x1720 fs/open.c:955
       do_open fs/namei.c:3650 [inline]
       path_openat+0x289f/0x3280 fs/namei.c:3807
       do_filp_open+0x235/0x490 fs/namei.c:3834
       do_sys_openat2+0x13e/0x1d0 fs/open.c:1405
       do_sys_open fs/open.c:1420 [inline]
       __do_sys_openat fs/open.c:1436 [inline]
       __se_sys_openat fs/open.c:1431 [inline]
       __x64_sys_openat+0x247/0x2a0 fs/open.c:1431
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&port_lock_key);
                               lock(console_owner);
                               lock(&port_lock_key);
  lock(console_owner);

 *** DEADLOCK ***

3 locks held by syz-executor.2/10514:
 #0: ffff88807ad101c0 (&tty->legacy_mutex){+.+.}-{3:3}, at: tty_lock_interruptible+0x68/0xc0 drivers/tty/tty_mutex.c:27
 #1: ffff88807ad100a0 (&tty->ldisc_sem){++++}-{0:0}, at: __tty_ldisc_lock drivers/tty/tty_ldisc.c:289 [inline]
 #1: ffff88807ad100a0 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_lock+0x6c/0xc0 drivers/tty/tty_ldisc.c:313
 #2: ffffffff94ad0858 (&port_lock_key){-.-.}-{2:2}, at: uart_port_lock_irqsave include/linux/serial_core.h:618 [inline]
 #2: ffffffff94ad0858 (&port_lock_key){-.-.}-{2:2}, at: uart_write+0x10e/0x320 drivers/tty/serial/serial_core.c:624

stack backtrace:
CPU: 1 PID: 10514 Comm: syz-executor.2 Not tainted 6.9.0-rc6-next-20240503-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
 check_noncircular+0x36a/0x4a0 kernel/locking/lockdep.c:2187
 check_prev_add kernel/locking/lockdep.c:3134 [inline]
 check_prevs_add kernel/locking/lockdep.c:3253 [inline]
 validate_chain+0x18cb/0x58e0 kernel/locking/lockdep.c:3869
 __lock_acquire+0x1346/0x1fd0 kernel/locking/lockdep.c:5137
 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5754
 console_trylock_spinning kernel/printk/printk.c:1994 [inline]
 vprintk_emit+0x3ec/0x770 kernel/printk/printk.c:2344
 _printk+0xd5/0x120 kernel/printk/printk.c:2370
 __report_bug lib/bug.c:195 [inline]
 report_bug+0x346/0x500 lib/bug.c:219
 handle_bug+0x3e/0x70 arch/x86/kernel/traps.c:239
 exc_invalid_op+0x1a/0x50 arch/x86/kernel/traps.c:260
 asm_exc_invalid_op+0x1a/0x20 arch/x86/include/asm/idtentry.h:621
RIP: 0010:uart_write+0x2b0/0x320 drivers/tty/serial/serial_core.c:625
Code: 74 08 48 89 df e8 10 f4 be fc 48 83 3b 00 74 74 e8 15 45 59 fc eb 97 e8 0e 45 59 fc 45 31 e4 eb 08 e8 04 45 59 fc 45 31 ed 90 <0f> 0b 90 45 84 e4 74 0a e8 f3 44 59 fc 45 31 f6 eb 84 e8 e9 44 59
RSP: 0018:ffffc900050874b8 EFLAGS: 00010046
RAX: ffffffff853cd0d2 RBX: dffffc0000000000 RCX: 0000000000040000
RDX: ffffc9000c925000 RSI: 000000000001ba30 RDI: 000000000001ba31
RBP: ffff88801fde8f48 R08: 0000000000000003 R09: fffff52000a10e74
R10: dffffc0000000000 R11: fffff52000a10e74 R12: 0000000000000000
R13: 0000000000000246 R14: ffff88801fde8be8 R15: ffffffff94ad0840
 tnc_init drivers/net/hamradio/6pack.c:531 [inline]
 sixpack_open+0x790/0xa80 drivers/net/hamradio/6pack.c:628
 tty_ldisc_open drivers/tty/tty_ldisc.c:432 [inline]
 tty_ldisc_reinit+0x2d4/0x4a0 drivers/tty/tty_ldisc.c:661
 tty_reopen+0x20b/0x2d0 drivers/tty/tty_io.c:1366
 tty_open_by_driver drivers/tty/tty_io.c:2082 [inline]
 tty_open+0xa26/0xdf0 drivers/tty/tty_io.c:2135
 chrdev_open+0x5b0/0x630 fs/char_dev.c:414
 do_dentry_open+0x95a/0x1720 fs/open.c:955
 do_open fs/namei.c:3650 [inline]
 path_openat+0x289f/0x3280 fs/namei.c:3807
 do_filp_open+0x235/0x490 fs/namei.c:3834
 do_sys_openat2+0x13e/0x1d0 fs/open.c:1405
 do_sys_open fs/open.c:1420 [inline]
 __do_sys_openat fs/open.c:1436 [inline]
 __se_sys_openat fs/open.c:1431 [inline]
 __x64_sys_openat+0x247/0x2a0 fs/open.c:1431
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f790a27dca9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f7909dde0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007f790a3ac050 RCX: 00007f790a27dca9
RDX: 0000000000000000 RSI: 0000000020000240 RDI: ffffffffffffff9c
RBP: 00007f790a2c947e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000006e R14: 00007f790a3ac050 R15: 00007ffc2522d128
 </TASK>
WARNING: CPU: 1 PID: 10514 at drivers/tty/serial/serial_core.c:625 uart_write+0x2b0/0x320 drivers/tty/serial/serial_core.c:625
Modules linked in:
CPU: 1 PID: 10514 Comm: syz-executor.2 Not tainted 6.9.0-rc6-next-20240503-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
RIP: 0010:uart_write+0x2b0/0x320 drivers/tty/serial/serial_core.c:625
Code: 74 08 48 89 df e8 10 f4 be fc 48 83 3b 00 74 74 e8 15 45 59 fc eb 97 e8 0e 45 59 fc 45 31 e4 eb 08 e8 04 45 59 fc 45 31 ed 90 <0f> 0b 90 45 84 e4 74 0a e8 f3 44 59 fc 45 31 f6 eb 84 e8 e9 44 59
RSP: 0018:ffffc900050874b8 EFLAGS: 00010046
RAX: ffffffff853cd0d2 RBX: dffffc0000000000 RCX: 0000000000040000
RDX: ffffc9000c925000 RSI: 000000000001ba30 RDI: 000000000001ba31
RBP: ffff88801fde8f48 R08: 0000000000000003 R09: fffff52000a10e74
R10: dffffc0000000000 R11: fffff52000a10e74 R12: 0000000000000000
R13: 0000000000000246 R14: ffff88801fde8be8 R15: ffffffff94ad0840
FS:  00007f7909dde6c0(0000) GS:ffff8880b9500000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00005555566ca978 CR3: 0000000044e04000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 tnc_init drivers/net/hamradio/6pack.c:531 [inline]
 sixpack_open+0x790/0xa80 drivers/net/hamradio/6pack.c:628
 tty_ldisc_open drivers/tty/tty_ldisc.c:432 [inline]
 tty_ldisc_reinit+0x2d4/0x4a0 drivers/tty/tty_ldisc.c:661
 tty_reopen+0x20b/0x2d0 drivers/tty/tty_io.c:1366
 tty_open_by_driver drivers/tty/tty_io.c:2082 [inline]
 tty_open+0xa26/0xdf0 drivers/tty/tty_io.c:2135
 chrdev_open+0x5b0/0x630 fs/char_dev.c:414
 do_dentry_open+0x95a/0x1720 fs/open.c:955
 do_open fs/namei.c:3650 [inline]
 path_openat+0x289f/0x3280 fs/namei.c:3807
 do_filp_open+0x235/0x490 fs/namei.c:3834
 do_sys_openat2+0x13e/0x1d0 fs/open.c:1405
 do_sys_open fs/open.c:1420 [inline]
 __do_sys_openat fs/open.c:1436 [inline]
 __se_sys_openat fs/open.c:1431 [inline]
 __x64_sys_openat+0x247/0x2a0 fs/open.c:1431
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f790a27dca9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f7909dde0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007f790a3ac050 RCX: 00007f790a27dca9
RDX: 0000000000000000 RSI: 0000000020000240 RDI: ffffffffffffff9c
RBP: 00007f790a2c947e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000006e R14: 00007f790a3ac050 R15: 00007ffc2522d128
 </TASK>

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/05/04 21:27 linux-next 9221b2819b8a 610f2a54 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in uart_write
2024/04/21 03:55 linux-next 7b4f2bc91c15 af24b050 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in uart_write
* Struck through repros no longer work on HEAD.