syzbot


possible deadlock in __queue_work

Status: auto-closed as invalid on 2020/10/15 10:06
Reported-by: syzbot+961bc330f3ee15812d2c@syzkaller.appspotmail.com
First crash: 850d, last: 742d
similar bugs (4):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 possible deadlock in __queue_work (2) 1 375d 375d 0/1 auto-closed as invalid on 2021/10/17 12:42
linux-4.19 possible deadlock in __queue_work 3 685d 780d 0/1 auto-closed as invalid on 2020/12/11 19:10
upstream possible deadlock in __queue_work (2) 16 123d 122d 0/22 closed as invalid on 2022/02/27 14:14
upstream possible deadlock in __queue_work 2 369d 428d 22/22 fixed on 2021/11/10 00:50

Sample crash report:
audit: type=1800 audit(1592388337.164:90): pid=31524 uid=0 auid=0 ses=4 subj=system_u:system_r:kernel_t:s0 op="collect_data" cause="failed(directio)" comm="syz-executor.5" name="file0" dev="sda1" ino=16119 res=0
======================================================
WARNING: possible circular locking dependency detected
4.14.184-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.5/31539 is trying to acquire lock:
 (&pool->lock/1){..-.}, at: [<ffffffff813ad654>] spin_lock include/linux/spinlock.h:317 [inline]
 (&pool->lock/1){..-.}, at: [<ffffffff813ad654>] __queue_work+0x174/0xf70 kernel/workqueue.c:1421

but task is already holding lock:
 (&(&port->lock)->rlock){-.-.}, at: [<ffffffff833c899b>] pty_write+0xdb/0x1c0 drivers/tty/pty.c:120

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #4 (&(&port->lock)->rlock){-.-.}:
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0x8c/0xc0 kernel/locking/spinlock.c:160
       tty_port_tty_get+0x1d/0x80 drivers/tty/tty_port.c:288
       tty_port_default_wakeup+0x11/0x40 drivers/tty/tty_port.c:46
       serial8250_tx_chars+0x400/0x9f0 drivers/tty/serial/8250/8250_port.c:1810
       serial8250_handle_irq.part.0+0x1f8/0x240 drivers/tty/serial/8250/8250_port.c:1883
       serial8250_handle_irq drivers/tty/serial/8250/8250_port.c:1869 [inline]
       serial8250_default_handle_irq+0x96/0x110 drivers/tty/serial/8250/8250_port.c:1899
       serial8250_interrupt+0xe4/0x1a0 drivers/tty/serial/8250/8250_core.c:129
       __handle_irq_event_percpu+0xee/0x7f0 kernel/irq/handle.c:147
       handle_irq_event_percpu+0x66/0x120 kernel/irq/handle.c:187
       handle_irq_event+0xa2/0x12d kernel/irq/handle.c:204
       handle_edge_irq+0x215/0x810 kernel/irq/chip.c:770
       generic_handle_irq_desc include/linux/irqdesc.h:159 [inline]
       handle_irq+0x35/0x50 arch/x86/kernel/irq_64.c:87
       do_IRQ+0x93/0x1d0 arch/x86/kernel/irq.c:230
       ret_from_intr+0x0/0x1e
       native_safe_halt+0xe/0x10 arch/x86/include/asm/irqflags.h:60
       arch_safe_halt arch/x86/include/asm/paravirt.h:94 [inline]
       default_idle+0x47/0x370 arch/x86/kernel/process.c:566
       cpuidle_idle_call kernel/sched/idle.c:156 [inline]
       do_idle+0x250/0x3c0 kernel/sched/idle.c:246
       cpu_startup_entry+0x14/0x20 kernel/sched/idle.c:351
       start_kernel+0x751/0x771 init/main.c:708
       secondary_startup_64+0xa5/0xb0 arch/x86/kernel/head_64.S:240

-> #3 (&port_lock_key){-.-.}:
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0x8c/0xc0 kernel/locking/spinlock.c:160
       serial8250_console_write+0x6ea/0x8e0 drivers/tty/serial/8250/8250_port.c:3236
       call_console_drivers kernel/printk/printk.c:1725 [inline]
       console_unlock+0x985/0xee0 kernel/printk/printk.c:2397
       vprintk_emit+0x3b8/0x600 kernel/printk/printk.c:1923
       vprintk_func+0x58/0x152 kernel/printk/printk_safe.c:401
       printk+0x9e/0xbc kernel/printk/printk.c:1996
       register_console+0x6ef/0xac0 kernel/printk/printk.c:2716
       univ8250_console_init+0x2f/0x3a drivers/tty/serial/8250/8250_core.c:691
       console_init+0x46/0x53 kernel/printk/printk.c:2797
       start_kernel+0x52f/0x771 init/main.c:634
       secondary_startup_64+0xa5/0xb0 arch/x86/kernel/head_64.S:240

