====================================================== WARNING: possible circular locking dependency detected 5.9.0-rc8-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor015/9424 is trying to acquire lock: ffffffff8a05ac60 (console_owner){-.-.}-{0:0}, at: log_next kernel/printk/printk.c:528 [inline] ffffffff8a05ac60 (console_owner){-.-.}-{0:0}, at: console_unlock+0x439/0xe60 kernel/printk/printk.c:2488 but task is already holding lock: ffffffff8df62618 (&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+0x94/0xce 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:1832 serial8250_handle_irq.part.0+0x328/0x3d0 drivers/tty/serial/8250/8250_port.c:1919 serial8250_handle_irq drivers/tty/serial/8250/8250_port.c:1892 [inline] serial8250_default_handle_irq+0xb2/0x220 drivers/tty/serial/8250/8250_port.c:1935 serial8250_interrupt+0xe6/0x190 drivers/tty/serial/8250/8250_core.c:126 __handle_irq_event_percpu+0x223/0xaa0 kernel/irq/handle.c:156 handle_irq_event_percpu kernel/irq/handle.c:196 [inline] handle_irq_event+0x102/0x285 kernel/irq/handle.c:213 handle_edge_irq+0x25f/0xd00 kernel/irq/chip.c:819 asm_call_irq_on_stack+0xf/0x20 __run_irq_on_irqstack arch/x86/include/asm/irq_stack.h:48 [inline] run_irq_on_irqstack_cond arch/x86/include/asm/irq_stack.h:101 [inline] handle_irq arch/x86/kernel/irq.c:230 [inline] __common_interrupt arch/x86/kernel/irq.c:249 [inline] common_interrupt+0x115/0x1f0 arch/x86/kernel/irq.c:239 asm_common_interrupt+0x1e/0x40 arch/x86/include/asm/idtentry.h:572 arch_local_irq_restore arch/x86/include/asm/paravirt.h:770 [inline] __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:160 [inline] _raw_spin_unlock_irqrestore+0x4d/0x90 kernel/locking/spinlock.c:191 spin_unlock_irqrestore include/linux/spinlock.h:409 [inline] uart_write+0x30d/0x56a drivers/tty/serial/serial_core.c:615 do_output_char+0x5de/0x850 drivers/tty/n_tty.c:447 process_output drivers/tty/n_tty.c:514 [inline] n_tty_write+0x481/0xf80 drivers/tty/n_tty.c:2345 do_tty_write drivers/tty/tty_io.c:962 [inline] tty_write+0x4d9/0x870 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:745 [inline] do_loop_readv_writev fs/read_write.c:729 [inline] do_iter_write+0x489/0x670 fs/read_write.c:1028 vfs_writev+0x1aa/0x2e0 fs/read_write.c:1099 do_writev+0x139/0x300 fs/read_write.c:1142 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 -> #1 (&port_lock_key){-.-.}-{2:2}: __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x94/0xce kernel/locking/spinlock.c:159 serial8250_console_write+0x200/0xb30 drivers/tty/serial/8250/8250_port.c:3289 call_console_drivers kernel/printk/printk.c:1824 [inline] console_unlock+0xadb/0xe60 kernel/printk/printk.c:2501 vprintk_emit+0x2ff/0x740 kernel/printk/printk.c:2029 vprintk_func+0x8d/0x1d4 kernel/printk/printk_safe.c:393 printk+0xba/0xed kernel/printk/printk.c:2078 register_console kernel/printk/printk.c:2854 [inline] register_console+0x55f/0x830 kernel/printk/printk.c:2733 univ8250_console_init+0x3a/0x46 drivers/tty/serial/8250/8250_core.c:690 console_init+0x421/0x619 kernel/printk/printk.c:2954 start_kernel+0x31c/0x4b1 init/main.c:976 secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:243 -> #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+0x2a96/0x5780 kernel/locking/lockdep.c:4441 lock_acquire+0x1f3/0xaf0 kernel/locking/lockdep.c:5029 console_lock_spinning_enable kernel/printk/printk.c:1690 [inline] console_unlock+0x4a1/0xe60 kernel/printk/printk.c:2498 vprintk_emit+0x2ff/0x740 kernel/printk/printk.c:2029 vprintk_func+0x8d/0x1d4 kernel/printk/printk_safe.c:393 printk+0xba/0xed kernel/printk/printk.c:2078 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+0x455/0xf60 drivers/tty/tty_io.c:1679 __fput+0x285/0x920 fs/file_table.c:281 task_work_run+0xdd/0x190 kernel/task_work.c:141 exit_task_work include/linux/task_work.h:25 [inline] do_exit+0xb7d/0x29f0 kernel/exit.c:806 do_group_exit+0x125/0x310 kernel/exit.c:903 get_signal+0x428/0x1f00 kernel/signal.c:2757 arch_do_signal+0x82/0x2520 arch/x86/kernel/signal.c:811 exit_to_user_mode_loop kernel/entry/common.c:161 [inline] exit_to_user_mode_prepare+0x1ae/0x200 kernel/entry/common.c:192 syscall_exit_to_user_mode+0x7e/0x2e0 kernel/entry/common.c:267 entry_SYSCALL_64_after_hwframe+0x44/0xa9 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-executor015/9424: #0: ffff8880a90621c0 (&tty->legacy_mutex){+.+.}-{3:3}, at: tty_lock+0xbd/0x120 drivers/tty/tty_mutex.c:19 #1: ffffffff8df62618 (&port->lock){-.-.}-{2:2}, at: tty_port_close_start.part.0+0x28/0x550 drivers/tty/tty_port.c:567 #2: ffffffff8a05aee0 (console_lock){+.+.}-{0:0}, at: vprintk_func+0x8d/0x1d4 kernel/printk/printk_safe.c:393 stack backtrace: CPU: 0 PID: 9424 Comm: syz-executor015 Not tainted 5.9.0-rc8-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+0x198/0x1fd lib/dump_stack.c:118 check_noncircular+0x324/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+0x2a96/0x5780 kernel/locking/lockdep.c:4441 lock_acquire+0x1f3/0xaf0 kernel/locking/lockdep.c:5029 console_lock_spinning_enable kernel/printk/printk.c:1690 [inline] console_unlock+0x4a1/0xe60 kernel/printk/printk.c:2498 vprintk_emit+0x2ff/0x740 kernel/printk/printk.c:2029 vprintk_func+0x8d/0x1d4 kernel/printk/printk_safe.c:393 printk+0xba/0xed kernel/printk/printk.c:2078 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+0x455/0xf60 drivers/tty/tty_io.c:1679 __fput+0x285/0x920 fs/file_table.c:281 task_work_run+0xdd/0x190 kernel/task_work.c:141 exit_task_work include/linux/task_work.h:25 [inline] do_exit+0xb7d/0x29f0 kernel/exit.c:806 do_group_exit+0x125/0x310 kernel/exit.c:903 get_signal+0x428/0x1f00 kernel/signal.c:2757 arch_do_signal+0x82/0x2520 arch/x86/kernel/signal.c:811 exit_to_user_mode_loop kernel/entry/common.c:161 [inline] exit_to_user_mode_prepare+0x1ae/0x200 kernel/entry/common.c:192 syscall_exit_to_user_mode+0x7e/0x2e0 kernel/entry/common.c:267 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x446e59 Code: Bad RIP value. RSP: 002b:00007fc228691cf8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca RAX: fffffffffffffe00 RBX: 00000000006dcc28 RCX: 0000000000446e59 RDX: 0000000000000000 RSI: 0000000000000080 RDI: 00000000006dcc28 RBP: 00000000006dcc20 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dcc2c R13: 00007ffdc98bd00f R14: 00007fc2286929c0 R15: 20c49ba5e353f7cf