syzbot


possible deadlock in tty_port_tty_get

Status: upstream: reported on 2022/09/30 22:05
Reported-by: syzbot+223c7461c58c58a4cb10@syzkaller.appspotmail.com
First crash: 67d, last: 5m
similar bugs (1):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 possible deadlock in tty_port_tty_get 3 66d 104d 0/1 upstream: reported on 2022/08/20 20:12

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.1.0-rc7-syzkaller-00140-gbdaa78c6aa86 #0 Not tainted
------------------------------------------------------
syz-executor.3/7329 is trying to acquire lock:
ffffffff8c6c9ae8 (zonelist_update_seq.seqcount){...-}-{0:0}, at: __alloc_pages+0x4aa/0x5b0 mm/page_alloc.c:5571

but task is already holding lock:
ffff888029224158 (&port->lock){-...}-{2:2}, at: tty_insert_flip_string_and_push_buffer+0x2f/0x160 drivers/tty/tty_buffer.c:628

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&port->lock){-...}-{2:2}:
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0x3d/0x60 kernel/locking/spinlock.c:162
       tty_port_tty_get+0x21/0xf0 drivers/tty/tty_port.c:327
       tty_port_default_wakeup+0x15/0x40 drivers/tty/tty_port.c:68
       serial8250_tx_chars+0x503/0xdb0 drivers/tty/serial/8250/8250_port.c:1859
       serial8250_handle_irq.part.0+0x460/0x870 drivers/tty/serial/8250/8250_port.c:1949
       serial8250_handle_irq drivers/tty/serial/8250/8250_port.c:1922 [inline]
       serial8250_default_handle_irq+0xb6/0x230 drivers/tty/serial/8250/8250_port.c:1969
       serial8250_interrupt+0xfc/0x200 drivers/tty/serial/8250/8250_core.c:126
       __handle_irq_event_percpu+0x264/0x970 kernel/irq/handle.c:158
       handle_irq_event_percpu kernel/irq/handle.c:193 [inline]
       handle_irq_event+0xab/0x1e0 kernel/irq/handle.c:210
       handle_edge_irq+0x263/0xd00 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+0xa1/0x210 arch/x86/kernel/irq.c:250
       common_interrupt+0xa8/0xd0 arch/x86/kernel/irq.c:240
       asm_common_interrupt+0x26/0x40 arch/x86/include/asm/idtentry.h:640
       native_safe_halt arch/x86/include/asm/irqflags.h:51 [inline]
       arch_safe_halt arch/x86/include/asm/irqflags.h:89 [inline]
       default_idle+0xf/0x10 arch/x86/kernel/process.c:730
       default_idle_call+0x84/0xc0 kernel/sched/idle.c:109
       cpuidle_idle_call kernel/sched/idle.c:191 [inline]
       do_idle+0x410/0x590 kernel/sched/idle.c:303
       cpu_startup_entry+0x18/0x20 kernel/sched/idle.c:400
       start_secondary+0x256/0x300 arch/x86/kernel/smpboot.c:262
       secondary_startup_64_no_verify+0xce/0xdb

-> #2 (&port_lock_key){-.-.}-{2:2}:
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0x3d/0x60 kernel/locking/spinlock.c:162
       serial8250_console_write+0x4ba/0x1010 drivers/tty/serial/8250/8250_port.c:3395
       call_console_driver kernel/printk/printk.c:1942 [inline]
       console_emit_next_record.constprop.0+0x3de/0x840 kernel/printk/printk.c:2731
       console_flush_all kernel/printk/printk.c:2793 [inline]
       console_unlock+0x3c2/0x600 kernel/printk/printk.c:2860
       vprintk_emit+0x1bd/0x600 kernel/printk/printk.c:2268
       vprintk+0x84/0xa0 kernel/printk/printk_safe.c:50
       _printk+0xbe/0xf1 kernel/printk/printk.c:2289
       register_console kernel/printk/printk.c:3208 [inline]
       register_console+0x45e/0x820 kernel/printk/printk.c:3103
       univ8250_console_init+0x3e/0x4a drivers/tty/serial/8250/8250_core.c:687
       console_init+0x3bb/0x582 kernel/printk/printk.c:3298
       start_kernel+0x303/0x498 init/main.c:1073
       secondary_startup_64_no_verify+0xce/0xdb