-> #2 (console_owner){-.-.}:
       console_lock_spinning_enable kernel/printk/printk.c:1588 [inline]
       console_unlock+0x36c/0xee0 kernel/printk/printk.c:2394
       vprintk_emit+0x3b8/0x600 kernel/printk/printk.c:1923
       vprintk_func+0x58/0x152 kernel/printk/printk_safe.c:401
       printk+0x9e/0xbc kernel/printk/printk.c:1996
       fail_dump lib/fault-inject.c:44 [inline]
       should_fail.cold+0xdf/0x154 lib/fault-inject.c:149
       should_failslab+0xd6/0x130 mm/failslab.c:32
       slab_pre_alloc_hook mm/slab.h:421 [inline]
       slab_alloc mm/slab.c:3376 [inline]
       kmem_cache_alloc+0x40/0x3c0 mm/slab.c:3550
       kmem_cache_zalloc include/linux/slab.h:651 [inline]
       fill_pool lib/debugobjects.c:110 [inline]
       __debug_object_init+0x57d/0x7a0 lib/debugobjects.c:341
       __init_work kernel/workqueue.c:504 [inline]
       insert_wq_barrier kernel/workqueue.c:2500 [inline]
       start_flush_work kernel/workqueue.c:2848 [inline]
       flush_work+0x1f7/0x780 kernel/workqueue.c:2892
       snd_seq_client_use_ptr+0x2aa/0x330 sound/core/seq/seq_clientmgr.c:164
       snd_seq_info_clients_read+0x146/0x705 sound/core/seq/seq_clientmgr.c:2466
       snd_info_seq_show+0xc5/0x110 sound/core/info.c:378
       seq_read+0x4d2/0x1130 fs/seq_file.c:237
       proc_reg_read+0xf2/0x160 fs/proc/inode.c:217
       do_loop_readv_writev fs/read_write.c:695 [inline]
       do_loop_readv_writev fs/read_write.c:682 [inline]
       do_iter_read+0x3e3/0x5a0 fs/read_write.c:919
       vfs_readv+0xd3/0x130 fs/read_write.c:981
       do_preadv+0x161/0x200 fs/read_write.c:1065
       do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x46/0xbb

-> #1 (&(&pool->lock)->rlock){-.-.}:
       __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
       _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:152
       spin_lock include/linux/spinlock.h:317 [inline]
       __queue_work+0x174/0xf70 kernel/workqueue.c:1421
       queue_work_on+0x159/0x1d0 kernel/workqueue.c:1490
       queue_work include/linux/workqueue.h:491 [inline]
       schedule_work include/linux/workqueue.h:549 [inline]
       put_pwq kernel/workqueue.c:1092 [inline]
       put_pwq+0x129/0x180 kernel/workqueue.c:1077
       put_pwq_unlocked.part.0+0x30/0x70 kernel/workqueue.c:1109
       put_pwq_unlocked kernel/workqueue.c:1103 [inline]
       destroy_workqueue+0x570/0x660 kernel/workqueue.c:4173
       do_floppy_init drivers/block/floppy.c:4732 [inline]
       floppy_async_init+0x1ba8/0x1cf3 drivers/block/floppy.c:4749
       async_run_entry_fn+0x102/0x4c0 kernel/async.c:127
       process_one_work+0x7c0/0x14c0 kernel/workqueue.c:2116
       worker_thread+0x5d7/0x1080 kernel/workqueue.c:2250
       kthread+0x30d/0x420 kernel/kthread.c:232
       ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

-> #0 (&pool->lock/1){..-.}:
       lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
       __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
       _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:152
       spin_lock include/linux/spinlock.h:317 [inline]
       __queue_work+0x174/0xf70 kernel/workqueue.c:1421
       queue_work_on+0x159/0x1d0 kernel/workqueue.c:1490
       pty_write+0x173/0x1c0 drivers/tty/pty.c:125
       tty_put_char+0xfe/0x120 drivers/tty/tty_io.c:2880
       do_output_char+0x126/0x750 drivers/tty/n_tty.c:488
       __process_echoes+0x313/0x8c0 drivers/tty/n_tty.c:739
       flush_echoes drivers/tty/n_tty.c:829 [inline]
       __receive_buf drivers/tty/n_tty.c:1648 [inline]
       n_tty_receive_buf_common+0x940/0x2490 drivers/tty/n_tty.c:1742
       tiocsti drivers/tty/tty_io.c:2186 [inline]
       tty_ioctl+0xd5f/0x1220 drivers/tty/tty_io.c:2572
       vfs_ioctl fs/ioctl.c:46 [inline]
       file_ioctl fs/ioctl.c:500 [inline]
       do_vfs_ioctl+0x75a/0xfe0 fs/ioctl.c:684
       SYSC_ioctl fs/ioctl.c:701 [inline]
       SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
       do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x46/0xbb

