program: r0 = syz_open_dev$tty1(0xc, 0x4, 0x1) ioctl$TIOCSETD(r0, 0x5423, &(0x7f0000000000)=0x2) ioctl$KDSKBENT(r0, 0x4b47, &(0x7f0000000040)={0x0, 0x1c, 0x20f}) r1 = openat$uinput(0xffffffffffffff9c, &(0x7f0000000080), 0x2, 0x0) ioctl$UI_SET_EVBIT(r1, 0x40045564, 0x1) ioctl$UI_SET_KEYBIT(r1, 0x40045565, 0x1c) ioctl$UI_DEV_SETUP(r1, 0x405c5503, &(0x7f0000000100)={{}, 'syz0\x00'}) ioctl$UI_DEV_CREATE(r1, 0x5501) write$input_event(r1, &(0x7f0000000200)={{}, 0x1, 0x1c, 0x1}, 0x18) write$input_event(r1, &(0x7f0000000240), 0x18) [ 77.224099][ T5320] input: syz0 as /devices/virtual/input/input5 [ 77.244625][ T5284] Bluetooth: hci0: command tx timeout [ 77.250421][ T1331] ieee802154 phy0 wpan0: encryption failed: -22 [ 77.253110][ T1331] ieee802154 phy1 wpan1: encryption failed: -22 [ 77.338226][ T5308] [ 77.338239][ T5308] ====================================================== [ 77.338246][ T5308] WARNING: possible circular locking dependency detected [ 77.338252][ T5308] syzkaller #0 Not tainted [ 77.338258][ T5308] ------------------------------------------------------ [ 77.338282][ T5308] kworker/0:5/5308 is trying to acquire lock: [ 77.338291][ T5308] ffff8880125ac2c8 (&tty->termios_rwsem){++++}-{4:4}, at: n_tty_flush_buffer+0x30/0x230 [ 77.339688][ T5308] [ 77.339688][ T5308] but task is already holding lock: [ 77.339693][ T5308] ffff88801b0ba0b8 (&buf->lock){+.+.}-{4:4}, at: tty_buffer_flush+0x74/0x2b0 [ 77.339734][ T5308] [ 77.339734][ T5308] which lock already depends on the new lock. [ 77.339734][ T5308] [ 77.339738][ T5308] [ 77.339738][ T5308] the existing dependency chain (in reverse order) is: [ 77.339743][ T5308] [ 77.339743][ T5308] -> #3 (&buf->lock){+.+.}-{4:4}: [ 77.339761][ T5308] __mutex_lock+0x19d/0x1550 [ 77.339809][ T5308] tty_buffer_flush+0x74/0x2b0 [ 77.339824][ T5308] tty_ldisc_flush+0x6b/0xc0 [ 77.339837][ T5308] __do_SAK+0x25e/0x680 [ 77.339846][ T5308] vc_SAK+0x78/0x220 [ 77.339859][ T5308] process_scheduled_works+0xa8e/0x14e0 [ 77.339872][ T5308] worker_thread+0xa47/0xfb0 [ 77.339884][ T5308] kthread+0x388/0x470 [ 77.339899][ T5308] ret_from_fork+0x514/0xb70 [ 77.339916][ T5308] ret_from_fork_asm+0x1a/0x30 [ 77.339926][ T5308] [ 77.339926][ T5308] -> #2 (console_lock){+.+.}-{0:0}: [ 77.339942][ T5308] console_lock+0x76/0x90 [ 77.339953][ T5308] serial_core_register_port+0xc47/0x2840 [ 77.339967][ T5308] serial8250_register_8250_port+0x16b4/0x2090 [ 77.339981][ T5308] serial_pnp_probe+0x56a/0x7f0 [ 77.339994][ T5308] pnp_device_probe+0x30b/0x4c0 [ 77.340008][ T5308] really_probe+0x254/0xae0 [ 77.340020][ T5308] __driver_probe_device+0x1e8/0x360 [ 77.340031][ T5308] driver_probe_device+0x4f/0x240 [ 77.340043][ T5308] __driver_attach+0x339/0x600 [ 77.340054][ T5308] bus_for_each_dev+0x23b/0x2c0 [ 77.340068][ T5308] bus_add_driver+0x345/0x670 [ 77.340083][ T5308] driver_register+0x23a/0x320 [ 77.340095][ T5308] serial8250_init+0x8f/0x160 [ 77.340169][ T5308] do_one_initcall+0x250/0x870 [ 77.340185][ T5308] do_initcall_level+0x10a/0x1a0 [ 77.340199][ T5308] do_initcalls+0x59/0xa0 [ 77.340210][ T5308] kernel_init_freeable+0x29d/0x3e0 [ 77.340223][ T5308] kernel_init+0x1d/0x1d0 [ 77.340238][ T5308] ret_from_fork+0x514/0xb70 [ 77.340282][ T5308] ret_from_fork_asm+0x1a/0x30 [ 77.340293][ T5308] [ 77.340293][ T5308] -> #1 (&port->mutex){+.+.}-{4:4}: [ 77.340316][ T5308] __mutex_lock+0x19d/0x1550 [ 77.340333][ T5308] uart_set_termios+0x83/0x12e0 [ 77.340349][ T5308] tty_set_termios+0xcaf/0x1800 [ 77.340363][ T5308] set_termios+0x53d/0x6c0 [ 77.340377][ T5308] tty_mode_ioctl+0x49c/0x7c0 [ 77.340389][ T5308] tty_ioctl+0x9bd/0xdd0 [ 77.340404][ T5308] __se_sys_ioctl+0xfc/0x170 [ 77.340419][ T5308] do_syscall_64+0x174/0x580 [ 77.340431][ T5308] entry_SYSCALL_64_after_hwframe+0x77/0x7f [ 77.340442][ T5308] [ 77.340442][ T5308] -> #0 (&tty->termios_rwsem){++++}-{4:4}: [ 77.340460][ T5308] __lock_acquire+0x1520/0x2cf0 [ 77.340481][ T5308] lock_acquire+0x106/0x350 [ 77.340496][ T5308] down_write+0x96/0x200 [ 77.340510][ T5308] n_tty_flush_buffer+0x30/0x230 [ 77.340521][ T5308] tty_buffer_flush+0x1ec/0x2b0 [ 77.340536][ T5308] tty_ldisc_flush+0x6b/0xc0 [ 77.340550][ T5308] __do_SAK+0x25e/0x680 [ 77.340564][ T5308] vc_SAK+0x78/0x220 [ 77.340580][ T5308] process_scheduled_works+0xa8e/0x14e0 [ 77.340593][ T5308] worker_thread+0xa47/0xfb0 [ 77.340605][ T5308] kthread+0x388/0x470 [ 77.340619][ T5308] ret_from_fork+0x514/0xb70 [ 77.340633][ T5308] ret_from_fork_asm+0x1a/0x30 [ 77.340644][ T5308] [ 77.340644][ T5308] other info that might help us debug this: [ 77.340644][ T5308] [ 77.340648][ T5308] Chain exists of: [ 77.340648][ T5308] &tty->termios_rwsem --> console_lock --> &buf->lock [ 77.340648][ T5308] [ 77.340666][ T5308] Possible unsafe locking scenario: [ 77.340666][ T5308] [ 77.340669][ T5308] CPU0 CPU1 [ 77.340673][ T5308] ---- ---- [ 77.340676][ T5308] lock(&buf->lock); [ 77.340685][ T5308] lock(console_lock); [ 77.340695][ T5308] lock(&buf->lock); [ 77.340702][ T5308] lock(&tty->termios_rwsem); [ 77.340716][ T5308] [ 77.340716][ T5308] *** DEADLOCK *** [ 77.340716][ T5308] [ 77.340719][ T5308] 5 locks held by kworker/0:5/5308: [ 77.340726][ T5308] #0: ffff88801b0a8940 ((wq_completion)events){+.+.}-{0:0}, at: process_scheduled_works+0xa20/0x14e0 [ 77.340753][ T5308] #1: ffffc9000e237c40 ((work_completion)(&vc_cons[currcons].SAK_work)){+.+.}-{0:0}, at: process_scheduled_works+0xa20/0x14e0 [ 77.340780][ T5308] #2: ffffffff8eb4bfa0 (console_lock){+.+.}-{0:0}, at: vc_SAK+0x28/0x220 [ 77.340808][ T5308] #3: ffff8880125ac0a0 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_flush+0x20/0xc0 [ 77.340840][ T5308] #4: ffff88801b0ba0b8 (&buf->lock){+.+.}-{4:4}, at: tty_buffer_flush+0x74/0x2b0 [ 77.340874][ T5308] [ 77.340874][ T5308] stack backtrace: [ 77.340880][ T5308] CPU: 0 UID: 0 PID: 5308 Comm: kworker/0:5 Not tainted syzkaller #0 PREEMPT(full) [ 77.340893][ T5308] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 [ 77.340901][ T5308] Workqueue: events vc_SAK [ 77.340914][ T5308] Call Trace: [ 77.340921][ T5308] [ 77.340926][ T5308] dump_stack_lvl+0xe8/0x150 [ 77.340941][ T5308] print_circular_bug+0x2e1/0x300 [ 77.340955][ T5308] check_noncircular+0x12e/0x150 [ 77.340967][ T5308] __lock_acquire+0x1520/0x2cf0 [ 77.340983][ T5308] ? __pfx___mutex_trylock_common+0x10/0x10 [ 77.340995][ T5308] ? rcu_is_watching+0x15/0xb0 [ 77.341005][ T5308] ? trace_contention_end+0x3d/0x140 [ 77.341019][ T5308] ? n_tty_flush_buffer+0x30/0x230 [ 77.341029][ T5308] lock_acquire+0x106/0x350 [ 77.341043][ T5308] ? n_tty_flush_buffer+0x30/0x230 [ 77.341057][ T5308] down_write+0x96/0x200 [ 77.341070][ T5308] ? n_tty_flush_buffer+0x30/0x230 [ 77.341081][ T5308] ? __pfx_down_write+0x10/0x10 [ 77.341096][ T5308] ? __pfx_n_tty_flush_buffer+0x10/0x10 [ 77.341108][ T5308] n_tty_flush_buffer+0x30/0x230 [ 77.341120][ T5308] ? tty_buffer_flush+0x1df/0x2b0 [ 77.341136][ T5308] ? __pfx_n_tty_flush_buffer+0x10/0x10 [ 77.341148][ T5308] tty_buffer_flush+0x1ec/0x2b0 [ 77.341165][ T5308] tty_ldisc_flush+0x6b/0xc0 [ 77.341182][ T5308] __do_SAK+0x25e/0x680 [ 77.341192][ T5308] ? _raw_spin_unlock_irqrestore+0x30/0x80 [ 77.341206][ T5308] vc_SAK+0x78/0x220 [ 77.341219][ T5308] ? process_scheduled_works+0xa20/0x14e0 [ 77.341231][ T5308] process_scheduled_works+0xa8e/0x14e0 [ 77.341251][ T5308] ? __pfx_process_scheduled_works+0x10/0x10 [ 77.341266][ T5308] ? assign_work+0x3cf/0x5d0 [ 77.341280][ T5308] worker_thread+0xa47/0xfb0 [ 77.341297][ T5308] ? __kthread_parkme+0x71/0x1f0 [ 77.341313][ T5308] kthread+0x388/0x470 [ 77.341329][ T5308] ? __pfx_worker_thread+0x10/0x10 [ 77.341342][ T5308] ? __pfx_kthread+0x10/0x10 [ 77.341359][ T5308] ret_from_fork+0x514/0xb70 [ 77.341377][ T5308] ? __pfx_ret_from_fork+0x10/0x10 [ 77.341393][ T5308] ? __switch_to+0xc89/0x1420 [ 77.341408][ T5308] ? __pfx_kthread+0x10/0x10 [ 77.341424][ T5308] ret_from_fork_asm+0x1a/0x30 [ 77.341439][ T5308]