syzbot


possible deadlock in tty_port_tty_get

Status: fixed on 2023/06/08 14:41
Subsystems: serial
[Documentation on labels]
Reported-by: syzbot+223c7461c58c58a4cb10@syzkaller.appspotmail.com
Fix commit: 1007843a9190 mm/page_alloc: fix potential deadlock on zonelist_update_seq seqlock
First crash: 524d, last: 319d
Discussions (2)
Title Replies (including bot) Last reply
[PATCH] mm/page_alloc: don't check zonelist_update_seq from atomic allocations 20 (20) 2023/04/05 09:02
[syzbot] possible deadlock in tty_port_tty_get 0 (2) 2023/03/25 23:02
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 5 381d 561d 0/1 upstream: reported on 2022/08/20 20:12
Last patch testing requests (1)
Created Duration User Patch Repo Result
2023/03/26 13:59 34m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 65aca32efdcb OK log

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.3.0-rc3-syzkaller-00317-g65aca32efdcb #0 Not tainted
------------------------------------------------------
syz-executor930/5168 is trying to acquire lock:
ffffffff8c8e11e8 (zonelist_update_seq.seqcount){...-}-{0:0}, at: __alloc_pages+0x408/0x4a0 mm/page_alloc.c:5605

but task is already holding lock:
ffff888014325958 (&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+0x53e/0xdf0 drivers/tty/serial/8250/8250_port.c:1865
       serial8250_handle_irq.part.0+0x460/0x870 drivers/tty/serial/8250/8250_port.c:1955
       serial8250_handle_irq drivers/tty/serial/8250/8250_port.c:1928 [inline]
       serial8250_default_handle_irq+0xb6/0x230 drivers/tty/serial/8250/8250_port.c:1975
       serial8250_interrupt+0xfc/0x200 drivers/tty/serial/8250/8250_core.c:127
       __handle_irq_event_percpu+0x22b/0x730 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/0x220 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:636
       native_safe_halt arch/x86/include/asm/irqflags.h:48 [inline]
       arch_safe_halt arch/x86/include/asm/irqflags.h:86 [inline]
       default_idle+0xf/0x20 arch/x86/kernel/process.c:703
       default_idle_call+0x67/0xa0 kernel/sched/idle.c:97
       cpuidle_idle_call kernel/sched/idle.c:170 [inline]
       do_idle+0x31e/0x3e0 kernel/sched/idle.c:282
       cpu_startup_entry+0x18/0x20 kernel/sched/idle.c:379
       start_secondary+0x221/0x2b0 arch/x86/kernel/smpboot.c:264
       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:3401
       console_emit_next_record kernel/printk/printk.c:2886 [inline]
       console_flush_all+0x49c/0xcc0 kernel/printk/printk.c:2942
       console_unlock+0xb8/0x1f0 kernel/printk/printk.c:3016
       vprintk_emit+0x1bd/0x600 kernel/printk/printk.c:2316
       vprintk+0x84/0xa0 kernel/printk/printk_safe.c:50
       _printk+0xbf/0xf0 kernel/printk/printk.c:2337
       register_console+0x7ef/0x10e0 kernel/printk/printk.c:3467
       univ8250_console_init+0x38/0x50 drivers/tty/serial/8250/8250_core.c:688
       console_init+0xba/0x5c0 kernel/printk/printk.c:3610
       start_kernel+0x273/0x4d0 init/main.c:1081
       secondary_startup_64_no_verify+0xce/0xdb

-> #1 (console_owner){....}-{0:0}:
       console_lock_spinning_enable kernel/printk/printk.c:1867 [inline]
       console_emit_next_record kernel/printk/printk.c:2880 [inline]
       console_flush_all+0x472/0xcc0 kernel/printk/printk.c:2942
       console_unlock+0xb8/0x1f0 kernel/printk/printk.c:3016
       vprintk_emit+0x1bd/0x600 kernel/printk/printk.c:2316
       vprintk+0x84/0xa0 kernel/printk/printk_safe.c:50
       _printk+0xbf/0xf0 kernel/printk/printk.c:2337
       build_zonelists+0x357/0x560 mm/page_alloc.c:6543
       __build_all_zonelists+0x122/0x180 mm/page_alloc.c:6656
       build_all_zonelists_init+0x1c/0x190 mm/page_alloc.c:6681
       build_all_zonelists+0x4a/0x150 mm/page_alloc.c:6714
       start_kernel+0xb7/0x4d0 init/main.c:975
       secondary_startup_64_no_verify+0xce/0xdb

-> #0 (zonelist_update_seq.seqcount){...-}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3098 [inline]
       check_prevs_add kernel/locking/lockdep.c:3217 [inline]
       validate_chain kernel/locking/lockdep.c:3832 [inline]
       __lock_acquire+0x2ec7/0x5d40 kernel/locking/lockdep.c:5056
       lock_acquire kernel/locking/lockdep.c:5669 [inline]
       lock_acquire+0x1af/0x520 kernel/locking/lockdep.c:5634
       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:4765 [inline]
       __alloc_pages_slowpath.constprop.0+0x15a/0x2170 mm/page_alloc.c:5086
       __alloc_pages+0x408/0x4a0 mm/page_alloc.c:5605
       __alloc_pages_node include/linux/gfp.h:237 [inline]
       kmem_getpages mm/slab.c:1360 [inline]
       cache_grow_begin+0x9b/0x3b0 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+0x360/0x3f0 mm/slab.c:3541
       __do_kmalloc_node mm/slab_common.c:966 [inline]
       __kmalloc+0x4e/0x190 mm/slab_common.c:980
       kmalloc include/linux/slab.h:584 [inline]
       tty_buffer_alloc+0x275/0x2f0 drivers/tty/tty_buffer.c:180
       __tty_buffer_request_room+0x15b/0x2d0 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
       ppp_async_push+0x5cb/0x1660 drivers/net/ppp/ppp_async.c:670
       ppp_async_send+0xe2/0x110 drivers/net/ppp/ppp_async.c:638
       __ppp_channel_push+0xe3/0x230 drivers/net/ppp/ppp_generic.c:2150
       ppp_channel_push+0x1c2/0x250 drivers/net/ppp/ppp_generic.c:2177
       ppp_write+0x22b/0x2d0 drivers/net/ppp/ppp_generic.c:523
       do_loop_readv_writev fs/read_write.c:759 [inline]
       do_loop_readv_writev fs/read_write.c:743 [inline]
       do_iter_write+0x4ef/0x700 fs/read_write.c:863
       vfs_writev+0x1aa/0x670 fs/read_write.c:934
       do_pwritev fs/read_write.c:1031 [inline]
       __do_sys_pwritev fs/read_write.c:1078 [inline]
       __se_sys_pwritev fs/read_write.c:1073 [inline]
       __x64_sys_pwritev+0x22f/0x310 fs/read_write.c:1073
       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 ***

4 locks held by syz-executor930/5168:
 #0: ffff888000630a48 (&pch->upl){.+..}-{2:2}, at: ppp_channel_push+0x28/0x250 drivers/net/ppp/ppp_generic.c:2171
 #1: ffff8880006309e0 (&pch->downl){+...}-{2:2}, at: spin_lock include/linux/spinlock.h:350 [inline]
 #1: ffff8880006309e0 (&pch->downl){+...}-{2:2}, at: __ppp_channel_push+0x2a/0x230 drivers/net/ppp/ppp_generic.c:2146
 #2: ffff8880283b8030 (&ap->xmit_lock){+...}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:355 [inline]
 #2: ffff8880283b8030 (&ap->xmit_lock){+...}-{2:2}, at: ppp_async_push+0xb2/0x1660 drivers/net/ppp/ppp_async.c:663
 #3: ffff888014325958 (&port->lock){-...}-{2:2}, at: tty_insert_flip_string_and_push_buffer+0x2f/0x160 drivers/tty/tty_buffer.c:628

stack backtrace:
CPU: 0 PID: 5168 Comm: syz-executor930 Not tainted 6.3.0-rc3-syzkaller-00317-g65aca32efdcb #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+0xd9/0x150 lib/dump_stack.c:106
 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2178
 check_prev_add kernel/locking/lockdep.c:3098 [inline]
 check_prevs_add kernel/locking/lockdep.c:3217 [inline]
 validate_chain kernel/locking/lockdep.c:3832 [inline]
 __lock_acquire+0x2ec7/0x5d40 kernel/locking/lockdep.c:5056
 lock_acquire kernel/locking/lockdep.c:5669 [inline]
 lock_acquire+0x1af/0x520 kernel/locking/lockdep.c:5634
 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:4765 [inline]
 __alloc_pages_slowpath.constprop.0+0x15a/0x2170 mm/page_alloc.c:5086
 __alloc_pages+0x408/0x4a0 mm/page_alloc.c:5605
 __alloc_pages_node include/linux/gfp.h:237 [inline]
 kmem_getpages mm/slab.c:1360 [inline]
 cache_grow_begin+0x9b/0x3b0 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+0x360/0x3f0 mm/slab.c:3541
 __do_kmalloc_node mm/slab_common.c:966 [inline]
 __kmalloc+0x4e/0x190 mm/slab_common.c:980
 kmalloc include/linux/slab.h:584 [inline]
 tty_buffer_alloc+0x275/0x2f0 drivers/tty/tty_buffer.c:180
 __tty_buffer_request_room+0x15b/0x2d0 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
 ppp_async_push+0x5cb/0x1660 drivers/net/ppp/ppp_async.c:670
 ppp_async_send+0xe2/0x110 drivers/net/ppp/ppp_async.c:638
 __ppp_channel_push+0xe3/0x230 drivers/net/ppp/ppp_generic.c:2150
 ppp_channel_push+0x1c2/0x250 drivers/net/ppp/ppp_generic.c:2177
 ppp_write+0x22b/0x2d0 drivers/net/ppp/ppp_generic.c:523
 do_loop_readv_writev fs/read_write.c:759 [inline]
 do_loop_readv_writev fs/read_write.c:743 [inline]
 do_iter_write+0x4ef/0x700 fs/read_write.c:863
 vfs_writev+0x1aa/0x670 fs/read_write.c:934
 do_pwritev fs/read_write.c:1031 [inline]
 __do_sys_pwritev fs/read_write.c:1078 [inline]
 __se_sys_pwritev fs/read_write.c:1073 [inline]
 __x64_sys_pwritev+0x22f/0x310 fs/read_write.c:1073
 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:0x7f76be0b97d9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 41 15 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fffcac24418 EFLAGS: 00000246 ORIG_RAX: 0000000000000128
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f76be0b97d9
RDX: 0000000000000003 RSI: 0000000020000380 RDI: 0000000000000004
RBP: 0000000000000000 R08: 0000000000000004 R09: 000000000000000d
R10: 00000000000000f1 R11: 0000000000000246 R12: 00007fffcac24430
R13: 00000000000f4240 R14: 0000000000000000 R15: 0000000000000000
 </TASK>

Crashes (22661):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/03/25 23:02 upstream 65aca32efdcb fbf0499a .config console log report syz C ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/20 05:34 upstream 789b4a41c247 a219f34e .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/20 03:52 upstream 789b4a41c247 a219f34e .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/20 01:28 upstream 789b4a41c247 a219f34e .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/19 22:56 upstream 789b4a41c247 a219f34e .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/19 21:29 upstream 789b4a41c247 a219f34e .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/19 20:28 upstream 789b4a41c247 a219f34e .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/19 20:17 upstream 789b4a41c247 a219f34e .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/19 19:16 upstream 789b4a41c247 a219f34e .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/19 17:53 upstream 789b4a41c247 a219f34e .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/19 15:51 upstream 789b4a41c247 94b4184e .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/19 13:00 upstream af67688dca57 94b4184e .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/19 11:51 upstream af67688dca57 94b4184e .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/19 09:19 upstream af67688dca57 94b4184e .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/19 08:03 upstream af67688dca57 94b4184e .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/19 06:54 upstream af67688dca57 94b4184e .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/19 05:53 upstream af67688dca57 94b4184e .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/19 04:23 upstream af67688dca57 d931e9f0 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/19 01:59 upstream af67688dca57 d931e9f0 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/19 01:20 upstream af67688dca57 d931e9f0 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/18 23:10 upstream af67688dca57 d931e9f0 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/18 21:59 upstream af67688dca57 d931e9f0 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/18 20:49 upstream af67688dca57 d931e9f0 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/18 19:29 upstream af67688dca57 d931e9f0 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/18 18:06 upstream 6a8f57ae2eb0 d931e9f0 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/18 16:24 upstream 6a8f57ae2eb0 d931e9f0 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/18 14:59 upstream 6a8f57ae2eb0 d931e9f0 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/18 13:55 upstream 6a8f57ae2eb0 d931e9f0 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/18 11:29 upstream 6a8f57ae2eb0 436577a9 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/18 10:22 upstream 6a8f57ae2eb0 436577a9 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/18 10:19 upstream 6a8f57ae2eb0 436577a9 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/18 09:07 upstream 6a8f57ae2eb0 436577a9 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/18 07:05 upstream 6a8f57ae2eb0 436577a9 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/18 05:36 upstream 6a8f57ae2eb0 436577a9 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/18 04:35 upstream 6a8f57ae2eb0 436577a9 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/18 03:16 upstream 6a8f57ae2eb0 436577a9 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/18 01:59 upstream 6a8f57ae2eb0 436577a9 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/17 23:28 upstream 6a8f57ae2eb0 436577a9 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/17 22:15 upstream 6a8f57ae2eb0 436577a9 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/17 21:14 upstream 6a8f57ae2eb0 436577a9 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/17 20:02 upstream 6a8f57ae2eb0 436577a9 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/17 18:11 upstream 6a8f57ae2eb0 c6ec7083 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/17 14:28 upstream 6a8f57ae2eb0 c6ec7083 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/16 17:11 upstream 3e7bb4f24617 ec410564 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root possible deadlock in tty_port_tty_get
2022/09/30 20:52 upstream 5a77386984b5 5e8ac358 .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2022/09/26 21:59 upstream 3800a713b607 10323ddf .config console log report info ci-qemu-upstream possible deadlock in tty_port_tty_get
2023/04/15 18:43 upstream 7a934f4bd7d6 ec410564 .config console log report info ci-qemu-upstream-386 possible deadlock in tty_port_tty_get
* Struck through repros no longer work on HEAD.