====================================================== WARNING: possible circular locking dependency detected 5.1.0+ #1 Not tainted ------------------------------------------------------ syz-executor.2/8250 is trying to acquire lock: 00000000b9ca21df (console_owner){-.-.}, at: log_next kernel/printk/printk.c:495 [inline] 00000000b9ca21df (console_owner){-.-.}, at: console_unlock+0x354/0xb80 kernel/printk/printk.c:2439 but task is already holding lock: 0000000044920d21 (&(&port->lock)->rlock){-.-.}, at: pty_write+0xbf/0x200 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:159 tty_port_tty_get+0x1b/0x70 drivers/tty/tty_port.c:287 tty_port_default_wakeup+0xa/0x30 drivers/tty/tty_port.c:47 tty_port_tty_wakeup+0x53/0x70 drivers/tty/tty_port.c:387 uart_write_wakeup+0x37/0x50 drivers/tty/serial/serial_core.c:103 serial8250_tx_chars+0x3dc/0x9d0 drivers/tty/serial/8250/8250_port.c:1806 serial8250_handle_irq.part.23+0x13e/0x230 drivers/tty/serial/8250/8250_port.c:1879 serial8250_handle_irq drivers/tty/serial/8250/8250_port.c:1865 [inline] serial8250_default_handle_irq+0x7c/0xe0 drivers/tty/serial/8250/8250_port.c:1895 serial8250_interrupt+0xcc/0x150 drivers/tty/serial/8250/8250_core.c:125 __handle_irq_event_percpu+0x100/0x660 kernel/irq/handle.c:149 handle_irq_event_percpu+0x6c/0x140 kernel/irq/handle.c:189 handle_irq_event+0xa2/0x130 kernel/irq/handle.c:206 handle_edge_irq+0x206/0x780 kernel/irq/chip.c:822 generic_handle_irq_desc include/linux/irqdesc.h:156 [inline] handle_irq+0x37/0x50 arch/x86/kernel/irq_64.c:34 do_IRQ+0x98/0x1c0 arch/x86/kernel/irq.c:246 ret_from_intr+0x0/0x1e native_safe_halt+0x6/0x10 arch/x86/include/asm/irqflags.h:57 arch_safe_halt arch/x86/include/asm/paravirt.h:156 [inline] default_idle+0x51/0x310 arch/x86/kernel/process.c:580 arch_cpu_idle+0xa/0x10 arch/x86/kernel/process.c:571 default_idle_call+0x6d/0x90 kernel/sched/idle.c:93 cpuidle_idle_call kernel/sched/idle.c:153 [inline] do_idle+0x3e4/0x590 kernel/sched/idle.c:262 cpu_startup_entry+0x18/0x20 kernel/sched/idle.c:353 start_secondary+0x367/0x4b0 arch/x86/kernel/smpboot.c:267 secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:243 -> #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:159 serial8250_console_write+0x1f0/0x800 drivers/tty/serial/8250/8250_port.c:3245 univ8250_console_write+0x4e/0x70 drivers/tty/serial/8250/8250_core.c:586 call_console_drivers kernel/printk/printk.c:1774 [inline] console_unlock+0x824/0xb80 kernel/printk/printk.c:2452 vprintk_emit+0x191/0x540 kernel/printk/printk.c:1975 vprintk_default+0x1a/0x20 kernel/printk/printk.c:2002 vprintk_func+0x49/0x12c kernel/printk/printk_safe.c:398 printk+0x9a/0xc0 kernel/printk/printk.c:2035 register_console+0x593/0x930 kernel/printk/printk.c:2767 univ8250_console_init+0x1e/0x28 drivers/tty/serial/8250/8250_core.c:681 console_init+0x317/0x481 kernel/printk/printk.c:2853 start_kernel+0x496/0x6f8 init/main.c:687 x86_64_start_reservations+0x29/0x2b arch/x86/kernel/head64.c:470 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+0x173/0x3d0 kernel/locking/lockdep.c:4302 console_lock_spinning_enable kernel/printk/printk.c:1637 [inline] console_unlock+0x3b6/0xb80 kernel/printk/printk.c:2449 vprintk_emit+0x191/0x540 kernel/printk/printk.c:1975 vprintk_default+0x1a/0x20 kernel/printk/printk.c:2002 vprintk_func+0x49/0x12c kernel/printk/printk_safe.c:398 printk+0x9a/0xc0 kernel/printk/printk.c:2035 fail_dump lib/fault-inject.c:44 [inline] should_fail+0x551/0x68a lib/fault-inject.c:143 __should_fail_alloc_page mm/page_alloc.c:3237 [inline] should_fail_alloc_page+0x50/0x60 mm/page_alloc.c:3274 prepare_alloc_pages mm/page_alloc.c:4557 [inline] __alloc_pages_nodemask+0x17f/0x850 mm/page_alloc.c:4604 __alloc_pages include/linux/gfp.h:473 [inline] __alloc_pages_node include/linux/gfp.h:486 [inline] kmem_getpages mm/slab.c:1398 [inline] cache_grow_begin+0x92/0x850 mm/slab.c:2636 cache_alloc_refill mm/slab.c:3009 [inline] ____cache_alloc mm/slab.c:3092 [inline] __do_cache_alloc mm/slab.c:3314 [inline] slab_alloc mm/slab.c:3349 [inline] __do_kmalloc mm/slab.c:3689 [inline] __kmalloc+0x69e/0x760 mm/slab.c:3700 kmalloc include/linux/slab.h:552 [inline] tty_buffer_alloc drivers/tty/tty_buffer.c:175 [inline] __tty_buffer_request_room+0x1b3/0x550 drivers/tty/tty_buffer.c:273 tty_insert_flip_string_fixed_flag+0x77/0x1a0 drivers/tty/tty_buffer.c:318 tty_insert_flip_string include/linux/tty_flip.h:37 [inline] pty_write+0xf3/0x200 drivers/tty/pty.c:122 tty_put_char+0x105/0x130 drivers/tty/tty_io.c:3031 __process_echoes+0x157/0x790 drivers/tty/n_tty.c:746 flush_echoes drivers/tty/n_tty.c:829 [inline] __receive_buf drivers/tty/n_tty.c:1648 [inline] n_tty_receive_buf_common+0x780/0x2b80 drivers/tty/n_tty.c:1742 n_tty_receive_buf+0xc/0x10 drivers/tty/n_tty.c:1771 tiocsti drivers/tty/tty_io.c:2195 [inline] tty_ioctl+0x645/0x12a0 drivers/tty/tty_io.c:2571 vfs_ioctl fs/ioctl.c:46 [inline] file_ioctl fs/ioctl.c:509 [inline] do_vfs_ioctl+0x196/0x10c0 fs/ioctl.c:696 ksys_ioctl+0x62/0x90 fs/ioctl.c:713 __do_sys_ioctl fs/ioctl.c:720 [inline] __se_sys_ioctl fs/ioctl.c:718 [inline] __x64_sys_ioctl+0x6e/0xb0 fs/ioctl.c:718 do_syscall_64+0xd0/0x520 arch/x86/entry/common.c:298 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 *** 5 locks held by syz-executor.2/8250: #0: 0000000009fd3d14 (&tty->ldisc_sem){++++}, at: ldsem_down_read+0x2d/0x40 drivers/tty/tty_ldsem.c:341 #1: 000000005c055205 (&o_tty->termios_rwsem/1){++++}, at: n_tty_receive_buf_common+0x80/0x2b80 drivers/tty/n_tty.c:1705 #2: 00000000cc69959f (&ldata->output_lock){+.+.}, at: flush_echoes drivers/tty/n_tty.c:827 [inline] #2: 00000000cc69959f (&ldata->output_lock){+.+.}, at: __receive_buf drivers/tty/n_tty.c:1648 [inline] #2: 00000000cc69959f (&ldata->output_lock){+.+.}, at: n_tty_receive_buf_common+0x740/0x2b80 drivers/tty/n_tty.c:1742 #3: 0000000044920d21 (&(&port->lock)->rlock){-.-.}, at: pty_write+0xbf/0x200 drivers/tty/pty.c:120 #4: 000000000d6a0a0a (console_lock){+.+.}, at: console_trylock_spinning kernel/printk/printk.c:1699 [inline] #4: 000000000d6a0a0a (console_lock){+.+.}, at: vprintk_emit+0x184/0x540 kernel/printk/printk.c:1974 stack backtrace: CPU: 1 PID: 8250 Comm: syz-executor.2 Not tainted 5.1.0+ #1 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+0x113/0x167 lib/dump_stack.c:113 print_circular_bug.cold.59+0x1bd/0x27d kernel/locking/lockdep.c:1564 check_prev_add kernel/locking/lockdep.c:2309 [inline] check_prevs_add kernel/locking/lockdep.c:2417 [inline] validate_chain kernel/locking/lockdep.c:2799 [inline] __lock_acquire+0x3853/0x55b0 kernel/locking/lockdep.c:3792 lock_acquire+0x173/0x3d0 kernel/locking/lockdep.c:4302 console_lock_spinning_enable kernel/printk/printk.c:1637 [inline] console_unlock+0x3b6/0xb80 kernel/printk/printk.c:2449 vprintk_emit+0x191/0x540 kernel/printk/printk.c:1975 vprintk_default+0x1a/0x20 kernel/printk/printk.c:2002 vprintk_func+0x49/0x12c kernel/printk/printk_safe.c:398 printk+0x9a/0xc0 kernel/printk/printk.c:2035 fail_dump lib/fault-inject.c:44 [inline] should_fail+0x551/0x68a lib/fault-inject.c:143 __should_fail_alloc_page mm/page_alloc.c:3237 [inline] should_fail_alloc_page+0x50/0x60 mm/page_alloc.c:3274 prepare_alloc_pages mm/page_alloc.c:4557 [inline] __alloc_pages_nodemask+0x17f/0x850 mm/page_alloc.c:4604 __alloc_pages include/linux/gfp.h:473 [inline] __alloc_pages_node include/linux/gfp.h:486 [inline] kmem_getpages mm/slab.c:1398 [inline] cache_grow_begin+0x92/0x850 mm/slab.c:2636 cache_alloc_refill mm/slab.c:3009 [inline] ____cache_alloc mm/slab.c:3092 [inline] __do_cache_alloc mm/slab.c:3314 [inline] slab_alloc mm/slab.c:3349 [inline] __do_kmalloc mm/slab.c:3689 [inline] __kmalloc+0x69e/0x760 mm/slab.c:3700 kmalloc include/linux/slab.h:552 [inline] tty_buffer_alloc drivers/tty/tty_buffer.c:175 [inline] __tty_buffer_request_room+0x1b3/0x550 drivers/tty/tty_buffer.c:273 tty_insert_flip_string_fixed_flag+0x77/0x1a0 drivers/tty/tty_buffer.c:318 tty_insert_flip_string include/linux/tty_flip.h:37 [inline] pty_write+0xf3/0x200 drivers/tty/pty.c:122 tty_put_char+0x105/0x130 drivers/tty/tty_io.c:3031 __process_echoes+0x157/0x790 drivers/tty/n_tty.c:746 flush_echoes drivers/tty/n_tty.c:829 [inline] __receive_buf drivers/tty/n_tty.c:1648 [inline] n_tty_receive_buf_common+0x780/0x2b80 drivers/tty/n_tty.c:1742 n_tty_receive_buf+0xc/0x10 drivers/tty/n_tty.c:1771 tiocsti drivers/tty/tty_io.c:2195 [inline] tty_ioctl+0x645/0x12a0 drivers/tty/tty_io.c:2571 vfs_ioctl fs/ioctl.c:46 [inline] file_ioctl fs/ioctl.c:509 [inline] do_vfs_ioctl+0x196/0x10c0 fs/ioctl.c:696 ksys_ioctl+0x62/0x90 fs/ioctl.c:713 __do_sys_ioctl fs/ioctl.c:720 [inline] __se_sys_ioctl fs/ioctl.c:718 [inline] __x64_sys_ioctl+0x6e/0xb0 fs/ioctl.c:718 do_syscall_64+0xd0/0x520 arch/x86/entry/common.c:298 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x4592c9 Code: fd b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 cb b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007fd27f2bec78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007fd27f2bec90 RCX: 00000000004592c9 RDX: 0000000020000040 RSI: 0000000000005412 RDI: 0000000000000004 RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007fd27f2bf6d4 R13: 00000000004c3827 R14: 00000000004d71d8 R15: 0000000000000005