-> #1 (console_owner){-...}-{0:0}:
       console_lock_spinning_enable kernel/printk/printk.c:1805 [inline]
       console_emit_next_record.constprop.0+0x2dd/0x840 kernel/printk/printk.c:2728
       console_flush_all kernel/printk/printk.c:2793 [inline]
       console_unlock+0x3c2/0x600 kernel/printk/printk.c:2860
       vprintk_emit+0x1bd/0x600 kernel/printk/printk.c:2268
       vprintk+0x84/0xa0 kernel/printk/printk_safe.c:50
       _printk+0xbe/0xf1 kernel/printk/printk.c:2289
       build_zonelists.cold+0xe5/0x11f mm/page_alloc.c:6506
       __build_all_zonelists+0x122/0x180 mm/page_alloc.c:6619
       build_all_zonelists_init+0x35/0x12f mm/page_alloc.c:6644
       build_all_zonelists+0x123/0x140 mm/page_alloc.c:6677
       start_kernel+0xbd/0x498 init/main.c:967
       secondary_startup_64_no_verify+0xce/0xdb

-> #0 (zonelist_update_seq.seqcount){...-}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3097 [inline]
       check_prevs_add kernel/locking/lockdep.c:3216 [inline]
       validate_chain kernel/locking/lockdep.c:3831 [inline]
       __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5055
       lock_acquire kernel/locking/lockdep.c:5668 [inline]
       lock_acquire+0x1e3/0x630 kernel/locking/lockdep.c:5633
       seqcount_lockdep_reader_access include/linux/seqlock.h:102 [inline]
       read_seqbegin include/linux/seqlock.h:836 [inline]
       zonelist_iter_begin mm/page_alloc.c:4730 [inline]
       __alloc_pages_slowpath.constprop.0+0x1ae/0x23d0 mm/page_alloc.c:5052
       __alloc_pages+0x4aa/0x5b0 mm/page_alloc.c:5571
       __alloc_pages_node include/linux/gfp.h:237 [inline]
       kmem_getpages mm/slab.c:1363 [inline]
       cache_grow_begin+0x94/0x390 mm/slab.c:2570
       cache_alloc_refill+0x27f/0x380 mm/slab.c:2943
       ____cache_alloc mm/slab.c:3019 [inline]
       ____cache_alloc mm/slab.c:3002 [inline]
       __do_cache_alloc mm/slab.c:3202 [inline]
       slab_alloc_node mm/slab.c:3250 [inline]
       __kmem_cache_alloc_node+0x44a/0x510 mm/slab.c:3549
       __do_kmalloc_node mm/slab_common.c:954 [inline]
       __kmalloc+0x4a/0xd0 mm/slab_common.c:968
       kmalloc include/linux/slab.h:558 [inline]
       tty_buffer_alloc+0x27b/0x2f0 drivers/tty/tty_buffer.c:180
       __tty_buffer_request_room+0x15f/0x2b0 drivers/tty/tty_buffer.c:278
       tty_insert_flip_string_fixed_flag+0x90/0x250 drivers/tty/tty_buffer.c:327
       tty_insert_flip_string include/linux/tty_flip.h:41 [inline]
       tty_insert_flip_string_and_push_buffer+0x42/0x160 drivers/tty/tty_buffer.c:629
       pty_write+0xda/0x100 drivers/tty/pty.c:118
       n_tty_write+0xb38/0xfd0 drivers/tty/n_tty.c:2373
       do_tty_write drivers/tty/tty_io.c:1018 [inline]
       file_tty_write.constprop.0+0x452/0x890 drivers/tty/tty_io.c:1089
       call_write_iter include/linux/fs.h:2199 [inline]
       do_iter_readv_writev+0x20b/0x3b0 fs/read_write.c:735
       do_iter_write+0x182/0x700 fs/read_write.c:861
       vfs_iter_write+0x74/0xa0 fs/read_write.c:902
       iter_file_splice_write+0x745/0xc90 fs/splice.c:686
       do_splice_from fs/splice.c:764 [inline]
       direct_splice_actor+0x114/0x180 fs/splice.c:931
       splice_direct_to_actor+0x335/0x8a0 fs/splice.c:886
       do_splice_direct+0x1ab/0x280 fs/splice.c:974
       do_sendfile+0xb19/0x1270 fs/read_write.c:1255
       __do_sys_sendfile64 fs/read_write.c:1323 [inline]
       __se_sys_sendfile64 fs/read_write.c:1309 [inline]
       __x64_sys_sendfile64+0x1d0/0x210 fs/read_write.c:1309
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

