====================================================== WARNING: possible circular locking dependency detected 5.7.0-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.0/10968 is trying to acquire lock: ffffffff899b2680 (console_owner){-.-.}-{0:0}, at: console_trylock_spinning kernel/printk/printk.c:1763 [inline] ffffffff899b2680 (console_owner){-.-.}-{0:0}, at: vprintk_emit+0x425/0x730 kernel/printk/printk.c:2031 but task is already holding lock: ffffffff8d1d94b8 (&port->lock#2){-.-.}-{2:2}, at: tty_port_close_start.part.0+0x28/0x550 drivers/tty/tty_port.c:567 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (&port->lock#2){-.-.}-{2:2}: __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x8c/0xbf kernel/locking/spinlock.c:159 tty_port_tty_get+0x1f/0x100 drivers/tty/tty_port.c:288 tty_port_default_wakeup+0x11/0x40 drivers/tty/tty_port.c:47 serial8250_tx_chars+0x48f/0xa60 drivers/tty/serial/8250/8250_port.c:1828 serial8250_handle_irq.part.0+0x328/0x3d0 drivers/tty/serial/8250/8250_port.c:1915 serial8250_handle_irq drivers/tty/serial/8250/8250_port.c:1888 [inline] serial8250_default_handle_irq+0xb5/0x140 drivers/tty/serial/8250/8250_port.c:1931 serial8250_interrupt+0xe6/0x190 drivers/tty/serial/8250/8250_core.c:126 __handle_irq_event_percpu+0x22e/0xa50 kernel/irq/handle.c:156 handle_irq_event_percpu+0x76/0x160 kernel/irq/handle.c:196 handle_irq_event+0xa2/0x12d kernel/irq/handle.c:213 handle_edge_irq+0x24b/0x8c0 kernel/irq/chip.c:830 generic_handle_irq_desc include/linux/irqdesc.h:156 [inline] do_IRQ+0xd5/0x270 arch/x86/kernel/irq.c:250 ret_from_intr+0x0/0x2b arch_local_irq_restore arch/x86/include/asm/paravirt.h:765 [inline] __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:160 [inline] _raw_spin_unlock_irqrestore+0x8c/0xe0 kernel/locking/spinlock.c:191 spin_unlock_irqrestore include/linux/spinlock.h:408 [inline] uart_write+0x3a7/0x6f0 drivers/tty/serial/serial_core.c:616 do_output_char+0x5dd/0x850 drivers/tty/n_tty.c:447 process_output drivers/tty/n_tty.c:514 [inline] n_tty_write+0x49e/0xf90 drivers/tty/n_tty.c:2345 do_tty_write drivers/tty/tty_io.c:962 [inline] tty_write+0x495/0x800 drivers/tty/tty_io.c:1046 redirected_tty_write+0xaa/0xb0 drivers/tty/tty_io.c:1067 do_loop_readv_writev fs/read_write.c:718 [inline] do_loop_readv_writev fs/read_write.c:702 [inline] do_iter_write fs/read_write.c:1001 [inline] do_iter_write+0x486/0x600 fs/read_write.c:980 vfs_writev+0x1b3/0x2f0 fs/read_write.c:1072 do_writev+0x139/0x300 fs/read_write.c:1115 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295 entry_SYSCALL_64_after_hwframe+0x49/0xb3 -> #1 (&port->lock){-.-.}-{2:2}: __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x8c/0xbf kernel/locking/spinlock.c:159 serial8250_console_write+0x20d/0xb00 drivers/tty/serial/8250/8250_port.c:3240 call_console_drivers kernel/printk/printk.c:1827 [inline] console_unlock+0xac7/0xf00 kernel/printk/printk.c:2515 vprintk_emit+0x2c4/0x730 kernel/printk/printk.c:2032 vprintk_func+0x8f/0x1a6 kernel/printk/printk_safe.c:386 printk+0xba/0xed kernel/printk/printk.c:2092 register_console kernel/printk/printk.c:2868 [inline] register_console+0x55f/0x7e0 kernel/printk/printk.c:2747 univ8250_console_init+0x3a/0x46 drivers/tty/serial/8250/8250_core.c:690 console_init+0x43f/0x646 kernel/printk/printk.c:2968 start_kernel+0x76e/0x9fb init/main.c:969 secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:242 -> #0 (console_owner){-.-.}-{0:0}: check_prev_add kernel/locking/lockdep.c:2496 [inline] check_prevs_add kernel/locking/lockdep.c:2601 [inline] validate_chain kernel/locking/lockdep.c:3218 [inline] __lock_acquire+0x2a9a/0x48a0 kernel/locking/lockdep.c:4380 lock_acquire+0x1f2/0x8f0 kernel/locking/lockdep.c:4959 console_trylock_spinning kernel/printk/printk.c:1784 [inline] vprintk_emit+0x462/0x730 kernel/printk/printk.c:2031 vprintk_func+0x8f/0x1a6 kernel/printk/printk_safe.c:386 printk+0xba/0xed kernel/printk/printk.c:2092 tty_port_close_start.part.0+0x4f7/0x550 drivers/tty/tty_port.c:569 tty_port_close_start drivers/tty/tty_port.c:641 [inline] tty_port_close+0x46/0xf0 drivers/tty/tty_port.c:634 tty_release+0x3b9/0xe90 drivers/tty/tty_io.c:1679 __fput+0x33e/0x880 fs/file_table.c:281 task_work_run+0xf4/0x1b0 kernel/task_work.c:123 tracehook_notify_resume include/linux/tracehook.h:188 [inline] exit_to_usermode_loop+0x2fa/0x360 arch/x86/entry/common.c:165 prepare_exit_to_usermode arch/x86/entry/common.c:196 [inline] syscall_return_slowpath arch/x86/entry/common.c:279 [inline] do_syscall_64+0x6b1/0x7d0 arch/x86/entry/common.c:305 entry_SYSCALL_64_after_hwframe+0x49/0xb3 other info that might help us debug this: Chain exists of: console_owner --> &port->lock --> &port->lock#2 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&port->lock#2); lock(&port->lock); lock(&port->lock#2); lock(console_owner); *** DEADLOCK *** 2 locks held by syz-executor.0/10968: #0: ffff8880940c81c0 (&tty->legacy_mutex){+.+.}-{3:3}, at: tty_lock+0xbd/0x120 drivers/tty/tty_mutex.c:19 #1: ffffffff8d1d94b8 (&port->lock#2){-.-.}-{2:2}, at: tty_port_close_start.part.0+0x28/0x550 drivers/tty/tty_port.c:567 stack backtrace: CPU: 0 PID: 10968 Comm: syz-executor.0 Not tainted 5.7.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x188/0x20d lib/dump_stack.c:118 check_noncircular+0x32e/0x3e0 kernel/locking/lockdep.c:1827 check_prev_add kernel/locking/lockdep.c:2496 [inline] check_prevs_add kernel/locking/lockdep.c:2601 [inline] validate_chain kernel/locking/lockdep.c:3218 [inline] __lock_acquire+0x2a9a/0x48a0 kernel/locking/lockdep.c:4380 lock_acquire+0x1f2/0x8f0 kernel/locking/lockdep.c:4959 console_trylock_spinning kernel/printk/printk.c:1784 [inline] vprintk_emit+0x462/0x730 kernel/printk/printk.c:2031 vprintk_func+0x8f/0x1a6 kernel/printk/printk_safe.c:386 printk+0xba/0xed kernel/printk/printk.c:2092 tty_port_close_start.part.0+0x4f7/0x550 drivers/tty/tty_port.c:569 tty_port_close_start drivers/tty/tty_port.c:641 [inline] tty_port_close+0x46/0xf0 drivers/tty/tty_port.c:634 tty_release+0x3b9/0xe90 drivers/tty/tty_io.c:1679 __fput+0x33e/0x880 fs/file_table.c:281 task_work_run+0xf4/0x1b0 kernel/task_work.c:123 tracehook_notify_resume include/linux/tracehook.h:188 [inline] exit_to_usermode_loop+0x2fa/0x360 arch/x86/entry/common.c:165 prepare_exit_to_usermode arch/x86/entry/common.c:196 [inline] syscall_return_slowpath arch/x86/entry/common.c:279 [inline] do_syscall_64+0x6b1/0x7d0 arch/x86/entry/common.c:305 entry_SYSCALL_64_after_hwframe+0x49/0xb3 RIP: 0033:0x416651 Code: 75 14 b8 03 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 04 1b 00 00 c3 48 83 ec 08 e8 0a fc ff ff 48 89 04 24 b8 03 00 00 00 0f 05 <48> 8b 3c 24 48 89 c2 e8 53 fc ff ff 48 89 d0 48 83 c4 08 48 3d 01 RSP: 002b:00007fff161d7b90 EFLAGS: 00000293 ORIG_RAX: 0000000000000003 RAX: 0000000000000000 RBX: 0000000000000004 RCX: 0000000000416651 RDX: 00000000000f4240 RSI: 0000000000000081 RDI: 0000000000000003 RBP: 0000000000000000 R08: 0000000000790148 R09: 0000000000000000 R10: 00007fff161d7c70 R11: 0000000000000293 R12: 0000000000790150 R13: 0000000000000000 R14: ffffffffffffffff R15: 000000000078bf0c