public inbox for [email protected]
 help / color / mirror / Atom feed
* possible deadlock in io_poll_double_wake
@ 2020-08-15 18:09 syzbot
  2020-08-15 18:14 ` syzbot
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: syzbot @ 2020-08-15 18:09 UTC (permalink / raw)
  To: axboe, io-uring, linux-fsdevel, linux-kernel, syzkaller-bugs,
	viro

Hello,

syzbot found the following issue on:

HEAD commit:    c9c9735c Merge tag 'scsi-misc' of git://git.kernel.org/pub..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=127399f6900000
kernel config:  https://syzkaller.appspot.com/x/.config?x=adea84f38e7bc8d
dashboard link: https://syzkaller.appspot.com/bug?extid=0d56cfeec64f045baffc
compiler:       clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81)

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

============================================
WARNING: possible recursive locking detected
5.8.0-syzkaller #0 Not tainted
--------------------------------------------
syz-executor.1/9155 is trying to acquire lock:
ffff8880a1fcc530 (&tty->write_wait){-.-.}-{2:2}, at: spin_lock include/linux/spinlock.h:354 [inline]
ffff8880a1fcc530 (&tty->write_wait){-.-.}-{2:2}, at: io_poll_double_wake+0x108/0x360 fs/io_uring.c:4599

but task is already holding lock:
ffff8880a1fcc530 (&tty->write_wait){-.-.}-{2:2}, at: __wake_up_common_lock kernel/sched/wait.c:122 [inline]
ffff8880a1fcc530 (&tty->write_wait){-.-.}-{2:2}, at: __wake_up+0xb8/0x150 kernel/sched/wait.c:142

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&tty->write_wait);
  lock(&tty->write_wait);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

4 locks held by syz-executor.1/9155:
 #0: ffff8880a1fcc098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref_wait+0x21/0x70 drivers/tty/tty_ldisc.c:267
 #1: ffff8880a1fcc2e8 (&tty->termios_rwsem){++++}-{3:3}, at: tty_set_termios+0xc5/0x1510 drivers/tty/tty_ioctl.c:328
 #2: ffff8880a1fcc098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref+0x18/0x80 drivers/tty/tty_ldisc.c:288
 #3: ffff8880a1fcc530 (&tty->write_wait){-.-.}-{2:2}, at: __wake_up_common_lock kernel/sched/wait.c:122 [inline]
 #3: ffff8880a1fcc530 (&tty->write_wait){-.-.}-{2:2}, at: __wake_up+0xb8/0x150 kernel/sched/wait.c:142

stack backtrace:
CPU: 0 PID: 9155 Comm: syz-executor.1 Not tainted 5.8.0-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_deadlock_bug kernel/locking/lockdep.c:2391 [inline]
 check_deadlock kernel/locking/lockdep.c:2432 [inline]
 validate_chain+0x69a4/0x88a0 kernel/locking/lockdep.c:3202
 __lock_acquire+0x1161/0x2ab0 kernel/locking/lockdep.c:4426
 lock_acquire+0x160/0x730 kernel/locking/lockdep.c:5005
 __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
 _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:151
 spin_lock include/linux/spinlock.h:354 [inline]
 io_poll_double_wake+0x108/0x360 fs/io_uring.c:4599
 __wake_up_common+0x30a/0x4e0 kernel/sched/wait.c:93
 __wake_up_common_lock kernel/sched/wait.c:123 [inline]
 __wake_up+0xd4/0x150 kernel/sched/wait.c:142
 n_tty_set_termios+0xa60/0x1080 drivers/tty/n_tty.c:1874
 tty_set_termios+0xcac/0x1510 drivers/tty/tty_ioctl.c:341
 set_termios+0x4a1/0x580 drivers/tty/tty_ioctl.c:414
 tty_mode_ioctl+0x7b2/0xa80 drivers/tty/tty_ioctl.c:770
 tty_ioctl+0xf81/0x15c0 drivers/tty/tty_io.c:2665
 vfs_ioctl fs/ioctl.c:48 [inline]
 __do_sys_ioctl fs/ioctl.c:753 [inline]
 __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:739
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x45d239
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:00007f063db5fc78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000017cc0 RCX: 000000000045d239
RDX: 0000000020000000 RSI: 0000000000005404 RDI: 0000000000000003
RBP: 000000000118cf80 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000118cf4c
R13: 00007ffc7ff6341f R14: 00007f063db609c0 R15: 000000000118cf4c


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

^ permalink raw reply	[flat|nested] 9+ messages in thread
* possible deadlock in io_poll_double_wake
@ 2021-10-14  2:45 Hao Sun
  0 siblings, 0 replies; 9+ messages in thread
From: Hao Sun @ 2021-10-14  2:45 UTC (permalink / raw)
  To: Pavel Begunkov, Jens Axboe, io-uring; +Cc: Linux Kernel Mailing List

Hello,

When using Healer to fuzz the latest Linux kernel, the following crash
was triggered.

HEAD commit: 64570fbc14f8 Linux 5.15-rc5
git tree: upstream
console output:
https://drive.google.com/file/d/1vA465O1bvHG4dfD07CNI-lcjbFYaD-nK/view?usp=sharing
kernel config: https://drive.google.com/file/d/1em3xgUIMNN_-LUUdySzwN-UDPc3qiiKD/view?usp=sharing
C reproducer: https://drive.google.com/file/d/13EMtDAujxvvBRb3m1gV1zXsp4gkRFJSS/view?usp=sharing
Syzlang reproducer:
https://drive.google.com/file/d/1dFk5ujvk-lnr_KzNGboFm9fvwYdETowv/view?usp=sharing

If you fix this issue, please add the following tag to the commit:
Reported-by: Hao Sun <[email protected]>

============================================
WARNING: possible recursive locking detected
5.15.0-rc5 #3 Not tainted
--------------------------------------------
swapper/0/0 is trying to acquire lock:
ffff88810f5cd130 (&runtime->sleep){..-.}-{2:2}, at:
io_poll_double_wake+0x2be/0x800 fs/io_uring.c:5418

but task is already holding lock:
ffff88810f5cf130 (&runtime->sleep){..-.}-{2:2}, at:
__wake_up_common_lock+0xb4/0x130 kernel/sched/wait.c:137

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&runtime->sleep);
  lock(&runtime->sleep);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

3 locks held by swapper/0/0:
 #0: ffffc90000007d68 ((&dpcm->timer)){+.-.}-{0:0}, at:
lockdep_copy_map include/linux/lockdep.h:35 [inline]
 #0: ffffc90000007d68 ((&dpcm->timer)){+.-.}-{0:0}, at:
call_timer_fn+0xd5/0x6b0 kernel/time/timer.c:1411
 #1: ffff888100fc6108 (&group->lock){..-.}-{2:2}, at:
_snd_pcm_stream_lock_irqsave+0x9f/0xd0 sound/core/pcm_native.c:170
 #2: ffff88810f5cf130 (&runtime->sleep){..-.}-{2:2}, at:
__wake_up_common_lock+0xb4/0x130 kernel/sched/wait.c:137

stack backtrace:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.15.0-rc5 #3
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.13.0-1ubuntu1.1 04/01/2014
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_deadlock_bug kernel/locking/lockdep.c:2944 [inline]
 check_deadlock kernel/locking/lockdep.c:2987 [inline]
 validate_chain kernel/locking/lockdep.c:3776 [inline]
 __lock_acquire.cold+0x168/0x3c3 kernel/locking/lockdep.c:5015
 lock_acquire kernel/locking/lockdep.c:5625 [inline]
 lock_acquire+0x1ab/0x520 kernel/locking/lockdep.c:5590
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0x39/0x50 kernel/locking/spinlock.c:162
 io_poll_double_wake+0x2be/0x800 fs/io_uring.c:5418
 __wake_up_common+0x147/0x650 kernel/sched/wait.c:108
 __wake_up_common_lock+0xd0/0x130 kernel/sched/wait.c:138
 snd_pcm_update_state+0x3d4/0x540 sound/core/pcm_lib.c:203
 snd_pcm_update_hw_ptr0+0xe79/0x2090 sound/core/pcm_lib.c:464
 snd_pcm_period_elapsed_under_stream_lock+0x15a/0x230 sound/core/pcm_lib.c:1816
 snd_pcm_period_elapsed+0x28/0x50 sound/core/pcm_lib.c:1848
 loopback_jiffies_timer_function+0x1eb/0x270 sound/drivers/aloop.c:668
 call_timer_fn+0x1a5/0x6b0 kernel/time/timer.c:1421
 expire_timers kernel/time/timer.c:1466 [inline]
 __run_timers.part.0+0x6b0/0xa90 kernel/time/timer.c:1734
 __run_timers kernel/time/timer.c:1715 [inline]
 run_timer_softirq+0xb6/0x1d0 kernel/time/timer.c:1747
 __do_softirq+0x1d7/0x93b kernel/softirq.c:558
 invoke_softirq kernel/softirq.c:432 [inline]
 __irq_exit_rcu kernel/softirq.c:636 [inline]
 irq_exit_rcu+0xf2/0x130 kernel/softirq.c:648
 sysvec_apic_timer_interrupt+0x93/0xc0 arch/x86/kernel/apic/apic.c:1097
 </IRQ>
 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:638
RIP: 0010:default_idle+0xb/0x10 arch/x86/kernel/process.c:717
Code: 1b 51 88 f8 e9 6f fe ff ff e8 11 51 88 f8 e9 3d fe ff ff e8 17
31 fd ff cc cc cc cc cc cc cc eb 07 0f 00 2d 47 99 50 00 fb f4 <c3> 0f
1f 40 00 41 54 be 08 00 00 00 53 65 48 8b 1c 25 40 f0 01 00
RSP: 0018:ffffffff8b607e28 EFLAGS: 00000206
RAX: 00000000001543c3 RBX: 0000000000000000 RCX: ffffffff8932d572
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000001 R09: ffffed100c7c6542
R10: ffff888063e32a0b R11: ffffed100c7c6541 R12: 0000000000000000
R13: 0000000000000000 R14: ffffffff8d6d8590 R15: 0000000000000000
 default_idle_call+0xc4/0x420 kernel/sched/idle.c:112
 cpuidle_idle_call kernel/sched/idle.c:194 [inline]
 do_idle+0x3f9/0x570 kernel/sched/idle.c:306
 cpu_startup_entry+0x14/0x20 kernel/sched/idle.c:403
 start_kernel+0x47a/0x49b init/main.c:1141
 secondary_startup_64_no_verify+0xb0/0xbb
----------------
Code disassembly (best guess):
   0: 1b 51 88              sbb    -0x78(%rcx),%edx
   3: f8                    clc
   4: e9 6f fe ff ff        jmpq   0xfffffe78
   9: e8 11 51 88 f8        callq  0xf888511f
   e: e9 3d fe ff ff        jmpq   0xfffffe50
  13: e8 17 31 fd ff        callq  0xfffd312f
  18: cc                    int3
  19: cc                    int3
  1a: cc                    int3
  1b: cc                    int3
  1c: cc                    int3
  1d: cc                    int3
  1e: cc                    int3
  1f: eb 07                jmp    0x28
  21: 0f 00 2d 47 99 50 00 verw   0x509947(%rip)        # 0x50996f
  28: fb                    sti
  29: f4                    hlt
* 2a: c3                    retq <-- trapping instruction
  2b: 0f 1f 40 00          nopl   0x0(%rax)
  2f: 41 54                push   %r12
  31: be 08 00 00 00        mov    $0x8,%esi
  36: 53                    push   %rbx
  37: 65 48 8b 1c 25 40 f0 mov    %gs:0x1f040,%rbx
  3e: 01 00

^ permalink raw reply	[flat|nested] 9+ messages in thread
* possible deadlock in io_poll_double_wake
@ 2022-08-30 13:33 Jiacheng Xu
  2022-08-30 13:58 ` Jens Axboe
  0 siblings, 1 reply; 9+ messages in thread