other info that might help us debug this:

Chain exists of:
  zonelist_update_seq.seqcount --> &port_lock_key --> &port->lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&port->lock);
                               lock(&port_lock_key);
                               lock(&port->lock);
  lock(zonelist_update_seq.seqcount);

 *** DEADLOCK ***

5 locks held by syz-executor.3/7329:
 #0: ffff888025136098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref_wait+0x26/0x80 drivers/tty/tty_ldisc.c:244
 #1: ffff888025136130 (&tty->atomic_write_lock){+.+.}-{3:3}, at: tty_write_lock drivers/tty/tty_io.c:944 [inline]
 #1: ffff888025136130 (&tty->atomic_write_lock){+.+.}-{3:3}, at: do_tty_write drivers/tty/tty_io.c:967 [inline]
 #1: ffff888025136130 (&tty->atomic_write_lock){+.+.}-{3:3}, at: file_tty_write.constprop.0+0x251/0x890 drivers/tty/tty_io.c:1089
 #2: ffff8880251362e8 (&tty->termios_rwsem){++++}-{3:3}, at: n_tty_write+0x1c3/0xfd0 drivers/tty/n_tty.c:2333
 #3: ffffc90000e71380 (&ldata->output_lock){+.+.}-{3:3}, at: n_tty_write+0xb05/0xfd0 drivers/tty/n_tty.c:2372
 #4: ffff888029224158 (&port->lock){-...}-{2:2}, at: tty_insert_flip_string_and_push_buffer+0x2f/0x160 drivers/tty/tty_buffer.c:628

stack backtrace:
CPU: 2 PID: 7329 Comm: syz-executor.3 Not tainted 6.1.0-rc7-syzkaller-00140-gbdaa78c6aa86 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106
 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2177
 check_prev_add kernel/locking/lockdep.c:3097 [inline]
 check_prevs_add kernel/locking/lockdep.c:3216 [inline]
 validate_chain kernel/locking/lockdep.c:3831 [inline]
 __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5055
 lock_acquire kernel/locking/lockdep.c:5668 [inline]
 lock_acquire+0x1e3/0x630 kernel/locking/lockdep.c:5633
 seqcount_lockdep_reader_access include/linux/seqlock.h:102 [inline]
 read_seqbegin include/linux/seqlock.h:836 [inline]
 zonelist_iter_begin mm/page_alloc.c:4730 [inline]
 __alloc_pages_slowpath.constprop.0+0x1ae/0x23d0 mm/page_alloc.c:5052
 __alloc_pages+0x4aa/0x5b0 mm/page_alloc.c:5571
 __alloc_pages_node include/linux/gfp.h:237 [inline]
 kmem_getpages mm/slab.c:1363 [inline]
 cache_grow_begin+0x94/0x390 mm/slab.c:2570
 cache_alloc_refill+0x27f/0x380 mm/slab.c:2943
 ____cache_alloc mm/slab.c:3019 [inline]
 ____cache_alloc mm/slab.c:3002 [inline]
 __do_cache_alloc mm/slab.c:3202 [inline]
 slab_alloc_node mm/slab.c:3250 [inline]
 __kmem_cache_alloc_node+0x44a/0x510 mm/slab.c:3549
 __do_kmalloc_node mm/slab_common.c:954 [inline]
 __kmalloc+0x4a/0xd0 mm/slab_common.c:968
 kmalloc include/linux/slab.h:558 [inline]
 tty_buffer_alloc+0x27b/0x2f0 drivers/tty/tty_buffer.c:180
 __tty_buffer_request_room+0x15f/0x2b0 drivers/tty/tty_buffer.c:278
 tty_insert_flip_string_fixed_flag+0x90/0x250 drivers/tty/tty_buffer.c:327
 tty_insert_flip_string include/linux/tty_flip.h:41 [inline]
 tty_insert_flip_string_and_push_buffer+0x42/0x160 drivers/tty/tty_buffer.c:629
 pty_write+0xda/0x100 drivers/tty/pty.c:118
 n_tty_write+0xb38/0xfd0 drivers/tty/n_tty.c:2373
 do_tty_write drivers/tty/tty_io.c:1018 [inline]
 file_tty_write.constprop.0+0x452/0x890 drivers/tty/tty_io.c:1089
 call_write_iter include/linux/fs.h:2199 [inline]
 do_iter_readv_writev+0x20b/0x3b0 fs/read_write.c:735
 do_iter_write+0x182/0x700 fs/read_write.c:861
 vfs_iter_write+0x74/0xa0 fs/read_write.c:902
 iter_file_splice_write+0x745/0xc90 fs/splice.c:686
 do_splice_from fs/splice.c:764 [inline]
 direct_splice_actor+0x114/0x180 fs/splice.c:931
 splice_direct_to_actor+0x335/0x8a0 fs/splice.c:886
 do_splice_direct+0x1ab/0x280 fs/splice.c:974
 do_sendfile+0xb19/0x1270 fs/read_write.c:1255
 __do_sys_sendfile64 fs/read_write.c:1323 [inline]
 __se_sys_sendfile64 fs/read_write.c:1309 [inline]
 __x64_sys_sendfile64+0x1d0/0x210 fs/read_write.c:1309
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f2e5d48c0d9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 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 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f2e5e2bb168 EFLAGS: 00000246 ORIG_RAX: 0000000000000028
RAX: ffffffffffffffda RBX: 00007f2e5d5abf80 RCX: 00007f2e5d48c0d9
RDX: 0000000000000000 RSI: 0000000000000005 RDI: 0000000000000006
RBP: 00007f2e5d4e7ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0800000080000012 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffc05018dcf R14: 00007f2e5e2bb300 R15: 0000000000022000
 </TASK>

