syzbot


possible deadlock in blkcg_deactivate_policy

Status: upstream: reported C repro on 2022/04/15 18:29
Reported-by: syzbot+b9e4c31d0a1efb34cb03@syzkaller.appspotmail.com
First crash: 171d, last: 1d17h

Cause bisection: introduced by (bisect log) :
commit 0a9a25ca78437b39e691bcc3dc8240455b803d8d
Author: Ming Lei <ming.lei@redhat.com>
Date: Fri Mar 18 13:01:43 2022 +0000

  block: let blkcg_gq grab request queue's refcnt

Crash: BUG: sleeping function called from invalid context in blk_release_queue (log)
Repro: C syz .config
Patch testing requests:
Created Duration User Patch Repo Result
2022/04/15 23:40 11m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/ b9b4c79e5830 OK

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.0.0-rc7-syzkaller-00029-g3800a713b607 #0 Not tainted
------------------------------------------------------
syz-executor478/7002 is trying to acquire lock:
ffff8880254480a8 ((&sq->pending_timer)){+.-.}-{0:0}, at: del_timer_sync+0x33/0x1b0 kernel/time/timer.c:1416

but task is already holding lock:
ffffffff91345550 (&blkcg->lock){....}-{2:2}, at: spin_lock include/linux/spinlock.h:349 [inline]
ffffffff91345550 (&blkcg->lock){....}-{2:2}, at: blkcg_deactivate_policy block/blk-cgroup.c:1519 [inline]
ffffffff91345550 (&blkcg->lock){....}-{2:2}, at: blkcg_deactivate_policy+0x181/0x470 block/blk-cgroup.c:1501

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&blkcg->lock){....}-{2:2}:
       __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
       _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:154
       spin_lock include/linux/spinlock.h:349 [inline]
       blkg_create+0x461/0x1020 block/blk-cgroup.c:344
       blkcg_init_queue+0xb2/0x620 block/blk-cgroup.c:1285
       __alloc_disk_node+0x29d/0x650 block/genhd.c:1367
       __blk_alloc_disk+0x35/0x90 block/genhd.c:1406
       brd_alloc.part.0+0x27f/0x7a0 drivers/block/brd.c:391
       brd_alloc drivers/block/brd.c:374 [inline]
       brd_init+0x1b8/0x24b drivers/block/brd.c:477
       do_one_initcall+0xfe/0x650 init/main.c:1296
       do_initcall_level init/main.c:1369 [inline]
       do_initcalls init/main.c:1385 [inline]
       do_basic_setup init/main.c:1404 [inline]
       kernel_init_freeable+0x6b1/0x73a init/main.c:1623
       kernel_init+0x1a/0x1d0 init/main.c:1512
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

-> #1 (&q->queue_lock){..-.}-{2:2}:
       __raw_spin_lock_irq include/linux/spinlock_api_smp.h:119 [inline]
       _raw_spin_lock_irq+0x32/0x50 kernel/locking/spinlock.c:170
       spin_lock_irq include/linux/spinlock.h:374 [inline]
       throtl_pending_timer_fn+0xf7/0x1690 block/blk-throttle.c:1152
       call_timer_fn+0x1a0/0x6b0 kernel/time/timer.c:1474
       expire_timers kernel/time/timer.c:1519 [inline]
       __run_timers.part.0+0x674/0xa80 kernel/time/timer.c:1790
       __run_timers kernel/time/timer.c:1768 [inline]
       run_timer_softirq+0xb3/0x1d0 kernel/time/timer.c:1803
       __do_softirq+0x1d3/0x9c6 kernel/softirq.c:571
       invoke_softirq kernel/softirq.c:445 [inline]
       __irq_exit_rcu+0x123/0x180 kernel/softirq.c:650
       irq_exit_rcu+0x5/0x20 kernel/softirq.c:662
       sysvec_apic_timer_interrupt+0x93/0xc0 arch/x86/kernel/apic/apic.c:1106
       asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:649
       lock_acquire+0x1ef/0x570 kernel/locking/lockdep.c:5634
       rcu_lock_acquire include/linux/rcupdate.h:280 [inline]
       rcu_read_lock include/linux/rcupdate.h:706 [inline]
       do_notify_parent_cldstop+0x179/0xa40 kernel/signal.c:2159
       ptrace_stop.part.0+0x834/0xa80 kernel/signal.c:2293
       ptrace_stop kernel/signal.c:2232 [inline]
       ptrace_do_notify+0x215/0x2b0 kernel/signal.c:2344
       ptrace_notify+0xc4/0x140 kernel/signal.c:2356
       ptrace_report_syscall include/linux/ptrace.h:420 [inline]
       ptrace_report_syscall_entry include/linux/ptrace.h:457 [inline]
       syscall_trace_enter.constprop.0+0xb0/0x240 kernel/entry/common.c:63
       do_syscall_64+0x16/0xb0 arch/x86/entry/common.c:76
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 ((&sq->pending_timer)){+.-.}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3095 [inline]
       check_prevs_add kernel/locking/lockdep.c:3214 [inline]
       validate_chain kernel/locking/lockdep.c:3829 [inline]
       __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5053
       lock_acquire kernel/locking/lockdep.c:5666 [inline]
       lock_acquire+0x1ab/0x570 kernel/locking/lockdep.c:5631
       del_timer_sync+0x5b/0x1b0 kernel/time/timer.c:1417
       throtl_pd_free+0x15/0x40 block/blk-throttle.c:500
       blkcg_deactivate_policy block/blk-cgroup.c:1523 [inline]
       blkcg_deactivate_policy+0x26c/0x470 block/blk-cgroup.c:1501
       blk_throtl_exit+0x8a/0x1a0 block/blk-throttle.c:2337
       blkcg_init_queue+0x19b/0x620 block/blk-cgroup.c:1304
       __alloc_disk_node+0x29d/0x650 block/genhd.c:1367
       __blk_mq_alloc_disk+0x13b/0x1f0 block/blk-mq.c:3942
       loop_add+0x3e2/0xaf0 drivers/block/loop.c:1983
       loop_control_ioctl+0x133/0x620 drivers/block/loop.c:2155
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:870 [inline]
       __se_sys_ioctl fs/ioctl.c:856 [inline]
       __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/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:
  (&sq->pending_timer) --> &q->queue_lock --> &blkcg->lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&blkcg->lock);
                               lock(&q->queue_lock);
                               lock(&blkcg->lock);
  lock((&sq->pending_timer));

 *** DEADLOCK ***

2 locks held by syz-executor478/7002:
 #0: ffff88807bc63888 (&q->queue_lock){..-.}-{2:2}, at: spin_lock_irq include/linux/spinlock.h:374 [inline]
 #0: ffff88807bc63888 (&q->queue_lock){..-.}-{2:2}, at: blkcg_deactivate_policy block/blk-cgroup.c:1512 [inline]
 #0: ffff88807bc63888 (&q->queue_lock){..-.}-{2:2}, at: blkcg_deactivate_policy+0x9b/0x470 block/blk-cgroup.c:1501
 #1: ffffffff91345550 (&blkcg->lock){....}-{2:2}, at: spin_lock include/linux/spinlock.h:349 [inline]
 #1: ffffffff91345550 (&blkcg->lock){....}-{2:2}, at: blkcg_deactivate_policy block/blk-cgroup.c:1519 [inline]
 #1: ffffffff91345550 (&blkcg->lock){....}-{2:2}, at: blkcg_deactivate_policy+0x181/0x470 block/blk-cgroup.c:1501