other info that might help us debug this:

Chain exists of:
  &pool->lock/1 --> &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(&pool->lock/1);

 *** DEADLOCK ***

4 locks held by syz-executor.5/31539:
 #0:  (&tty->ldisc_sem){++++}, at: [<ffffffff833bd922>] tty_ldisc_ref_wait+0x22/0x80 drivers/tty/tty_ldisc.c:284
 #1:  (&o_tty->termios_rwsem/1){++++}, at: [<ffffffff833b63f1>] n_tty_receive_buf_common+0x81/0x2490 drivers/tty/n_tty.c:1705
 #2:  (&ldata->output_lock){+.+.}, at: [<ffffffff833b6c72>] flush_echoes drivers/tty/n_tty.c:827 [inline]
 #2:  (&ldata->output_lock){+.+.}, at: [<ffffffff833b6c72>] __receive_buf drivers/tty/n_tty.c:1648 [inline]
 #2:  (&ldata->output_lock){+.+.}, at: [<ffffffff833b6c72>] n_tty_receive_buf_common+0x902/0x2490 drivers/tty/n_tty.c:1742
 #3:  (&(&port->lock)->rlock){-.-.}, at: [<ffffffff833c899b>] pty_write+0xdb/0x1c0 drivers/tty/pty.c:120

stack backtrace:
CPU: 1 PID: 31539 Comm: syz-executor.5 Not tainted 4.14.184-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x1b2/0x283 lib/dump_stack.c:58
 print_circular_bug.isra.0.cold+0x2dc/0x425 kernel/locking/lockdep.c:1258
 check_prev_add kernel/locking/lockdep.c:1905 [inline]
 check_prevs_add kernel/locking/lockdep.c:2022 [inline]
 validate_chain kernel/locking/lockdep.c:2464 [inline]
 __lock_acquire+0x3057/0x42a0 kernel/locking/lockdep.c:3491
 lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
 __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
 _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:152
 spin_lock include/linux/spinlock.h:317 [inline]
 __queue_work+0x174/0xf70 kernel/workqueue.c:1421
 queue_work_on+0x159/0x1d0 kernel/workqueue.c:1490
 pty_write+0x173/0x1c0 drivers/tty/pty.c:125
 tty_put_char+0xfe/0x120 drivers/tty/tty_io.c:2880
 do_output_char+0x126/0x750 drivers/tty/n_tty.c:488
 __process_echoes+0x313/0x8c0 drivers/tty/n_tty.c:739
 flush_echoes drivers/tty/n_tty.c:829 [inline]
 __receive_buf drivers/tty/n_tty.c:1648 [inline]
 n_tty_receive_buf_common+0x940/0x2490 drivers/tty/n_tty.c:1742
 tiocsti drivers/tty/tty_io.c:2186 [inline]
 tty_ioctl+0xd5f/0x1220 drivers/tty/tty_io.c:2572
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x75a/0xfe0 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x45ca59
RSP: 002b:00007f18d87a3c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000004ee9e0 RCX: 000000000045ca59
RDX: 0000000020000000 RSI: 0000000000005412 RDI: 0000000000000007
RBP: 000000000078bf00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 0000000000000560 R14: 00000000004c818d R15: 00007f18d87a46d4
netlink: 24 bytes leftover after parsing attributes in process `syz-executor.5'.
netlink: 24 bytes leftover after parsing attributes in process `syz-executor.5'.
netlink: 24 bytes leftover after parsing attributes in process `syz-executor.5'.
netlink: 24 bytes leftover after parsing attributes in process `syz-executor.5'.
netlink: 24 bytes leftover after parsing attributes in process `syz-executor.5'.
netlink: 24 bytes leftover after parsing attributes in process `syz-executor.5'.
netlink: 24 bytes leftover after parsing attributes in process `syz-executor.5'.

Crashes (7):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-linux-4-14 2020/06/17 10:05 linux-4.14.y b850307b279c b9f3810b .config log report
ci2-linux-4-14 2020/05/26 20:08 linux-4.14.y a41ba30d9df2 9072c126 .config log report
ci2-linux-4-14 2020/05/23 20:27 linux-4.14.y a41ba30d9df2 4afdfa20 .config log report
ci2-linux-4-14 2020/05/15 08:31 linux-4.14.y ab9dfda23248 2d572622 .config log report
ci2-linux-4-14 2020/05/15 04:46 linux-4.14.y ab9dfda23248 2d572622 .config log report
ci2-linux-4-14 2020/04/04 07:57 linux-4.14.y 4520f06b03ae ef26b610 .config log report
ci2-linux-4-14 2020/03/01 03:19 linux-4.14.y 78d697fc93f9 c88c7b75 .config log report