Crashes (6527):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-qemu-upstream 2022/12/03 01:42 upstream bdaa78c6aa86 e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/03 00:47 upstream bdaa78c6aa86 e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 23:42 upstream bdaa78c6aa86 e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 23:28 upstream bdaa78c6aa86 e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 22:25 upstream bdaa78c6aa86 e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 21:13 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 20:06 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 18:54 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 17:48 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 16:14 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 14:56 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 14:47 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 13:47 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 12:36 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 11:37 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 10:14 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 08:24 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 06:33 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 05:27 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 04:43 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 03:43 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 02:58 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 01:44 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/02 01:10 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/01 22:57 upstream ef4d3ea40565 3b580c21 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/01 22:15 upstream ef4d3ea40565 3b580c21 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/01 21:11 upstream ef4d3ea40565 3b580c21 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/01 20:04 upstream ef4d3ea40565 3b580c21 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/01 18:43 upstream ef4d3ea40565 3b580c21 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/01 17:33 upstream ef4d3ea40565 3b580c21 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/01 17:30 upstream ef4d3ea40565 3b580c21 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/01 16:29 upstream ef4d3ea40565 3b580c21 .config log report info possible deadlock in tty_port_tty_get
ci-upstream-kasan-gce-selinux-root 2022/12/01 15:27 upstream ef4d3ea40565 e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/01 15:24 upstream ef4d3ea40565 3b580c21 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/01 14:24 upstream ef4d3ea40565 3b580c21 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/01 14:02 upstream ef4d3ea40565 3b580c21 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/01 12:56 upstream ef4d3ea40565 3b580c21 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/01 11:36 upstream ef4d3ea40565 4c2a66e8 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/01 10:43 upstream ef4d3ea40565 4c2a66e8 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/01 09:39 upstream ef4d3ea40565 4c2a66e8 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/01 08:55 upstream ef4d3ea40565 4c2a66e8 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/12/01 07:54 upstream ef4d3ea40565 4c2a66e8 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/09/30 20:52 upstream 5a77386984b5 5e8ac358 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream 2022/09/26 21:59 upstream 3800a713b607 10323ddf .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream-386 2022/12/02 07:08 upstream a4412fdd49dc e080de16 .config log report info possible deadlock in tty_port_tty_get
ci-qemu-upstream-386 2022/12/01 23:59 upstream ef4d3ea40565 3b580c21 .config log report info possible deadlock in tty_port_tty_get
* Struck through repros no longer work on HEAD.