stack backtrace:
CPU: 0 PID: 7002 Comm: syz-executor478 Not tainted 6.0.0-rc7-syzkaller-00029-g3800a713b607 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2175
 check_prev_add kernel/locking/lockdep.c:3095 [inline]
 check_prevs_add kernel/locking/lockdep.c:3214 [inline]
 validate_chain kernel/locking/lockdep.c:3829 [inline]
 __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5053
 lock_acquire kernel/locking/lockdep.c:5666 [inline]
 lock_acquire+0x1ab/0x570 kernel/locking/lockdep.c:5631
 del_timer_sync+0x5b/0x1b0 kernel/time/timer.c:1417
 throtl_pd_free+0x15/0x40 block/blk-throttle.c:500
 blkcg_deactivate_policy block/blk-cgroup.c:1523 [inline]
 blkcg_deactivate_policy+0x26c/0x470 block/blk-cgroup.c:1501
 blk_throtl_exit+0x8a/0x1a0 block/blk-throttle.c:2337
 blkcg_init_queue+0x19b/0x620 block/blk-cgroup.c:1304
 __alloc_disk_node+0x29d/0x650 block/genhd.c:1367
 __blk_mq_alloc_disk+0x13b/0x1f0 block/blk-mq.c:3942
 loop_add+0x3e2/0xaf0 drivers/block/loop.c:1983
 loop_control_ioctl+0x133/0x620 drivers/block/loop.c:2155
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl fs/ioctl.c:856 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f91bde18069
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 b1 14 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:00007ffebac2ccb8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007f91bde18069
RDX: 0000000000000000 RSI: 0000000000004c80 RDI: 0000000000000003
RBP: 00007ffebac2ccd0 R08: 0000000000000002 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000004
R13: 431bde82d7b634db R14: 0000000000000000 R15: 0000000000000000
 </TASK>

