====================================================== WARNING: possible circular locking dependency detected 5.12.0-rc7-next-20210415-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.0/10525 is trying to acquire lock: ffffffff8be851c0 (console_owner){....}-{0:0}, at: console_unlock+0x2e6/0xc40 kernel/printk/printk.c:2619 but task is already holding lock: ffffffff90608278 (&port->lock){-.-.}-{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}: __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x39/0x50 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+0x487/0xa80 drivers/tty/serial/8250/8250_port.c:1826 serial8250_handle_irq.part.0+0x328/0x3d0 drivers/tty/serial/8250/8250_port.c:1913 serial8250_handle_irq drivers/tty/serial/8250/8250_port.c:1886 [inline] serial8250_default_handle_irq+0xb2/0x220 drivers/tty/serial/8250/8250_port.c:1929 serial8250_interrupt+0xfd/0x200 drivers/tty/serial/8250/8250_core.c:126 __handle_irq_event_percpu+0x303/0x8f0 kernel/irq/handle.c:156 handle_irq_event_percpu kernel/irq/handle.c:196 [inline] handle_irq_event+0x102/0x290 kernel/irq/handle.c:213 handle_edge_irq+0x25f/0xd00 kernel/irq/chip.c:819 generic_handle_irq_desc include/linux/irqdesc.h:158 [inline] handle_irq arch/x86/kernel/irq.c:231 [inline] __common_interrupt+0x9d/0x210 arch/x86/kernel/irq.c:250 common_interrupt+0x9f/0xd0 arch/x86/kernel/irq.c:240 asm_common_interrupt+0x1e/0x40 arch/x86/include/asm/idtentry.h:623 __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:161 [inline] _raw_spin_unlock_irqrestore+0x38/0x70 kernel/locking/spinlock.c:191 spin_unlock_irqrestore include/linux/spinlock.h:414 [inline] uart_write+0x30d/0x570 drivers/tty/serial/serial_core.c:615 do_output_char+0x5de/0x850 drivers/tty/n_tty.c:443 process_output drivers/tty/n_tty.c:510 [inline] n_tty_write+0x4c3/0xfd0 drivers/tty/n_tty.c:2365 do_tty_write drivers/tty/tty_io.c:1043 [inline] file_tty_write.constprop.0+0x526/0x910 drivers/tty/tty_io.c:1133 redirected_tty_write+0xa1/0xc0 drivers/tty/tty_io.c:1140 call_write_iter include/linux/fs.h:2114 [inline] do_iter_readv_writev+0x46f/0x740 fs/read_write.c:740 do_iter_write+0x188/0x670 fs/read_write.c:866 vfs_writev+0x1aa/0x630 fs/read_write.c:939 do_writev+0x139/0x300 fs/read_write.c:982 do_syscall_64+0x3a/0xb0 arch/x86/entry/common.c:47 entry_SYSCALL_64_after_hwframe+0x44/0xae -> #1 (&port_lock_key){-.-.}-{2:2}: __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x39/0x50 kernel/locking/spinlock.c:159 serial8250_console_write+0x8b2/0xae0 drivers/tty/serial/8250/8250_port.c:3286 call_console_drivers kernel/printk/printk.c:1938 [inline] console_unlock+0x859/0xc40 kernel/printk/printk.c:2643 vprintk_emit+0x1ca/0x560 kernel/printk/printk.c:2174 vprintk+0x8d/0x260 kernel/printk/printk_safe.c:392 printk+0xba/0xed kernel/printk/printk.c:2216 register_console kernel/printk/printk.c:2991 [inline] register_console+0x55f/0x780 kernel/printk/printk.c:2870 univ8250_console_init+0x3a/0x46 drivers/tty/serial/8250/8250_core.c:690 console_init+0x3c7/0x596 kernel/printk/printk.c:3091 start_kernel+0x30b/0x49b init/main.c:1018 secondary_startup_64_no_verify+0xb0/0xbb -> #0 (console_owner){....}-{0:0}: check_prev_add kernel/locking/lockdep.c:2938 [inline] check_prevs_add kernel/locking/lockdep.c:3061 [inline] validate_chain kernel/locking/lockdep.c:3676 [inline] __lock_acquire+0x2a17/0x5230 kernel/locking/lockdep.c:4902 lock_acquire kernel/locking/lockdep.c:5512 [inline] lock_acquire+0x1ab/0x740 kernel/locking/lockdep.c:5477 console_lock_spinning_enable kernel/printk/printk.c:1790 [inline] console_unlock+0x359/0xc40 kernel/printk/printk.c:2640 vprintk_emit+0x1ca/0x560 kernel/printk/printk.c:2174 vprintk+0x8d/0x260 kernel/printk/printk_safe.c:392 printk+0xba/0xed kernel/printk/printk.c:2216 tty_port_close_start.part.0+0x503/0x550 drivers/tty/tty_port.c:569 tty_port_close_start drivers/tty/tty_port.c:641 [inline] tty_port_close+0x46/0x170 drivers/tty/tty_port.c:634 tty_release+0x45e/0x1210 drivers/tty/tty_io.c:1778 __fput+0x288/0x920 fs/file_table.c:280 task_work_run+0xdd/0x1a0 kernel/task_work.c:164 tracehook_notify_resume include/linux/tracehook.h:189 [inline] exit_to_user_mode_loop kernel/entry/common.c:174 [inline] exit_to_user_mode_prepare+0x272/0x280 kernel/entry/common.c:208 __syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline] syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:301 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:57 entry_SYSCALL_64_after_hwframe+0x44/0xae other info that might help us debug this: Chain exists of: console_owner --> &port_lock_key --> &port->lock Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&port->lock); lock(&port_lock_key); lock(&port->lock); lock(console_owner); *** DEADLOCK *** 3 locks held by syz-executor.0/10525: #0: ffff888019ba81c0 (&tty->legacy_mutex){+.+.}-{3:3}, at: tty_lock+0xbd/0x120 drivers/tty/tty_mutex.c:19 #1: ffffffff90608278 (&port->lock){-.-.}-{2:2}, at: tty_port_close_start.part.0+0x28/0x550 drivers/tty/tty_port.c:567 #2: ffffffff8bf655a0 (console_lock){+.+.}-{0:0}, at: vprintk+0x8d/0x260 kernel/printk/printk_safe.c:392 stack backtrace: CPU: 1 PID: 10525 Comm: syz-executor.0 Not tainted 5.12.0-rc7-next-20210415-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:79 [inline] dump_stack+0x141/0x1d7 lib/dump_stack.c:120 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2129 check_prev_add kernel/locking/lockdep.c:2938 [inline] check_prevs_add kernel/locking/lockdep.c:3061 [inline] validate_chain kernel/locking/lockdep.c:3676 [inline] __lock_acquire+0x2a17/0x5230 kernel/locking/lockdep.c:4902 lock_acquire kernel/locking/lockdep.c:5512 [inline] lock_acquire+0x1ab/0x740 kernel/locking/lockdep.c:5477 console_lock_spinning_enable kernel/printk/printk.c:1790 [inline] console_unlock+0x359/0xc40 kernel/printk/printk.c:2640 vprintk_emit+0x1ca/0x560 kernel/printk/printk.c:2174 vprintk+0x8d/0x260 kernel/printk/printk_safe.c:392 printk+0xba/0xed kernel/printk/printk.c:2216 tty_port_close_start.part.0+0x503/0x550 drivers/tty/tty_port.c:569 tty_port_close_start drivers/tty/tty_port.c:641 [inline] tty_port_close+0x46/0x170 drivers/tty/tty_port.c:634 tty_release+0x45e/0x1210 drivers/tty/tty_io.c:1778 __fput+0x288/0x920 fs/file_table.c:280 task_work_run+0xdd/0x1a0 kernel/task_work.c:164 tracehook_notify_resume include/linux/tracehook.h:189 [inline] exit_to_user_mode_loop kernel/entry/common.c:174 [inline] exit_to_user_mode_prepare+0x272/0x280 kernel/entry/common.c:208 __syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline] syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:301 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:57 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x41926b Code: 0f 05 48 3d 00 f0 ff ff 77 45 c3 0f 1f 40 00 48 83 ec 18 89 7c 24 0c e8 63 fc ff ff 8b 7c 24 0c 41 89 c0 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 89 44 24 0c e8 a1 fc ff ff 8b 44 RSP: 002b:00007ffe8d7f9e30 EFLAGS: 00000293 ORIG_RAX: 0000000000000003 RAX: 0000000000000000 RBX: 0000000000000006 RCX: 000000000041926b RDX: 00000000005703a8 RSI: 0000000000000001 RDI: 0000000000000005 RBP: 0000000000000001 R08: 0000000000000000 R09: 0000001b332200e0 R10: 00007ffe8d7f9f20 R11: 0000000000000293 R12: 0000000000068dd8 R13: 00000000000003e8 R14: 000000000056bf60 R15: 0000000000068dd2