possible deadlock in n_tty_flush_buffer

Status: upstream: reported on 2026/08/04 21:19
Reported-by: syzbot+b2cc229a584bebf6d9cb@syzkaller.appspotmail.com
First crash: 1d15h, last: 1d10h
Similar bugs (3)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in n_tty_flush_buffer serial 4 syz, C error inconclusive 71 1d12h 561d 0/29 upstream: reported C repro on 2025/01/22 11:21
linux-5.15 possible deadlock in n_tty_flush_buffer 4 2 1d17h 1d17h 0/3 upstream: reported on 2026/08/04 19:36
linux-6.1 possible deadlock in n_tty_flush_buffer 4 syz, C 16 21h03m 1d16h 0/3 upstream: reported C repro on 2026/08/04 20:24

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
kworker/0:1/9 is trying to acquire lock:
ffff8880790722e8 (&tty->termios_rwsem){++++}-{3:3}, at: n_tty_flush_buffer+0x30/0x230 drivers/tty/n_tty.c:363

but task is already holding lock:
ffff8880186510b8 (&buf->lock){+.+.}-{3:3}, at: tty_buffer_flush+0x79/0x3e0 drivers/tty/tty_buffer.c:229

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&buf->lock){+.+.}-{3:3}:
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x135/0xc80 kernel/locking/mutex.c:747
       tty_buffer_flush+0x79/0x3e0 drivers/tty/tty_buffer.c:229
       tty_ldisc_flush+0x6b/0xc0 drivers/tty/tty_ldisc.c:388
       __do_SAK+0x25b/0x680 drivers/tty/tty_io.c:3014
       vc_SAK+0x78/0x220 drivers/tty/vt/vt_ioctl.c:995
       process_one_work kernel/workqueue.c:2657 [inline]
       process_scheduled_works+0xa60/0x1600 kernel/workqueue.c:2734
       worker_thread+0xa5e/0xfe0 kernel/workqueue.c:2815
       kthread+0x2fa/0x390 kernel/kthread.c:388
       ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:152
       ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:293

-> #2 (console_lock){+.+.}-{0:0}:
       console_lock+0x164/0x1b0 kernel/printk/printk.c:2686
       uart_configure_port drivers/tty/serial/serial_core.c:2632 [inline]
       serial_core_add_one_port drivers/tty/serial/serial_core.c:3199 [inline]
       serial_core_register_port+0xbee/0x20b0 drivers/tty/serial/serial_core.c:3422
       serial8250_register_8250_port+0x15fd/0x1f40 drivers/tty/serial/8250/8250_core.c:1142
       serial_pnp_probe+0x577/0x750 drivers/tty/serial/8250/8250_pnp.c:478
       pnp_device_probe+0x305/0x4b0 drivers/pnp/driver.c:111
       call_driver_probe drivers/base/dd.c:-1 [inline]
       really_probe+0x247/0xae0 drivers/base/dd.c:717
       __driver_probe_device+0x1f5/0x390 drivers/base/dd.c:879
       driver_probe_device+0x4f/0x420 drivers/base/dd.c:909
       __driver_attach+0x444/0x6d0 drivers/base/dd.c:1295
       bus_for_each_dev+0x235/0x2b0 drivers/base/bus.c:370
       bus_add_driver+0x340/0x630 drivers/base/bus.c:723
       driver_register+0x23a/0x310 drivers/base/driver.c:246
       serial8250_init+0x9a/0x170 drivers/tty/serial/8250/8250_core.c:1243
       do_one_initcall+0x242/0x790 init/main.c:1210
       do_initcall_level+0x13d/0x1f0 init/main.c:1272
       do_initcalls+0x69/0xd0 init/main.c:1288
       kernel_init_freeable+0x3d9/0x560 init/main.c:1525
       kernel_init+0x1d/0x1c0 init/main.c:1415
       ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:152
       ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:293

-> #1 (&port->mutex){+.+.}-{3:3}:
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x135/0xc80 kernel/locking/mutex.c:747
       uart_set_termios+0x84/0x900 drivers/tty/serial/serial_core.c:1703
       tty_set_termios+0xcb1/0x17e0 drivers/tty/tty_ioctl.c:354
       set_termios+0x52b/0x6c0 drivers/tty/tty_ioctl.c:528
       tty_mode_ioctl+0x49f/0x7b0 drivers/tty/tty_ioctl.c:-1
       tty_ioctl+0x9b5/0xdc0 drivers/tty/tty_io.c:2788
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:871 [inline]
       __se_sys_ioctl+0xfd/0x170 fs/ioctl.c:857
       do_syscall_x64 arch/x86/entry/common.c:46 [inline]
       do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:76
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #0 (&tty->termios_rwsem){++++}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3134 [inline]
       check_prevs_add kernel/locking/lockdep.c:3253 [inline]
       validate_chain kernel/locking/lockdep.c:3869 [inline]
       __lock_acquire+0x37ef/0x7d80 kernel/locking/lockdep.c:5137
       lock_acquire+0x19e/0x420 kernel/locking/lockdep.c:5754
       down_write+0x97/0x200 kernel/locking/rwsem.c:1573
       n_tty_flush_buffer+0x30/0x230 drivers/tty/n_tty.c:363
       tty_buffer_flush+0x31e/0x3e0 drivers/tty/tty_buffer.c:241
       tty_ldisc_flush+0x6b/0xc0 drivers/tty/tty_ldisc.c:388
       __do_SAK+0x25b/0x680 drivers/tty/tty_io.c:3014
       vc_SAK+0x78/0x220 drivers/tty/vt/vt_ioctl.c:995
       process_one_work kernel/workqueue.c:2657 [inline]
       process_scheduled_works+0xa60/0x1600 kernel/workqueue.c:2734
       worker_thread+0xa5e/0xfe0 kernel/workqueue.c:2815
       kthread+0x2fa/0x390 kernel/kthread.c:388
       ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:152
       ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:293