Crashes (62):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-selinux-root 2022/09/27 08:18 upstream 3800a713b607 10323ddf .config log report syz C possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-smack-root 2022/09/23 03:46 upstream dc164f4fb00a 0042f2b4 .config log report syz C possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-selinux-root 2022/09/22 06:35 upstream 06f7db949993 60af5050 .config log report syz C possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce 2022/08/14 23:09 upstream 7ebfc85e2cd7 8dfcaa3d .config log report syz C possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-smack-root 2022/08/08 03:58 upstream 200e340f2196 88e3a122 .config log report syz C possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-root 2022/07/10 11:50 upstream b1c428b6c368 b5765a15 .config log report syz C possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-root 2022/07/07 05:44 upstream 9f09069cde34 bff65f44 .config log report syz C possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-root 2022/06/21 12:07 upstream 78ca55889a54 0fc5c330 .config log report syz C possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce 2022/04/15 00:47 upstream b9b4c79e5830 b17b2923 .config log report syz C possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-386 2022/10/02 03:22 upstream b357fd1c2afc feb56351 .config log report syz C possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-386 2022/07/01 12:03 upstream 1a0e93df1e10 1434eec0 .config log report syz C possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-386 2022/06/28 06:19 upstream 03c765b0e3b4 ef82eb2c .config log report syz C possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-386 2022/04/15 05:05 upstream b9b4c79e5830 b17b2923 .config log report syz C possible deadlock in blkcg_deactivate_policy
ci-upstream-linux-next-kasan-gce-root 2022/08/17 21:55 linux-next 95d10484d66e 4e72d229 .config log report syz C possible deadlock in blkcg_deactivate_policy
ci-upstream-linux-next-kasan-gce-root 2022/07/31 00:23 linux-next cb71b93c2dc3 fef302b1 .config log report syz C possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-smack-root 2022/08/30 00:40 upstream b90cb1053190 5b44472d .config log report syz possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-smack-root 2022/08/08 22:50 upstream 200e340f2196 88e3a122 .config log report syz possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-root 2022/07/20 08:05 upstream ca85855bdcae 775344bc .config log report syz possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-386 2022/05/28 08:49 upstream 8291eaafed36 a46af346 .config log report syz possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-386 2022/05/22 03:35 upstream 6c3f5bec9b40 7268fa62 .config log report syz possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-386 2022/04/18 08:48 upstream b2d229d4ddb1 8bcc32a6 .config log report syz possible deadlock in blkcg_deactivate_policy
ci-upstream-linux-next-kasan-gce-root 2022/08/14 09:57 linux-next 6c8f479764eb 8dfcaa3d .config log report syz possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-selinux-root 2022/09/30 02:32 upstream 511cce163b75 1d385642 .config log report info possible deadlock in blkcg_deactivate_policy
ci2-upstream-fs 2022/09/25 05:17 upstream 3db61221f4e8 0042f2b4 .config log report info possible deadlock in blkcg_deactivate_policy
ci2-upstream-fs 2022/09/22 04:40 upstream 06f7db949993 60af5050 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-smack-root 2022/09/21 04:52 upstream 60891ec99e14 c4b8ccfd .config log report info possible deadlock in blkcg_deactivate_policy
ci-qemu-upstream 2022/09/19 03:43 upstream 38eddeedbbea dd9a85ff .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-root 2022/09/05 18:02 upstream 7e18e42e4b28 922294ab .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-root 2022/08/20 22:02 upstream 50cd95ac4654 26a13b38 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-root 2022/08/20 19:13 upstream 50cd95ac4654 26a13b38 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-root 2022/08/19 23:34 upstream 4c2d0b039c5c 26a13b38 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-root 2022/07/17 06:57 upstream c658cabbfd32 95cb00d1 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-smack-root 2022/07/08 00:43 upstream e8a4e1c1bb69 bff65f44 .config log report info possible deadlock in blkcg_deactivate_policy
ci-qemu-upstream 2022/07/05 12:40 upstream c1084b6c5620 bff65f44 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-root 2022/07/02 18:46 upstream 089866061428 1434eec0 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-root 2022/06/26 12:30 upstream 0840a7914caa a371c43c .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-smack-root 2022/06/18 13:24 upstream 4b35035bcf80 8f633d84 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-root 2022/06/15 23:46 upstream 979086f5e006 1719ee24 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-selinux-root 2022/05/29 14:53 upstream 664a393a2663 a46af346 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-root 2022/04/28 23:51 upstream 259b897e5a79 e9076525 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce-root 2022/04/22 22:03 upstream d569e86915b7 131df97d .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce 2022/04/20 07:14 upstream b7f73403a3e9 7d7bc738 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-kasan-gce 2022/04/15 00:30 upstream b9b4c79e5830 b17b2923 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-net-this-kasan-gce 2022/09/02 20:04 net e7506d344bf1 25194605 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-net-this-kasan-gce 2022/08/21 21:15 net e82c649e851c 26a13b38 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-net-this-kasan-gce 2022/06/22 15:59 net 53664d51d351 0fc5c330 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-net-kasan-gce 2022/08/20 21:51 net-next 917edfb98c48 26a13b38 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-net-kasan-gce 2022/08/19 23:03 net-next 268603d79cc4 26a13b38 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-net-kasan-gce 2022/07/21 05:34 net-next 5fb859f79f4f 88cb1383 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-net-kasan-gce 2022/06/30 11:43 net-next 2a832912dba2 1434eec0 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-net-kasan-gce 2022/06/21 21:34 net-next 8720bd951b8e 0fc5c330 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-net-kasan-gce 2022/06/20 18:45 net-next a56b158a5078 8d15e28d .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-linux-next-kasan-gce-root 2022/05/22 22:27 linux-next 18ecd30af1a8 7268fa62 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-gce-arm64 2022/10/01 00:56 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci bbed346d5a96 feb56351 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-gce-arm64 2022/09/28 09:55 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci c194837ebb57 75c78242 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-gce-arm64 2022/09/11 11:45 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci a6b443748715 356d8217 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-gce-arm64 2022/08/31 04:18 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci a41a877bc12d 4a380809 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-gce-arm64 2022/08/27 10:23 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci a41a877bc12d 07177916 .config log report info possible deadlock in blkcg_deactivate_policy
ci-upstream-gce-arm64 2022/08/24 21:08 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci a41a877bc12d 514514f6 .config log report info possible deadlock in blkcg_deactivate_policy
* Struck through repros no longer work on HEAD.