====================================================== WARNING: possible circular locking dependency detected 5.12.0-rc6-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.4/27949 is trying to acquire lock: ffffffff8c704c60 (console_owner){-...}-{0:0}, at: console_trylock_spinning+0x10e/0x2f0 kernel/printk/printk.c:1788 but task is already holding lock: ffff88801aaf9158 (&port->lock){-.-.}-{2:2}, at: pty_write+0xb6/0x170 drivers/tty/pty.c:119 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (&port->lock){-.-.}-{2:2}: lock_acquire+0x126/0x650 kernel/locking/lockdep.c:5510 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x73/0xa0 kernel/locking/spinlock.c:159 tty_port_tty_get+0x21/0xe0 drivers/tty/tty_port.c:288 tty_port_default_wakeup+0x11/0x40 drivers/tty/tty_port.c:47 serial8250_tx_chars+0x5ea/0x800 drivers/tty/serial/8250/8250_port.c:1832 serial8250_handle_irq+0x2fd/0x3e0 drivers/tty/serial/8250/8250_port.c:1919 serial8250_default_handle_irq+0xaf/0x190 drivers/tty/serial/8250/8250_port.c:1935 serial8250_interrupt+0xa3/0x1e0 drivers/tty/serial/8250/8250_core.c:126 __handle_irq_event_percpu+0x1b7/0x620 kernel/irq/handle.c:156 handle_irq_event_percpu kernel/irq/handle.c:196 [inline] handle_irq_event+0xbd/0x280 kernel/irq/handle.c:213 handle_edge_irq+0x245/0xbe0 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+0xce/0x1e0 arch/x86/kernel/irq.c:250 common_interrupt+0x9c/0xc0 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+0x7a/0xc0 kernel/locking/spinlock.c:191 spin_unlock_irqrestore include/linux/spinlock.h:409 [inline] uart_write+0x6a1/0x8f0 drivers/tty/serial/serial_core.c:615 do_output_char+0x638/0x940 drivers/tty/n_tty.c:443 process_output drivers/tty/n_tty.c:510 [inline] n_tty_write+0xd5c/0x1180 drivers/tty/n_tty.c:2365 do_tty_write drivers/tty/tty_io.c:1043 [inline] file_tty_write+0x5c5/0x9a0 drivers/tty/tty_io.c:1133 do_iter_readv_writev+0x48c/0x650 include/linux/fs.h:1971 do_iter_write+0x16c/0x5f0 fs/read_write.c:866 vfs_writev fs/read_write.c:939 [inline] do_writev+0x19a/0x350 fs/read_write.c:982 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xae -> #1 (&port_lock_key){-.-.}-{2:2}: lock_acquire+0x126/0x650 kernel/locking/lockdep.c:5510 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x73/0xa0 kernel/locking/spinlock.c:159 serial8250_console_write+0x107/0xd20 drivers/tty/serial/8250/8250_port.c:3292 call_console_drivers kernel/printk/printk.c:1858 [inline] console_unlock+0x930/0xe00 kernel/printk/printk.c:2576 vprintk_emit+0x1ab/0x270 kernel/printk/printk.c:2098 printk+0x62/0x83 kernel/printk/printk.c:2146 register_console+0x802/0xad0 kernel/printk/printk.c:2927 univ8250_console_init+0x41/0x43 drivers/tty/serial/8250/8250_core.c:690 console_init+0x52/0x97 kernel/printk/printk.c:3027 start_kernel+0x30c/0x544 init/main.c:993 secondary_startup_64_no_verify+0xb0/0xbb -> #0 (console_owner){-...}-{0:0}: check_prev_add kernel/locking/lockdep.c:2936 [inline] check_prevs_add+0x339/0x5c20 kernel/locking/lockdep.c:3059 validate_chain kernel/locking/lockdep.c:3674 [inline] __lock_acquire+0x41f7/0x5e60 kernel/locking/lockdep.c:4900 lock_acquire+0x126/0x650 kernel/locking/lockdep.c:5510 console_trylock_spinning+0x12e/0x2f0 kernel/printk/printk.c:1805 vprintk_emit+0x192/0x270 kernel/printk/printk.c:2097 printk+0x62/0x83 kernel/printk/printk.c:2146 fail_dump lib/fault-inject.c:45 [inline] should_fail+0x366/0x4b0 lib/fault-inject.c:146 should_failslab+0x5/0x20 mm/slab_common.c:1273 slab_pre_alloc_hook mm/slab.h:499 [inline] slab_alloc_node mm/slub.c:2826 [inline] slab_alloc mm/slub.c:2915 [inline] __kmalloc+0x89/0x380 mm/slub.c:4051 kmalloc include/linux/slab.h:559 [inline] tty_buffer_alloc drivers/tty/tty_buffer.c:175 [inline] __tty_buffer_request_room+0x1f0/0x540 drivers/tty/tty_buffer.c:273 tty_insert_flip_string_fixed_flag+0x92/0x2c0 drivers/tty/tty_buffer.c:318 tty_insert_flip_string include/linux/tty_flip.h:37 [inline] pty_write+0xda/0x170 drivers/tty/pty.c:121 tty_put_char+0xc7/0x110 drivers/tty/tty_io.c:3182 __process_echoes+0x1a9/0x930 drivers/tty/n_tty.c:742 flush_echoes drivers/tty/n_tty.c:825 [inline] __receive_buf drivers/tty/n_tty.c:1644 [inline] n_tty_receive_buf_common+0x2a1a/0x3120 drivers/tty/n_tty.c:1739 tiocsti drivers/tty/tty_io.c:2316 [inline] tty_ioctl+0xc64/0x15f0 drivers/tty/tty_io.c:2717 vfs_ioctl fs/ioctl.c:48 [inline] __do_sys_ioctl fs/ioctl.c:753 [inline] __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:739 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 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 *** 4 locks held by syz-executor.4/27949: #0: ffff888079ad0098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref_wait+0x21/0x70 drivers/tty/tty_ldisc.c:266 #1: ffff888079ad02e8 (&o_tty->termios_rwsem/1){++++}-{3:3}, at: n_tty_receive_buf_common+0x88/0x3120 drivers/tty/n_tty.c:1702 #2: ffffc90001538378 (&ldata->output_lock){+.+.}-{3:3}, at: flush_echoes drivers/tty/n_tty.c:823 [inline] #2: ffffc90001538378 (&ldata->output_lock){+.+.}-{3:3}, at: __receive_buf drivers/tty/n_tty.c:1644 [inline] #2: ffffc90001538378 (&ldata->output_lock){+.+.}-{3:3}, at: n_tty_receive_buf_common+0x29db/0x3120 drivers/tty/n_tty.c:1739 #3: ffff88801aaf9158 (&port->lock){-.-.}-{2:2}, at: pty_write+0xb6/0x170 drivers/tty/pty.c:119 stack backtrace: CPU: 1 PID: 27949 Comm: syz-executor.4 Not tainted 5.12.0-rc6-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+0x176/0x24e lib/dump_stack.c:120 print_circular_bug+0xadf/0xd80 kernel/locking/lockdep.c:2005 check_noncircular+0x221/0x2d0 kernel/locking/lockdep.c:2127 check_prev_add kernel/locking/lockdep.c:2936 [inline] check_prevs_add+0x339/0x5c20 kernel/locking/lockdep.c:3059 validate_chain kernel/locking/lockdep.c:3674 [inline] __lock_acquire+0x41f7/0x5e60 kernel/locking/lockdep.c:4900 lock_acquire+0x126/0x650 kernel/locking/lockdep.c:5510 console_trylock_spinning+0x12e/0x2f0 kernel/printk/printk.c:1805 vprintk_emit+0x192/0x270 kernel/printk/printk.c:2097 printk+0x62/0x83 kernel/printk/printk.c:2146 fail_dump lib/fault-inject.c:45 [inline] should_fail+0x366/0x4b0 lib/fault-inject.c:146 should_failslab+0x5/0x20 mm/slab_common.c:1273 slab_pre_alloc_hook mm/slab.h:499 [inline] slab_alloc_node mm/slub.c:2826 [inline] slab_alloc mm/slub.c:2915 [inline] __kmalloc+0x89/0x380 mm/slub.c:4051 kmalloc include/linux/slab.h:559 [inline] tty_buffer_alloc drivers/tty/tty_buffer.c:175 [inline] __tty_buffer_request_room+0x1f0/0x540 drivers/tty/tty_buffer.c:273 tty_insert_flip_string_fixed_flag+0x92/0x2c0 drivers/tty/tty_buffer.c:318 tty_insert_flip_string include/linux/tty_flip.h:37 [inline] pty_write+0xda/0x170 drivers/tty/pty.c:121 tty_put_char+0xc7/0x110 drivers/tty/tty_io.c:3182 __process_echoes+0x1a9/0x930 drivers/tty/n_tty.c:742 flush_echoes drivers/tty/n_tty.c:825 [inline] __receive_buf drivers/tty/n_tty.c:1644 [inline] n_tty_receive_buf_common+0x2a1a/0x3120 drivers/tty/n_tty.c:1739 tiocsti drivers/tty/tty_io.c:2316 [inline] tty_ioctl+0xc64/0x15f0 drivers/tty/tty_io.c:2717 vfs_ioctl fs/ioctl.c:48 [inline] __do_sys_ioctl fs/ioctl.c:753 [inline] __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:739 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x466459 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fac16330188 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 000000000056bf60 RCX: 0000000000466459 RDX: 0000000020000100 RSI: 0000000000005412 RDI: 0000000000000004 RBP: 00007fac163301d0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001 R13: 00007ffdf649c16f R14: 00007fac16330300 R15: 0000000000022000