====================================================== WARNING: possible circular locking dependency detected 5.9.0-rc2-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.0/11303 is trying to acquire lock: ffffffff894fc9c0 (console_owner){-.-.}-{0:0}, at: console_trylock_spinning+0x11a/0x380 kernel/printk/printk.c:1764 but task is already holding lock: ffff8880a16e2958 (&port->lock#2){-.-.}-{2:2}, at: pty_write+0xb6/0x180 drivers/tty/pty.c:120 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (&port->lock#2){-.-.}-{2:2}: lock_acquire+0x160/0x730 kernel/locking/lockdep.c:5005 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x9e/0xc0 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+0xac/0x190 drivers/tty/serial/8250/8250_port.c:1935 serial8250_interrupt+0x93/0x180 drivers/tty/serial/8250/8250_core.c:126 __handle_irq_event_percpu+0x1b7/0x610 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/0xbf0 kernel/irq/chip.c:819 asm_call_on_stack+0xf/0x20 arch/x86/entry/entry_64.S:706 __run_on_irqstack arch/x86/include/asm/irq_stack.h:22 [inline] run_on_irqstack_cond arch/x86/include/asm/irq_stack.h:48 [inline] handle_irq arch/x86/kernel/irq.c:230 [inline] __common_interrupt arch/x86/kernel/irq.c:249 [inline] common_interrupt+0x13c/0x230 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+0xa5/0xd0 kernel/locking/spinlock.c:191 spin_unlock_irqrestore include/linux/spinlock.h:409 [inline] uart_write+0x767/0x8f0 drivers/tty/serial/serial_core.c:615 do_output_char+0x63b/0x940 drivers/tty/n_tty.c:447 process_output drivers/tty/n_tty.c:514 [inline] n_tty_write+0xd5c/0x1170 drivers/tty/n_tty.c:2345 do_tty_write drivers/tty/tty_io.c:962 [inline] tty_write+0x593/0x940 drivers/tty/tty_io.c:1046 do_loop_readv_writev fs/read_write.c:737 [inline] do_iter_write+0x441/0x610 fs/read_write.c:1020 vfs_writev fs/read_write.c:1091 [inline] do_writev+0x23f/0x4a0 fs/read_write.c:1134 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 -> #1 (&port->lock){-.-.}-{2:2}: lock_acquire+0x160/0x730 kernel/locking/lockdep.c:5005 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x9e/0xc0 kernel/locking/spinlock.c:159 serial8250_console_write+0x13e/0xd60 drivers/tty/serial/8250/8250_port.c:3289 call_console_drivers kernel/printk/printk.c:1822 [inline] console_unlock+0x90c/0xec0 kernel/printk/printk.c:2501 vprintk_emit+0x1f8/0x3c0 kernel/printk/printk.c:2029 printk+0x62/0x83 kernel/printk/printk.c:2078 register_console+0x7ca/0xad0 kernel/printk/printk.c:2854 univ8250_console_init+0x41/0x43 drivers/tty/serial/8250/8250_core.c:690 console_init+0x52/0x97 kernel/printk/printk.c:2954 start_kernel+0x2db/0x4f0 init/main.c:975 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+0x1b0c/0x88a0 kernel/locking/lockdep.c:3218 __lock_acquire+0x1161/0x2ab0 kernel/locking/lockdep.c:4426 lock_acquire+0x160/0x730 kernel/locking/lockdep.c:5005 console_trylock_spinning+0x13a/0x380 kernel/printk/printk.c:1781 vprintk_emit+0x1db/0x3c0 kernel/printk/printk.c:2028 printk+0x62/0x83 kernel/printk/printk.c:2078 fail_dump lib/fault-inject.c:45 [inline] should_fail+0x36c/0x4e0 lib/fault-inject.c:146 prepare_alloc_pages+0x248/0x4b0 mm/page_alloc.c:4824 __alloc_pages_nodemask+0xbc/0x5c0 mm/page_alloc.c:4870 __alloc_pages include/linux/gfp.h:509 [inline] __alloc_pages_node include/linux/gfp.h:522 [inline] kmem_getpages+0x37/0x1d0 mm/slab.c:1376 cache_grow_begin+0x64/0x270 mm/slab.c:2590 cache_alloc_refill+0x359/0x3f0 mm/slab.c:2962 ____cache_alloc mm/slab.c:3045 [inline] __do_cache_alloc mm/slab.c:3268 [inline] slab_alloc mm/slab.c:3304 [inline] __do_kmalloc mm/slab.c:3653 [inline] __kmalloc+0x2f9/0x320 mm/slab.c:3664 kmalloc include/linux/slab.h:559 [inline] tty_buffer_alloc drivers/tty/tty_buffer.c:175 [inline] __tty_buffer_request_room+0x1f3/0x540 drivers/tty/tty_buffer.c:273 tty_insert_flip_string_fixed_flag+0x91/0x2c0 drivers/tty/tty_buffer.c:318 tty_insert_flip_string include/linux/tty_flip.h:37 [inline] pty_write+0xda/0x180 drivers/tty/pty.c:122 n_tty_write+0x584/0x1170 drivers/tty/n_tty.c:2356 do_tty_write drivers/tty/tty_io.c:962 [inline] tty_write+0x593/0x940 drivers/tty/tty_io.c:1046 __kernel_write+0x1ac/0xac0 fs/read_write.c:528 write_pipe_buf+0xf9/0x150 fs/splice.c:799 splice_from_pipe_feed fs/splice.c:502 [inline] __splice_from_pipe+0x351/0x8b0 fs/splice.c:626 splice_from_pipe fs/splice.c:661 [inline] default_file_splice_write fs/splice.c:811 [inline] do_splice_from fs/splice.c:847 [inline] direct_splice_actor+0x1eb/0x2a0 fs/splice.c:1016 splice_direct_to_actor+0x4a2/0xb60 fs/splice.c:971 do_splice_direct+0x201/0x340 fs/splice.c:1059 do_sendfile+0x86d/0x1210 fs/read_write.c:1540 __do_sys_sendfile64 fs/read_write.c:1601 [inline] __se_sys_sendfile64 fs/read_write.c:1587 [inline] __x64_sys_sendfile64+0x164/0x1a0 fs/read_write.c:1587 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 other info that might help us debug this: Chain exists of: console_owner --> &port->lock --> &port->lock#2 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&port->lock#2); lock(&port->lock); lock(&port->lock#2); lock(console_owner); *** DEADLOCK *** 5 locks held by syz-executor.0/11303: #0: ffff88808a53f098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref_wait+0x21/0x70 drivers/tty/tty_ldisc.c:267 #1: ffff88808a53f130 (&tty->atomic_write_lock){+.+.}-{3:3}, at: tty_write_lock drivers/tty/tty_io.c:888 [inline] #1: ffff88808a53f130 (&tty->atomic_write_lock){+.+.}-{3:3}, at: do_tty_write drivers/tty/tty_io.c:911 [inline] #1: ffff88808a53f130 (&tty->atomic_write_lock){+.+.}-{3:3}, at: tty_write+0x22c/0x940 drivers/tty/tty_io.c:1046 #2: ffff88808a53f2e8 (&tty->termios_rwsem){++++}-{3:3}, at: n_tty_write+0x1e0/0x1170 drivers/tty/n_tty.c:2316 #3: ffffc90000ed0378 (&ldata->output_lock){+.+.}-{3:3}, at: n_tty_write+0x53a/0x1170 drivers/tty/n_tty.c:2355 #4: ffff8880a16e2958 (&port->lock#2){-.-.}-{2:2}, at: pty_write+0xb6/0x180 drivers/tty/pty.c:120 stack backtrace: CPU: 1 PID: 11303 Comm: syz-executor.0 Not tainted 5.9.0-rc2-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+0x1f0/0x31e lib/dump_stack.c:118 print_circular_bug+0xc72/0xea0 kernel/locking/lockdep.c:1703 check_noncircular+0x1fb/0x3a0 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+0x1b0c/0x88a0 kernel/locking/lockdep.c:3218 __lock_acquire+0x1161/0x2ab0 kernel/locking/lockdep.c:4426 lock_acquire+0x160/0x730 kernel/locking/lockdep.c:5005 console_trylock_spinning+0x13a/0x380 kernel/printk/printk.c:1781 vprintk_emit+0x1db/0x3c0 kernel/printk/printk.c:2028 printk+0x62/0x83 kernel/printk/printk.c:2078 fail_dump lib/fault-inject.c:45 [inline] should_fail+0x36c/0x4e0 lib/fault-inject.c:146 prepare_alloc_pages+0x248/0x4b0 mm/page_alloc.c:4824 __alloc_pages_nodemask+0xbc/0x5c0 mm/page_alloc.c:4870 __alloc_pages include/linux/gfp.h:509 [inline] __alloc_pages_node include/linux/gfp.h:522 [inline] kmem_getpages+0x37/0x1d0 mm/slab.c:1376 cache_grow_begin+0x64/0x270 mm/slab.c:2590 cache_alloc_refill+0x359/0x3f0 mm/slab.c:2962 ____cache_alloc mm/slab.c:3045 [inline] __do_cache_alloc mm/slab.c:3268 [inline] slab_alloc mm/slab.c:3304 [inline] __do_kmalloc mm/slab.c:3653 [inline] __kmalloc+0x2f9/0x320 mm/slab.c:3664 kmalloc include/linux/slab.h:559 [inline] tty_buffer_alloc drivers/tty/tty_buffer.c:175 [inline] __tty_buffer_request_room+0x1f3/0x540 drivers/tty/tty_buffer.c:273 tty_insert_flip_string_fixed_flag+0x91/0x2c0 drivers/tty/tty_buffer.c:318 tty_insert_flip_string include/linux/tty_flip.h:37 [inline] pty_write+0xda/0x180 drivers/tty/pty.c:122 n_tty_write+0x584/0x1170 drivers/tty/n_tty.c:2356 do_tty_write drivers/tty/tty_io.c:962 [inline] tty_write+0x593/0x940 drivers/tty/tty_io.c:1046 __kernel_write+0x1ac/0xac0 fs/read_write.c:528 write_pipe_buf+0xf9/0x150 fs/splice.c:799 splice_from_pipe_feed fs/splice.c:502 [inline] __splice_from_pipe+0x351/0x8b0 fs/splice.c:626 splice_from_pipe fs/splice.c:661 [inline] default_file_splice_write fs/splice.c:811 [inline] do_splice_from fs/splice.c:847 [inline] direct_splice_actor+0x1eb/0x2a0 fs/splice.c:1016 splice_direct_to_actor+0x4a2/0xb60 fs/splice.c:971 do_splice_direct+0x201/0x340 fs/splice.c:1059 do_sendfile+0x86d/0x1210 fs/read_write.c:1540 __do_sys_sendfile64 fs/read_write.c:1601 [inline] __se_sys_sendfile64 fs/read_write.c:1587 [inline] __x64_sys_sendfile64+0x164/0x1a0 fs/read_write.c:1587 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x45d5b9 Code: 5d b4 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 2b b4 fb ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007fae19c6ac78 EFLAGS: 00000246 ORIG_RAX: 0000000000000028 RAX: ffffffffffffffda RBX: 0000000000027840 RCX: 000000000045d5b9 RDX: 0000000000000000 RSI: 0000000000000003 RDI: 0000000000000004 RBP: 00007fae19c6aca0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000040811001 R11: 0000000000000246 R12: 0000000000000017 R13: 00007fff9bee6fdf R14: 00007fae19c6b9c0 R15: 000000000118cf4c