From: Jiacheng Xu @ 2022-08-30 13:33 UTC (permalink / raw)
  To: linux-kernel, axboe, asml.silence, Qiang.Zhang; +Cc: io-uring

Hello,

When using modified Syzkaller to fuzz the Linux kernel-5.19, the
following crash was triggered. Though the issue seems to get fixed on
syzbot(https://syzkaller.appspot.com/bug?id=12e4415bf5272f433acefa690478208f3be3be2d),
it could still be triggered with the following repro.
We would appreciate a CVE ID if this is a security issue.

HEAD commit: 568035b01cfb Linux-5.15.58
git tree: upstream

console output:
https://drive.google.com/file/d/1e4DHaUKhY9DLZJK_pNScWHydUv-MaD9_/view?usp=sharing
https://drive.google.com/file/d/1NmOGWcfPnY2kSrS0nOwvG1AZ923jFQ3p/view?usp=sharing
kernel config: https://drive.google.com/file/d/1wgIUDwP5ho29AM-K7HhysSTfWFpfXYkG/view?usp=sharing
syz repro: https://drive.google.com/file/d/1e5xY8AOMimLbpAlOOupmGYC_tUA3sa8k/view?usp=sharing
C reproducer: https://drive.google.com/file/d/1esAe__18Lt7and43QdXFfI6GJCsF85_z/view?usp=sharing

Description:
spin_lock_irqsave() in __wake_up_common_lock() is called before waking
up a task. However, spin_lock_irqsave() has to be called once in
io_poll_double_wake().
such call stack is:

   snd_pcm_post_stop()
      __wake_up_common_lock()
         spin_lock_irqsave()
             io_poll_double_wake()
                 spin_lock_irqsave()

Environment:
Ubuntu 20.04 on Linux 5.4.0
QEMU 4.2.1:
qemu-system-x86_64 \
  -m 2G \
  -smp 2 \
  -kernel /home/workdir/bzImage \
  -append "console=ttyS0 root=/dev/sda earlyprintk=serial net.ifnames=0" \
  -drive file=/home/workdir/stretch.img,format=raw \
  -net user,host=10.0.2.10,hostfwd=tcp:127.0.0.1:10021-:22 \
  -net nic,model=e1000 \
  -enable-kvm \
  -nographic \
  -pidfile vm.pid \
  2>&1 | tee vm.log

If you fix this issue, please add the following tag to the commit:
Reported-by Jiacheng Xu<[email protected]>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-08-30 13:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-15 18:09 possible deadlock in io_poll_double_wake syzbot
2020-08-15 18:14 ` syzbot
2020-08-15 18:14 ` Jens Axboe
2020-08-15 18:15   ` syzbot
2020-08-15 18:15   ` syzbot
2020-08-15 18:15 ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2021-10-14  2:45 Hao Sun
2022-08-30 13:33 Jiacheng Xu
2022-08-30 13:58 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox