keytouch 0003:0926:3333.001B: input,hidraw1: USB HID v0.00 Keyboard [HID 0926:3333] on usb-dummy_hcd.0-1/input0 ====================================================== WARNING: possible circular locking dependency detected syzkaller #0 Not tainted ------------------------------------------------------ kworker/1:3/5829 is trying to acquire lock: ffff88801bec20b8 (&buf->lock){+.+.}-{4:4}, at: tty_buffer_flush+0x72/0x310 drivers/tty/tty_buffer.c:236 but task is already holding lock: ffffffff8e7d1ae0 (console_lock){+.+.}-{0:0}, at: class_console_lock_constructor include/linux/console.h:736 [inline] ffffffff8e7d1ae0 (console_lock){+.+.}-{0:0}, at: vc_SAK+0x13/0x320 drivers/tty/vt/vt_ioctl.c:985 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (console_lock){+.+.}-{0:0}: console_lock+0x7a/0xa0 kernel/printk/printk.c:2896 class_console_lock_constructor include/linux/console.h:736 [inline] con_flush_chars+0x63/0x90 drivers/tty/vt/vt.c:3729 n_tty_write+0xc74/0x11c0 drivers/tty/n_tty.c:2382 iterate_tty_write drivers/tty/tty_io.c:1006 [inline] file_tty_write.isra.0+0x4d2/0x890 drivers/tty/tty_io.c:1081 new_sync_write fs/read_write.c:595 [inline] vfs_write+0x6ac/0x1070 fs/read_write.c:688 ksys_write+0x12a/0x250 fs/read_write.c:740 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:83 [inline] __do_fast_syscall_32+0xe7/0x950 arch/x86/entry/syscall_32.c:307 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:332 entry_SYSENTER_compat_after_hwframe+0x84/0x8e -> #1 (&tty->termios_rwsem){++++}-{4:4}: down_read+0x99/0x450 kernel/locking/rwsem.c:1568 class_rwsem_read_constructor include/linux/rwsem.h:259 [inline] n_tty_receive_buf_common+0x85/0x1950 drivers/tty/n_tty.c:1678 tty_ldisc_receive_buf+0xaa/0x1a0 drivers/tty/tty_buffer.c:394 tty_port_default_receive_buf+0x70/0xb0 drivers/tty/tty_port.c:37 receive_buf drivers/tty/tty_buffer.c:452 [inline] flush_to_ldisc+0x26b/0x730 drivers/tty/tty_buffer.c:502 process_one_work+0xa0e/0x1980 kernel/workqueue.c:3314 process_scheduled_works kernel/workqueue.c:3397 [inline] worker_thread+0x5ef/0xe50 kernel/workqueue.c:3478 kthread+0x370/0x450 kernel/kthread.c:436 ret_from_fork+0x72b/0xd50 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 -> #0 (&buf->lock){+.+.}-{4:4}: check_prev_add kernel/locking/lockdep.c:3165 [inline] check_prevs_add kernel/locking/lockdep.c:3284 [inline] validate_chain kernel/locking/lockdep.c:3908 [inline] __lock_acquire+0x14b8/0x2630 kernel/locking/lockdep.c:5237 lock_acquire kernel/locking/lockdep.c:5868 [inline] lock_acquire+0x1b1/0x370 kernel/locking/lockdep.c:5825 __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x1a4/0x1b10 kernel/locking/mutex.c:820 tty_buffer_flush+0x72/0x310 drivers/tty/tty_buffer.c:236 tty_ldisc_flush+0x68/0xf0 drivers/tty/tty_ldisc.c:388 __do_SAK+0x38f/0x4d0 drivers/tty/tty_io.c:3025 vc_SAK+0x7f/0x320 drivers/tty/vt/vt_ioctl.c:994 process_one_work+0xa0e/0x1980 kernel/workqueue.c:3314 process_scheduled_works kernel/workqueue.c:3397 [inline] worker_thread+0x5ef/0xe50 kernel/workqueue.c:3478 kthread+0x370/0x450 kernel/kthread.c:436 ret_from_fork+0x72b/0xd50 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 other info that might help us debug this: Chain exists of: &buf->lock --> &tty->termios_rwsem --> console_lock Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(console_lock); lock(&tty->termios_rwsem); lock(console_lock); lock(&buf->lock); *** DEADLOCK *** 4 locks held by kworker/1:3/5829: #0: ffff88801b8aa940 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work+0x12d6/0x1980 kernel/workqueue.c:3289 #1: ffffc9000610fd08 ((work_completion)(&vc_cons[currcons].SAK_work)){+.+.}-{0:0}, at: process_one_work+0x973/0x1980 kernel/workqueue.c:3290 #2: ffffffff8e7d1ae0 (console_lock){+.+.}-{0:0}, at: class_console_lock_constructor include/linux/console.h:736 [inline] #2: ffffffff8e7d1ae0 (console_lock){+.+.}-{0:0}, at: vc_SAK+0x13/0x320 drivers/tty/vt/vt_ioctl.c:985 #3: ffff88804b3000a0 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref drivers/tty/tty_ldisc.c:263 [inline] #3: ffff88804b3000a0 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_flush+0x1c/0xf0 drivers/tty/tty_ldisc.c:386 stack backtrace: CPU: 1 UID: 0 PID: 5829 Comm: kworker/1:3 Not tainted syzkaller #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Workqueue: events vc_SAK Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120 print_circular_bug.cold+0x178/0x1c7 kernel/locking/lockdep.c:2043 check_noncircular+0x146/0x160 kernel/locking/lockdep.c:2175 check_prev_add kernel/locking/lockdep.c:3165 [inline] check_prevs_add kernel/locking/lockdep.c:3284 [inline] validate_chain kernel/locking/lockdep.c:3908 [inline] __lock_acquire+0x14b8/0x2630 kernel/locking/lockdep.c:5237 lock_acquire kernel/locking/lockdep.c:5868 [inline] lock_acquire+0x1b1/0x370 kernel/locking/lockdep.c:5825 __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x1a4/0x1b10 kernel/locking/mutex.c:820 tty_buffer_flush+0x72/0x310 drivers/tty/tty_buffer.c:236 tty_ldisc_flush+0x68/0xf0 drivers/tty/tty_ldisc.c:388 __do_SAK+0x38f/0x4d0 drivers/tty/tty_io.c:3025 vc_SAK+0x7f/0x320 drivers/tty/vt/vt_ioctl.c:994 process_one_work+0xa0e/0x1980 kernel/workqueue.c:3314 process_scheduled_works kernel/workqueue.c:3397 [inline] worker_thread+0x5ef/0xe50 kernel/workqueue.c:3478 kthread+0x370/0x450 kernel/kthread.c:436 ret_from_fork+0x72b/0xd50 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 tty tty1: SAK: killed process 5945 (syz.3.10): by fd#5 tty tty1: SAK: killed process 5956 (syz.3.13): by fd#5 tty tty1: SAK: killed process 5968 (syz.0.15): by fd#5 tty tty1: SAK: killed process 5976 (syz.0.17): by fd#5 tty tty1: SAK: killed process 5993 (syz.0.21): by fd#5 tty tty1: SAK: killed process 6135 (syz.1.53): by fd#5