other info that might help us debug this:

Chain exists of:
  &tty->termios_rwsem --> console_lock --> &buf->lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&buf->lock);
                               lock(console_lock);
                               lock(&buf->lock);
  lock(&tty->termios_rwsem);

 *** DEADLOCK ***

5 locks held by kworker/0:1/9:
 #0: ffff888017c70938 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:2632 [inline]
 #0: ffff888017c70938 ((wq_completion)events){+.+.}-{0:0}, at: process_scheduled_works+0x975/0x1600 kernel/workqueue.c:2734
 #1: ffffc900000e7d00 ((work_completion)(&vc_cons[currcons].SAK_work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:2632 [inline]
 #1: ffffc900000e7d00 ((work_completion)(&vc_cons[currcons].SAK_work)){+.+.}-{0:0}, at: process_scheduled_works+0x975/0x1600 kernel/workqueue.c:2734
 #2: ffffffff8d126180 (console_lock){+.+.}-{0:0}, at: vc_SAK+0x28/0x220 drivers/tty/vt/vt_ioctl.c:985
 #3: ffff8880790720a0 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref drivers/tty/tty_ldisc.c:263 [inline]
 #3: ffff8880790720a0 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_flush+0x20/0xc0 drivers/tty/tty_ldisc.c:386
 #4: ffff8880186510b8 (&buf->lock){+.+.}-{3:3}, at: tty_buffer_flush+0x79/0x3e0 drivers/tty/tty_buffer.c:229

stack backtrace:
CPU: 0 PID: 9 Comm: kworker/0:1 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
Workqueue: events vc_SAK
Call Trace:
 <TASK>
 dump_stack_lvl+0x18c/0x250 lib/dump_stack.c:106
 check_noncircular+0x2fc/0x400 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 kernel/locking/lockdep.c:3869 [inline]
 __lock_acquire+0x37ef/0x7d80 kernel/locking/lockdep.c:5137
 lock_acquire+0x19e/0x420 kernel/locking/lockdep.c:5754
 down_write+0x97/0x200 kernel/locking/rwsem.c:1573
 n_tty_flush_buffer+0x30/0x230 drivers/tty/n_tty.c:363
 tty_buffer_flush+0x31e/0x3e0 drivers/tty/tty_buffer.c:241
 tty_ldisc_flush+0x6b/0xc0 drivers/tty/tty_ldisc.c:388
 __do_SAK+0x25b/0x680 drivers/tty/tty_io.c:3014
 vc_SAK+0x78/0x220 drivers/tty/vt/vt_ioctl.c:995
 process_one_work kernel/workqueue.c:2657 [inline]
 process_scheduled_works+0xa60/0x1600 kernel/workqueue.c:2734
 worker_thread+0xa5e/0xfe0 kernel/workqueue.c:2815
 kthread+0x2fa/0x390 kernel/kthread.c:388
 ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:152
 ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:293
 </TASK>
tty tty1: SAK: killed process 6964 (syz.5.111): by fd#3
tty tty1: SAK: killed process 6965 (syz.5.111): by fd#3
tty tty1: SAK: killed process 6967 (syz.5.111): by fd#3

Crashes (7):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/08/05 02:44 linux-6.6.y aa0e49877a2e d4abbeac .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan possible deadlock in n_tty_flush_buffer
2026/08/05 02:43 linux-6.6.y aa0e49877a2e d4abbeac .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan possible deadlock in n_tty_flush_buffer
2026/08/05 00:52 linux-6.6.y aa0e49877a2e d4abbeac .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan possible deadlock in n_tty_flush_buffer
2026/08/05 00:51 linux-6.6.y aa0e49877a2e d4abbeac .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan possible deadlock in n_tty_flush_buffer
2026/08/04 21:45 linux-6.6.y aa0e49877a2e d4abbeac .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan possible deadlock in n_tty_flush_buffer
2026/08/04 21:20 linux-6.6.y aa0e49877a2e d4abbeac .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan possible deadlock in n_tty_flush_buffer
2026/08/04 21:19 linux-6.6.y aa0e49877a2e d4abbeac .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan possible deadlock in n_tty_flush_buffer
* Struck through repros no longer work on HEAD.