program: r0 = syz_open_dev$tty1(0xc, 0x4, 0x1) ioctl$TIOCSETD(r0, 0x5423, &(0x7f0000000000)=0x1b) r1 = syz_open_dev$tty1(0xc, 0x4, 0x1) ioctl$TIOCSETD(r1, 0x5423, &(0x7f0000000000)=0x1b) ioctl$KDSKBENT(r1, 0x4b47, &(0x7f0000000040)={0x0, 0x1c, 0x20f}) r2 = openat$uinput(0xffffffffffffff9c, &(0x7f0000000080), 0x2, 0x0) ioctl$UI_SET_EVBIT(r2, 0x40045564, 0x1) ioctl$UI_SET_KEYBIT(r2, 0x40045565, 0x1c) ioctl$UI_DEV_SETUP(r2, 0x405c5503, &(0x7f0000000100)={{}, 'syz0\x00'}) ioctl$UI_DEV_CREATE(r2, 0x5501) write$input_event(r2, &(0x7f0000000200)={{}, 0x1, 0x1c, 0x1}, 0x18) write$input_event(r2, &(0x7f0000000240), 0x18) [ 115.595820][ T5332] input: syz0 as /devices/virtual/input/input5 [ 115.632772][ T1378] [ 115.632779][ T1378] ====================================================== [ 115.632782][ T1378] WARNING: possible circular locking dependency detected [ 115.632786][ T1378] syzkaller #0 Not tainted [ 115.632790][ T1378] ------------------------------------------------------ [ 115.632793][ T1378] kworker/0:3/1378 is trying to acquire lock: [ 115.632797][ T1378] ffff88801237b2c8 (&tty->termios_rwsem){++++}-{4:4}, at: n_tty_flush_buffer+0x30/0x230 [ 115.632877][ T1378] [ 115.632877][ T1378] but task is already holding lock: [ 115.632880][ T1378] ffff88801b0ba0b8 (&buf->lock){+.+.}-{4:4}, at: tty_buffer_flush+0x74/0x2b0 [ 115.632900][ T1378] [ 115.632900][ T1378] which lock already depends on the new lock. [ 115.632900][ T1378] [ 115.632902][ T1378] [ 115.632902][ T1378] the existing dependency chain (in reverse order) is: [ 115.632905][ T1378] [ 115.632905][ T1378] -> #3 (&buf->lock){+.+.}-{4:4}: [ 115.632920][ T1378] __mutex_lock+0x19d/0x1550 [ 115.632953][ T1378] tty_buffer_flush+0x74/0x2b0 [ 115.632963][ T1378] tty_ldisc_flush+0x6b/0xc0 [ 115.632972][ T1378] __do_SAK+0x25e/0x680 [ 115.632978][ T1378] vc_SAK+0x78/0x220 [ 115.632986][ T1378] process_scheduled_works+0xa8e/0x14e0 [ 115.632994][ T1378] worker_thread+0xa47/0xfb0 [ 115.633002][ T1378] kthread+0x388/0x470 [ 115.633011][ T1378] ret_from_fork+0x514/0xb70 [ 115.633021][ T1378] ret_from_fork_asm+0x1a/0x30 [ 115.633027][ T1378] [ 115.633027][ T1378] -> #2 (console_lock){+.+.}-{0:0}: [ 115.633038][ T1378] console_lock+0x76/0x90 [ 115.633045][ T1378] serial_core_register_port+0xc47/0x2840 [ 115.633055][ T1378] serial8250_register_8250_port+0x16b4/0x2090 [ 115.633064][ T1378] serial_pnp_probe+0x56a/0x7f0 [ 115.633073][ T1378] pnp_device_probe+0x30b/0x4c0 [ 115.633099][ T1378] really_probe+0x254/0xae0 [ 115.633108][ T1378] __driver_probe_device+0x1e8/0x360 [ 115.633115][ T1378] driver_probe_device+0x4f/0x240 [ 115.633122][ T1378] __driver_attach+0x339/0x600 [ 115.633129][ T1378] bus_for_each_dev+0x23b/0x2c0 [ 115.633138][ T1378] bus_add_driver+0x345/0x670 [ 115.633147][ T1378] driver_register+0x23a/0x320 [ 115.633154][ T1378] serial8250_init+0x8f/0x160 [ 115.633208][ T1378] do_one_initcall+0x250/0x870 [ 115.633219][ T1378] do_initcall_level+0x10a/0x1a0 [ 115.633227][ T1378] do_initcalls+0x59/0xa0 [ 115.633235][ T1378] kernel_init_freeable+0x29d/0x3e0 [ 115.633243][ T1378] kernel_init+0x1d/0x1d0 [ 115.633252][ T1378] ret_from_fork+0x514/0xb70 [ 115.633262][ T1378] ret_from_fork_asm+0x1a/0x30 [ 115.633268][ T1378] [ 115.633268][ T1378] -> #1 (&port->mutex){+.+.}-{4:4}: [ 115.633278][ T1378] __mutex_lock+0x19d/0x1550 [ 115.633287][ T1378] uart_set_termios+0x83/0x12e0 [ 115.633297][ T1378] tty_set_termios+0xcaf/0x1800 [ 115.633305][ T1378] set_termios+0x53d/0x6c0 [ 115.633314][ T1378] tty_mode_ioctl+0x49c/0x7c0 [ 115.633322][ T1378] tty_ioctl+0x9bd/0xdd0 [ 115.633332][ T1378] __se_sys_ioctl+0xfc/0x170 [ 115.633342][ T1378] do_syscall_64+0x174/0x580 [ 115.633350][ T1378] entry_SYSCALL_64_after_hwframe+0x77/0x7f [ 115.633357][ T1378] [ 115.633357][ T1378] -> #0 (&tty->termios_rwsem){++++}-{4:4}: [ 115.633370][ T1378] __lock_acquire+0x1520/0x2cf0 [ 115.633384][ T1378] lock_acquire+0x106/0x350 [ 115.633397][ T1378] down_write+0x96/0x200 [ 115.633409][ T1378] n_tty_flush_buffer+0x30/0x230 [ 115.633419][ T1378] tty_buffer_flush+0x1ec/0x2b0 [ 115.633429][ T1378] tty_ldisc_flush+0x6b/0xc0 [ 115.633438][ T1378] __do_SAK+0x25e/0x680 [ 115.633443][ T1378] vc_SAK+0x78/0x220 [ 115.633451][ T1378] process_scheduled_works+0xa8e/0x14e0 [ 115.633458][ T1378] worker_thread+0xa47/0xfb0 [ 115.633466][ T1378] kthread+0x388/0x470 [ 115.633475][ T1378] ret_from_fork+0x514/0xb70 [ 115.633485][ T1378] ret_from_fork_asm+0x1a/0x30 [ 115.633490][ T1378] [ 115.633490][ T1378] other info that might help us debug this: [ 115.633490][ T1378] [ 115.633493][ T1378] Chain exists of: [ 115.633493][ T1378] &tty->termios_rwsem --> console_lock --> &buf->lock [ 115.633493][ T1378] [ 115.633505][ T1378] Possible unsafe locking scenario: [ 115.633505][ T1378] [ 115.633508][ T1378] CPU0 CPU1 [ 115.633510][ T1378] ---- ---- [ 115.633512][ T1378] lock(&buf->lock); [ 115.633517][ T1378] lock(console_lock); [ 115.633523][ T1378] lock(&buf->lock); [ 115.633528][ T1378] lock(&tty->termios_rwsem); [ 115.633533][ T1378] [ 115.633533][ T1378] *** DEADLOCK *** [ 115.633533][ T1378] [ 115.633535][ T1378] 5 locks held by kworker/0:3/1378: [ 115.633539][ T1378] #0: ffff88801b0a8940 ((wq_completion)events){+.+.}-{0:0}, at: process_scheduled_works+0xa20/0x14e0 [ 115.633558][ T1378] #1: ffffc9000288fc40 ((work_completion)(&vc_cons[currcons].SAK_work)){+.+.}-{0:0}, at: process_scheduled_works+0xa20/0x14e0 [ 115.633577][ T1378] #2: ffffffff8eb4bfa0 (console_lock){+.+.}-{0:0}, at: vc_SAK+0x28/0x220 [ 115.633595][ T1378] #3: ffff88801237b0a0 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_flush+0x20/0xc0 [ 115.633615][ T1378] #4: ffff88801b0ba0b8 (&buf->lock){+.+.}-{4:4}, at: tty_buffer_flush+0x74/0x2b0 [ 115.633636][ T1378] [ 115.633636][ T1378] stack backtrace: [ 115.633642][ T1378] CPU: 0 UID: 0 PID: 1378 Comm: kworker/0:3 Not tainted syzkaller #0 PREEMPT(full) [ 115.633654][ T1378] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 [ 115.633660][ T1378] Workqueue: events vc_SAK [ 115.633672][ T1378] Call Trace: [ 115.633676][ T1378] [ 115.633680][ T1378] dump_stack_lvl+0xe8/0x150 [ 115.633691][ T1378] print_circular_bug+0x2e1/0x300 [ 115.633698][ T1378] check_noncircular+0x12e/0x150 [ 115.633706][ T1378] __lock_acquire+0x1520/0x2cf0 [ 115.633716][ T1378] ? __pfx___mutex_trylock_common+0x10/0x10 [ 115.633724][ T1378] ? rcu_is_watching+0x15/0xb0 [ 115.633730][ T1378] ? trace_contention_end+0x3d/0x140 [ 115.633738][ T1378] ? n_tty_flush_buffer+0x30/0x230 [ 115.633745][ T1378] lock_acquire+0x106/0x350 [ 115.633754][ T1378] ? n_tty_flush_buffer+0x30/0x230 [ 115.633763][ T1378] down_write+0x96/0x200 [ 115.633772][ T1378] ? n_tty_flush_buffer+0x30/0x230 [ 115.633779][ T1378] ? __pfx_down_write+0x10/0x10 [ 115.633789][ T1378] ? __pfx_n_tty_flush_buffer+0x10/0x10 [ 115.633796][ T1378] n_tty_flush_buffer+0x30/0x230 [ 115.633804][ T1378] ? tty_buffer_flush+0x1df/0x2b0 [ 115.633814][ T1378] ? __pfx_n_tty_flush_buffer+0x10/0x10 [ 115.633822][ T1378] tty_buffer_flush+0x1ec/0x2b0 [ 115.633832][ T1378] tty_ldisc_flush+0x6b/0xc0 [ 115.633842][ T1378] __do_SAK+0x25e/0x680 [ 115.633848][ T1378] ? _raw_spin_unlock_irqrestore+0x30/0x80 [ 115.633856][ T1378] vc_SAK+0x78/0x220 [ 115.633864][ T1378] ? process_scheduled_works+0xa20/0x14e0 [ 115.633872][ T1378] process_scheduled_works+0xa8e/0x14e0 [ 115.633885][ T1378] ? __pfx_process_scheduled_works+0x10/0x10 [ 115.633898][ T1378] ? assign_work+0x3cf/0x5d0 [ 115.633910][ T1378] worker_thread+0xa47/0xfb0 [ 115.633926][ T1378] ? __kthread_parkme+0x71/0x1f0 [ 115.633936][ T1378] kthread+0x388/0x470 [ 115.633946][ T1378] ? __pfx_worker_thread+0x10/0x10 [ 115.633953][ T1378] ? __pfx_kthread+0x10/0x10 [ 115.633963][ T1378] ret_from_fork+0x514/0xb70 [ 115.633973][ T1378] ? __pfx_ret_from_fork+0x10/0x10 [ 115.633983][ T1378] ? __switch_to+0xc89/0x1420 [ 115.633992][ T1378] ? __pfx_kthread+0x10/0x10 [ 115.634002][ T1378] ret_from_fork_asm+0x1a/0x30 [ 115.634010][ T1378] [ 115.920202][ T5291] Bluetooth: hci0: command tx timeout