RBP: 00007ffd9d96c480 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000007 R13: ffffffffffffffff R14: 0000000000000000 R15: 0000000000000000 ====================================================== WARNING: possible circular locking dependency detected 4.19.0+ #90 Not tainted ------------------------------------------------------ syz-executor922/5855 is trying to acquire lock: 00000000ae98dff4 (console_owner){-.-.}, at: console_trylock_spinning kernel/printk/printk.c:1662 [inline] 00000000ae98dff4 (console_owner){-.-.}, at: vprintk_emit+0x57f/0x990 kernel/printk/printk.c:1922 but task is already holding lock: 00000000c548ed67 (&(&port->lock)->rlock){-.-.}, at: pty_write+0xf9/0x1f0 drivers/tty/pty.c:120 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (&(&port->lock)->rlock){-.-.}: __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x99/0xd0 kernel/locking/spinlock.c:152 tty_port_tty_get+0x20/0x80 drivers/tty/tty_port.c:287 tty_port_default_wakeup+0x15/0x40 drivers/tty/tty_port.c:47 tty_port_tty_wakeup+0x5d/0x70 drivers/tty/tty_port.c:387 uart_write_wakeup+0x44/0x60 drivers/tty/serial/serial_core.c:103 serial8250_tx_chars+0x4be/0xb60 drivers/tty/serial/8250/8250_port.c:1825 serial8250_handle_irq.part.23+0x1ee/0x280 drivers/tty/serial/8250/8250_port.c:1898 serial8250_handle_irq drivers/tty/serial/8250/8250_port.c:1884 [inline] serial8250_default_handle_irq+0xc8/0x150 drivers/tty/serial/8250/8250_port.c:1914 serial8250_interrupt+0xef/0x190 drivers/tty/serial/8250/8250_core.c:125 __handle_irq_event_percpu+0x195/0xb30 kernel/irq/handle.c:149 handle_irq_event_percpu+0xa0/0x1d0 kernel/irq/handle.c:189 handle_irq_event+0xa7/0x135 kernel/irq/handle.c:206 handle_edge_irq+0x227/0x880 kernel/irq/chip.c:791 generic_handle_irq_desc include/linux/irqdesc.h:154 [inline] handle_irq+0x252/0x3d8 arch/x86/kernel/irq_64.c:78 do_IRQ+0x98/0x1c0 arch/x86/kernel/irq.c:246 ret_from_intr+0x0/0x1e arch_local_irq_restore arch/x86/include/asm/paravirt.h:761 [inline] __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:160 [inline] _raw_spin_unlock_irqrestore+0xaf/0xd0 kernel/locking/spinlock.c:184 spin_unlock_irqrestore include/linux/spinlock.h:384 [inline] uart_write+0x4b2/0x740 drivers/tty/serial/serial_core.c:598 process_output_block drivers/tty/n_tty.c:593 [inline] n_tty_write+0x6c1/0x11a0 drivers/tty/n_tty.c:2331 do_tty_write drivers/tty/tty_io.c:959 [inline] tty_write+0x3f1/0x880 drivers/tty/tty_io.c:1043 redirected_tty_write+0xaf/0xc0 drivers/tty/tty_io.c:1064 __vfs_write+0x119/0x9f0 fs/read_write.c:485 vfs_write+0x1fc/0x560 fs/read_write.c:549 ksys_write+0x101/0x260 fs/read_write.c:598 __do_sys_write fs/read_write.c:610 [inline] __se_sys_write fs/read_write.c:607 [inline] __x64_sys_write+0x73/0xb0 fs/read_write.c:607 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe -> #1 (&port_lock_key){-.-.}: __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x99/0xd0 kernel/locking/spinlock.c:152 serial8250_console_write+0x8e8/0xb10 drivers/tty/serial/8250/8250_port.c:3266 univ8250_console_write+0x5f/0x70 drivers/tty/serial/8250/8250_core.c:586 call_console_drivers kernel/printk/printk.c:1729 [inline] console_unlock+0xb1f/0x1190 kernel/printk/printk.c:2415 vprintk_emit+0x391/0x990 kernel/printk/printk.c:1923 vprintk_default+0x28/0x30 kernel/printk/printk.c:1965 vprintk_func+0x7e/0x181 kernel/printk/printk_safe.c:398 printk+0xa7/0xcf kernel/printk/printk.c:1998 register_console+0x8df/0xcf0 kernel/printk/printk.c:2730 univ8250_console_init+0x3f/0x4b drivers/tty/serial/8250/8250_core.c:681 console_init+0x6ac/0x9dc kernel/printk/printk.c:2816 start_kernel+0x73a/0xa5a init/main.c:666 x86_64_start_reservations+0x2e/0x30 arch/x86/kernel/head64.c:472 x86_64_start_kernel+0x76/0x79 arch/x86/kernel/head64.c:451 secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:243 -> #0 (console_owner){-.-.}: lock_acquire+0x1ed/0x520 kernel/locking/lockdep.c:3844 console_trylock_spinning kernel/printk/printk.c:1683 [inline] vprintk_emit+0x5db/0x990 kernel/printk/printk.c:1922 vprintk_default+0x28/0x30 kernel/printk/printk.c:1965 vprintk_func+0x7e/0x181 kernel/printk/printk_safe.c:398 printk+0xa7/0xcf kernel/printk/printk.c:1998 fail_dump lib/fault-inject.c:44 [inline] should_fail+0xac1/0xd01 lib/fault-inject.c:149 __should_failslab+0x124/0x180 mm/failslab.c:32 should_failslab+0x9/0x14 mm/slab_common.c:1578 slab_pre_alloc_hook mm/slab.h:423 [inline] slab_alloc mm/slab.c:3378 [inline] __do_kmalloc mm/slab.c:3720 [inline] __kmalloc+0x70/0x760 mm/slab.c:3731 kmalloc include/linux/slab.h:551 [inline] tty_buffer_alloc drivers/tty/tty_buffer.c:175 [inline] __tty_buffer_request_room+0x2da/0x810 drivers/tty/tty_buffer.c:273 tty_insert_flip_string_fixed_flag+0x88/0x1f0 drivers/tty/tty_buffer.c:318 tty_insert_flip_string include/linux/tty_flip.h:37 [inline] pty_write+0x12c/0x1f0 drivers/tty/pty.c:122 tty_put_char+0x137/0x160 drivers/tty/tty_io.c:3013 __process_echoes+0x456/0x9b0 drivers/tty/n_tty.c:726 flush_echoes drivers/tty/n_tty.c:827 [inline] __receive_buf drivers/tty/n_tty.c:1646 [inline] n_tty_receive_buf_common+0x11bf/0x2cb0 drivers/tty/n_tty.c:1740 n_tty_receive_buf+0x30/0x40 drivers/tty/n_tty.c:1769 tiocsti drivers/tty/tty_io.c:2177 [inline] tty_ioctl+0x7cc/0x17d0 drivers/tty/tty_io.c:2553 vfs_ioctl fs/ioctl.c:46 [inline] file_ioctl fs/ioctl.c:501 [inline] do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685 ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702 __do_sys_ioctl fs/ioctl.c:709 [inline] __se_sys_ioctl fs/ioctl.c:707 [inline] __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe other info that might help us debug this: Chain exists of: console_owner --> &port_lock_key --> &(&port->lock)->rlock Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&(&port->lock)->rlock); lock(&port_lock_key); lock(&(&port->lock)->rlock); lock(console_owner); *** DEADLOCK *** 4 locks held by syz-executor922/5855: #0: 00000000679b9cce (&tty->ldisc_sem){++++}, at: ldsem_down_read+0x32/0x40 drivers/tty/tty_ldsem.c:353 #1: 0000000083ed5d81 (&o_tty->termios_rwsem/1){++++}, at: n_tty_receive_buf_common+0xeb/0x2cb0 drivers/tty/n_tty.c:1703 #2: 00000000ec53077d (&ldata->output_lock){+.+.}, at: flush_echoes drivers/tty/n_tty.c:825 [inline] #2: 00000000ec53077d (&ldata->output_lock){+.+.}, at: __receive_buf drivers/tty/n_tty.c:1646 [inline] #2: 00000000ec53077d (&ldata->output_lock){+.+.}, at: n_tty_receive_buf_common+0x1187/0x2cb0 drivers/tty/n_tty.c:1740 #3: 00000000c548ed67 (&(&port->lock)->rlock){-.-.}, at: pty_write+0xf9/0x1f0 drivers/tty/pty.c:120 stack backtrace: CPU: 1 PID: 5855 Comm: syz-executor922 Not tainted 4.19.0+ #90 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+0x244/0x39d lib/dump_stack.c:113 print_circular_bug.isra.35.cold.54+0x1bd/0x27d kernel/locking/lockdep.c:1221 check_prev_add kernel/locking/lockdep.c:1863 [inline] check_prevs_add kernel/locking/lockdep.c:1976 [inline] validate_chain kernel/locking/lockdep.c:2347 [inline] __lock_acquire+0x3399/0x4c20 kernel/locking/lockdep.c:3341 lock_acquire+0x1ed/0x520 kernel/locking/lockdep.c:3844 console_trylock_spinning kernel/printk/printk.c:1683 [inline] vprintk_emit+0x5db/0x990 kernel/printk/printk.c:1922 vprintk_default+0x28/0x30 kernel/printk/printk.c:1965 vprintk_func+0x7e/0x181 kernel/printk/printk_safe.c:398 printk+0xa7/0xcf kernel/printk/printk.c:1998 fail_dump lib/fault-inject.c:44 [inline] should_fail+0xac1/0xd01 lib/fault-inject.c:149 __should_failslab+0x124/0x180 mm/failslab.c:32 should_failslab+0x9/0x14 mm/slab_common.c:1578 slab_pre_alloc_hook mm/slab.h:423 [inline] slab_alloc mm/slab.c:3378 [inline] __do_kmalloc mm/slab.c:3720 [inline] __kmalloc+0x70/0x760 mm/slab.c:3731 kmalloc include/linux/slab.h:551 [inline] tty_buffer_alloc drivers/tty/tty_buffer.c:175 [inline] __tty_buffer_request_room+0x2da/0x810 drivers/tty/tty_buffer.c:273 tty_insert_flip_string_fixed_flag+0x88/0x1f0 drivers/tty/tty_buffer.c:318 tty_insert_flip_string include/linux/tty_flip.h:37 [inline] pty_write+0x12c/0x1f0 drivers/tty/pty.c:122 tty_put_char+0x137/0x160 drivers/tty/tty_io.c:3013 __process_echoes+0x456/0x9b0 drivers/tty/n_tty.c:726 flush_echoes drivers/tty/n_tty.c:827 [inline] __receive_buf drivers/tty/n_tty.c:1646 [inline] n_tty_receive_buf_common+0x11bf/0x2cb0 drivers/tty/n_tty.c:1740 n_tty_receive_buf+0x30/0x40 drivers/tty/n_tty.c:1769 tiocsti drivers/tty/tty_io.c:2177 [inline] tty_ioctl+0x7cc/0x17d0 drivers/tty/tty_io.c:2553 vfs_ioctl fs/ioctl.c:46 [inline] file_ioctl fs/ioctl.c:501 [inline] do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685 ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702 __do_sys_ioctl fs/ioctl.c:709 [inline] __se_sys_ioctl fs/ioctl.c:707 [inline] __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x440589 Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 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 0f 83 3