====================================================== WARNING: possible circular locking dependency detected 4.19.211-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.4/15733 is trying to acquire lock: 00000000abfef71a ((wq_completion)"knbd%d-recv"nbd->index){+.+.}, at: flush_workqueue+0xe8/0x13e0 kernel/workqueue.c:2658 but task is already holding lock: 000000009b10c5db (&nbd->config_lock){+.+.}, at: refcount_dec_and_mutex_lock lib/refcount.c:311 [inline] 000000009b10c5db (&nbd->config_lock){+.+.}, at: refcount_dec_and_mutex_lock+0x4a/0x80 lib/refcount.c:306 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #10 (&nbd->config_lock){+.+.}: nbd_open+0x2e2/0x6f0 drivers/block/nbd.c:1428 __blkdev_get+0x372/0x1480 fs/block_dev.c:1494 blkdev_get+0xb0/0x940 fs/block_dev.c:1627 blkdev_open+0x202/0x290 fs/block_dev.c:1788 do_dentry_open+0x4aa/0x1160 fs/open.c:796 do_last fs/namei.c:3421 [inline] path_openat+0x793/0x2df0 fs/namei.c:3537 do_filp_open+0x18c/0x3f0 fs/namei.c:3567 do_sys_open+0x3b3/0x520 fs/open.c:1085 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe -> #9 (nbd_index_mutex){+.+.}: nbd_open+0x73/0x6f0 drivers/block/nbd.c:1415 __blkdev_get+0x372/0x1480 fs/block_dev.c:1494 blkdev_get+0xb0/0x940 fs/block_dev.c:1627 blkdev_open+0x202/0x290 fs/block_dev.c:1788 do_dentry_open+0x4aa/0x1160 fs/open.c:796 do_last fs/namei.c:3421 [inline] path_openat+0x793/0x2df0 fs/namei.c:3537 do_filp_open+0x18c/0x3f0 fs/namei.c:3567 do_sys_open+0x3b3/0x520 fs/open.c:1085 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe -> #8 (&bdev->bd_mutex){+.+.}: blkdev_put+0x30/0x520 fs/block_dev.c:1839 btrfs_close_bdev fs/btrfs/volumes.c:1033 [inline] btrfs_close_one_device fs/btrfs/volumes.c:1057 [inline] close_fs_devices.part.0+0x24d/0x8e0 fs/btrfs/volumes.c:1085 close_fs_devices fs/btrfs/volumes.c:1117 [inline] btrfs_close_devices+0x95/0x1f0 fs/btrfs/volumes.c:1103 close_ctree+0x3c8/0x850 fs/btrfs/disk-io.c:4047 generic_shutdown_super+0x144/0x370 fs/super.c:456 kill_anon_super+0x36/0x60 fs/super.c:1032 btrfs_kill_super+0x49/0x550 fs/btrfs/super.c:2221 deactivate_locked_super+0x94/0x160 fs/super.c:329 deactivate_super+0x174/0x1a0 fs/super.c:360 cleanup_mnt+0x1a8/0x290 fs/namespace.c:1098 task_work_run+0x148/0x1c0 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:193 [inline] exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167 prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline] syscall_return_slowpath arch/x86/entry/common.c:271 [inline] do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296 entry_SYSCALL_64_after_hwframe+0x49/0xbe -> #7 (&fs_devs->device_list_mutex){+.+.}: btrfs_run_dev_stats+0xbb/0xa80 fs/btrfs/volumes.c:7111 commit_cowonly_roots+0x1ce/0xc30 fs/btrfs/transaction.c:1172 btrfs_commit_transaction+0x94a/0x2480 fs/btrfs/transaction.c:2218 btrfs_commit_super+0xc1/0x100 fs/btrfs/disk-io.c:3932 close_ctree+0x618/0x850 fs/btrfs/disk-io.c:3992 generic_shutdown_super+0x144/0x370 fs/super.c:456 kill_anon_super+0x36/0x60 fs/super.c:1032 btrfs_kill_super+0x49/0x550 fs/btrfs/super.c:2221 deactivate_locked_super+0x94/0x160 fs/super.c:329 deactivate_super+0x174/0x1a0 fs/super.c:360 cleanup_mnt+0x1a8/0x290 fs/namespace.c:1098 task_work_run+0x148/0x1c0 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:193 [inline] exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167 prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline] syscall_return_slowpath arch/x86/entry/common.c:271 [inline] do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296 entry_SYSCALL_64_after_hwframe+0x49/0xbe -> #6 (&fs_info->tree_log_mutex){+.+.}: btrfs_commit_transaction+0x8c2/0x2480 fs/btrfs/transaction.c:2176 btrfs_commit_super+0xc1/0x100 fs/btrfs/disk-io.c:3932 close_ctree+0x618/0x850 fs/btrfs/disk-io.c:3992 generic_shutdown_super+0x144/0x370 fs/super.c:456 kill_anon_super+0x36/0x60 fs/super.c:1032 btrfs_kill_super+0x49/0x550 fs/btrfs/super.c:2221 deactivate_locked_super+0x94/0x160 fs/super.c:329 deactivate_super+0x174/0x1a0 fs/super.c:360 cleanup_mnt+0x1a8/0x290 fs/namespace.c:1098 task_work_run+0x148/0x1c0 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:193 [inline] exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167 prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline] syscall_return_slowpath arch/x86/entry/common.c:271 [inline] do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296 entry_SYSCALL_64_after_hwframe+0x49/0xbe -> #5 (&fs_info->reloc_mutex){+.+.}: btrfs_commit_transaction+0x80b/0x2480 fs/btrfs/transaction.c:2120 btrfs_commit_super+0xc1/0x100 fs/btrfs/disk-io.c:3932 close_ctree+0x618/0x850 fs/btrfs/disk-io.c:3992 generic_shutdown_super+0x144/0x370 fs/super.c:456 kill_anon_super+0x36/0x60 fs/super.c:1032 btrfs_kill_super+0x49/0x550 fs/btrfs/super.c:2221 deactivate_locked_super+0x94/0x160 fs/super.c:329 deactivate_super+0x174/0x1a0 fs/super.c:360 cleanup_mnt+0x1a8/0x290 fs/namespace.c:1098 task_work_run+0x148/0x1c0 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:193 [inline] exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167 prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline] syscall_return_slowpath arch/x86/entry/common.c:271 [inline] do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296 entry_SYSCALL_64_after_hwframe+0x49/0xbe -> #4 (sb_internal#5){.+.+}: sb_start_intwrite include/linux/fs.h:1626 [inline] start_transaction+0xa37/0xf90 fs/btrfs/transaction.c:528 btrfs_dirty_inode+0xe3/0x210 fs/btrfs/inode.c:6165 btrfs_update_time+0x33b/0x3d0 fs/btrfs/inode.c:6207 update_time fs/inode.c:1675 [inline] touch_atime+0x23c/0x2a0 fs/inode.c:1746 file_accessed include/linux/fs.h:2123 [inline] btrfs_file_mmap+0x11b/0x160 fs/btrfs/file.c:2274 call_mmap include/linux/fs.h:1826 [inline] mmap_region+0xc94/0x16b0 mm/mmap.c:1757 do_mmap+0x8e8/0x1080 mm/mmap.c:1530 do_mmap_pgoff include/linux/mm.h:2329 [inline] vm_mmap_pgoff+0x197/0x200 mm/util.c:357 ksys_mmap_pgoff+0x298/0x5a0 mm/mmap.c:1580 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe -> #3 (&mm->mmap_sem){++++}: _copy_to_iter+0x3d0/0xea0 lib/iov_iter.c:564 copy_to_iter include/linux/uio.h:106 [inline] skb_copy_datagram_iter+0x469/0x9e0 net/core/datagram.c:431 skb_copy_datagram_msg include/linux/skbuff.h:3347 [inline] unix_dgram_recvmsg+0x3b7/0xdb0 net/unix/af_unix.c:2180 sock_recvmsg_nosec net/socket.c:859 [inline] sock_recvmsg net/socket.c:866 [inline] sock_recvmsg net/socket.c:862 [inline] __sys_recvfrom+0x249/0x3a0 net/socket.c:1956 __do_sys_recvfrom net/socket.c:1974 [inline] __se_sys_recvfrom net/socket.c:1970 [inline] __x64_sys_recvfrom+0xdd/0x1b0 net/socket.c:1970 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe -> #2 (&u->iolock){+.+.}: unix_stream_read_generic+0x2de/0x1a40 net/unix/af_unix.c:2322 unix_stream_recvmsg+0xb1/0xf0 net/unix/af_unix.c:2505 sock_recvmsg_nosec net/socket.c:859 [inline] sock_recvmsg net/socket.c:866 [inline] sock_recvmsg+0xca/0x110 net/socket.c:862 sock_xmit+0x37d/0x5c0 drivers/block/nbd.c:439 nbd_read_stat drivers/block/nbd.c:633 [inline] recv_work+0x1e9/0x1100 drivers/block/nbd.c:732 process_one_work+0x864/0x1570 kernel/workqueue.c:2153 worker_thread+0x64c/0x1130 kernel/workqueue.c:2296 kthread+0x33f/0x460 kernel/kthread.c:259 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415 -> #1 ((work_completion)(&args->work)){+.+.}: worker_thread+0x64c/0x1130 kernel/workqueue.c:2296 kthread+0x33f/0x460 kernel/kthread.c:259 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415 -> #0 ((wq_completion)"knbd%d-recv"nbd->index){+.+.}: flush_workqueue+0x117/0x13e0 kernel/workqueue.c:2661 drain_workqueue+0x1a5/0x460 kernel/workqueue.c:2826 destroy_workqueue+0x75/0x790 kernel/workqueue.c:4183 nbd_config_put+0x3c5/0x870 drivers/block/nbd.c:1175 nbd_release+0xf4/0x170 drivers/block/nbd.c:1461 __blkdev_put+0x636/0x870 fs/block_dev.c:1819 blkdev_close+0x86/0xb0 fs/block_dev.c:1888 __fput+0x2ce/0x890 fs/file_table.c:278 task_work_run+0x148/0x1c0 kernel/task_work.c:113 exit_task_work include/linux/task_work.h:22 [inline] do_exit+0xbf3/0x2be0 kernel/exit.c:870 do_group_exit+0x125/0x310 kernel/exit.c:967 get_signal+0x3f2/0x1f70 kernel/signal.c:2589 do_signal+0x8f/0x1670 arch/x86/kernel/signal.c:799 exit_to_usermode_loop+0x204/0x2a0 arch/x86/entry/common.c:163 prepare_exit_to_usermode+0x277/0x2d0 arch/x86/entry/common.c:198 retint_user+0x8/0x18 other info that might help us debug this: Chain exists of: (wq_completion)"knbd%d-recv"nbd->index --> nbd_index_mutex --> &nbd->config_lock Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&nbd->config_lock); lock(nbd_index_mutex); lock(&nbd->config_lock); lock((wq_completion)"knbd%d-recv"nbd->index); *** DEADLOCK *** 2 locks held by syz-executor.4/15733: #0: 0000000084e5cc56 (&bdev->bd_mutex){+.+.}, at: __blkdev_put+0xfc/0x870 fs/block_dev.c:1806 #1: 000000009b10c5db (&nbd->config_lock){+.+.}, at: refcount_dec_and_mutex_lock lib/refcount.c:311 [inline] #1: 000000009b10c5db (&nbd->config_lock){+.+.}, at: refcount_dec_and_mutex_lock+0x4a/0x80 lib/refcount.c:306 stack backtrace: CPU: 1 PID: 15733 Comm: syz-executor.4 Not tainted 4.19.211-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/21/2023 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1fc/0x2ef lib/dump_stack.c:118 print_circular_bug.constprop.0.cold+0x2d7/0x41e kernel/locking/lockdep.c:1222 check_prev_add kernel/locking/lockdep.c:1866 [inline] check_prevs_add kernel/locking/lockdep.c:1979 [inline] validate_chain kernel/locking/lockdep.c:2420 [inline] __lock_acquire+0x30c9/0x3ff0 kernel/locking/lockdep.c:3416 lock_acquire+0x170/0x3c0 kernel/locking/lockdep.c:3908 flush_workqueue+0x117/0x13e0 kernel/workqueue.c:2661 drain_workqueue+0x1a5/0x460 kernel/workqueue.c:2826 destroy_workqueue+0x75/0x790 kernel/workqueue.c:4183 nbd_config_put+0x3c5/0x870 drivers/block/nbd.c:1175 nbd_release+0xf4/0x170 drivers/block/nbd.c:1461 __blkdev_put+0x636/0x870 fs/block_dev.c:1819 blkdev_close+0x86/0xb0 fs/block_dev.c:1888 __fput+0x2ce/0x890 fs/file_table.c:278 task_work_run+0x148/0x1c0 kernel/task_work.c:113 exit_task_work include/linux/task_work.h:22 [inline] do_exit+0xbf3/0x2be0 kernel/exit.c:870 do_group_exit+0x125/0x310 kernel/exit.c:967 get_signal+0x3f2/0x1f70 kernel/signal.c:2589 do_signal+0x8f/0x1670 arch/x86/kernel/signal.c:799 exit_to_usermode_loop+0x204/0x2a0 arch/x86/entry/common.c:163 prepare_exit_to_usermode+0x277/0x2d0 arch/x86/entry/common.c:198 retint_user+0x8/0x18 RIP: 0033:0x7fd0ff99d0f9 Code: Bad RIP value. RSP: 002b:00007fd0f6aee118 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 00007fd0ffabd050 RCX: 00007fd0ff99d0f9 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 00007fd0ff9f8ae9 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffd30193a2f R14: 00007fd0f6aee300 R15: 0000000000022000 BTRFS warning (device ): duplicate device /dev/loop5 devid 1 generation 8 scanned by syz-executor.5 (15748) BTRFS error (device loop2): superblock checksum mismatch BTRFS warning (device ): duplicate device /dev/loop5 devid 1 generation 8 scanned by systemd-udevd (15775) BTRFS warning (device ): duplicate device /dev/loop3 devid 1 generation 8 scanned by syz-executor.3 (15768) BTRFS error (device loop2): open_ctree failed BTRFS error (device loop2): superblock checksum mismatch BTRFS warning (device ): duplicate device /dev/loop3 devid 1 generation 8 scanned by systemd-udevd (15782) BTRFS error (device loop2): open_ctree failed BTRFS error (device loop2): superblock checksum mismatch BTRFS error (device loop2): open_ctree failed BTRFS info (device loop3): using free space tree BTRFS info (device loop3): has skinny extents BTRFS error (device loop3): found replace target device without a valid replace item BTRFS error (device loop3): failed to init dev_replace: -117 BTRFS error (device loop3): open_ctree failed BTRFS info (device loop5): using free space tree BTRFS info (device loop5): has skinny extents BTRFS warning (device ): duplicate device /dev/loop1 devid 1 generation 8 scanned by syz-executor.1 (15813) BTRFS warning (device ): duplicate device /dev/loop1 devid 1 generation 8 scanned by systemd-udevd (15867) BTRFS error (device loop5): found replace target device without a valid replace item BTRFS error (device loop5): failed to init dev_replace: -117 BTRFS error (device loop5): open_ctree failed BTRFS info (device loop5): using free space tree BTRFS info (device loop5): has skinny extents BTRFS warning (device ): duplicate device /dev/loop3 devid 1 generation 8 scanned by syz-executor.3 (15855) BTRFS error (device loop5): found replace target device without a valid replace item BTRFS error (device loop5): failed to init dev_replace: -117 BTRFS error (device loop5): open_ctree failed BTRFS info (device loop1): using free space tree BTRFS info (device loop1): has skinny extents BTRFS warning (device ): duplicate device /dev/loop4 devid 1 generation 8 scanned by syz-executor.4 (15897) BTRFS warning (device ): duplicate device /dev/loop4 devid 1 generation 8 scanned by systemd-udevd (15927) BTRFS warning (device ): duplicate device /dev/loop3 devid 1 generation 8 scanned by syz-executor.3 (15920) BTRFS warning (device ): duplicate device /dev/loop3 devid 1 generation 8 scanned by systemd-udevd (15918) BTRFS warning (device ): duplicate device /dev/loop5 devid 1 generation 8 scanned by syz-executor.5 (15917) BTRFS warning (device ): duplicate device /dev/loop5 devid 1 generation 8 scanned by systemd-udevd (15927) BTRFS error (device loop1): found replace target device without a valid replace item BTRFS error (device loop1): failed to init dev_replace: -117 BTRFS error (device loop1): open_ctree failed BTRFS info (device loop3): using free space tree BTRFS info (device loop3): has skinny extents BTRFS warning (device ): duplicate device /dev/loop5 devid 1 generation 8 scanned by syz-executor.5 (15978) BTRFS warning (device ): duplicate device /dev/loop5 devid 1 generation 8 scanned by systemd-udevd (15997) BTRFS warning (device ): duplicate device /dev/loop4 devid 1 generation 8 scanned by syz-executor.4 (15988) BTRFS error (device loop3): found replace target device without a valid replace item BTRFS warning (device ): duplicate device /dev/loop4 devid 1 generation 8 scanned by systemd-udevd (16021) BTRFS error (device loop3): failed to init dev_replace: -117 BTRFS error (device loop3): open_ctree failed BTRFS info (device loop1): using free space tree BTRFS info (device loop1): has skinny extents BTRFS error (device loop1): found replace target device without a valid replace item BTRFS error (device loop1): failed to init dev_replace: -117 BTRFS error (device loop1): open_ctree failed BTRFS info (device loop1): using free space tree BTRFS info (device loop1): has skinny extents BTRFS warning (device ): duplicate device /dev/loop5 devid 1 generation 8 scanned by syz-executor.5 (16041) BTRFS warning (device ): duplicate device /dev/loop5 devid 1 generation 8 scanned by systemd-udevd (16071) BTRFS warning (device ): duplicate device /dev/loop3 devid 1 generation 8 scanned by syz-executor.3 (16051) BTRFS warning (device ): duplicate device /dev/loop3 devid 1 generation 8 scanned by systemd-udevd (16067) BTRFS error (device loop1): found replace target device without a valid replace item BTRFS error (device loop1): failed to init dev_replace: -117 BTRFS error (device loop1): open_ctree failed BTRFS error (device loop2): superblock checksum mismatch BTRFS warning (device ): duplicate device /dev/loop1 devid 1 generation 8 scanned by syz-executor.1 (16077) BTRFS warning (device ): duplicate device /dev/loop1 devid 1 generation 8 scanned by systemd-udevd (16114) BTRFS error (device loop2): open_ctree failed BTRFS info (device loop3): using free space tree BTRFS warning (device ): duplicate device /dev/loop5 devid 1 generation 8 scanned by syz-executor.5 (16110) BTRFS info (device loop3): has skinny extents BTRFS error (device loop3): found replace target device without a valid replace item BTRFS error (device loop3): failed to init dev_replace: -117 BTRFS error (device loop3): open_ctree failed BTRFS info (device loop1): using free space tree BTRFS info (device loop1): has skinny extents BTRFS error (device loop1): found replace target device without a valid replace item BTRFS error (device loop1): failed to init dev_replace: -117 BTRFS error (device loop1): open_ctree failed BTRFS info (device loop3): using free space tree BTRFS info (device loop3): has skinny extents BTRFS error (device loop3): found replace target device without a valid replace item BTRFS error (device loop3): failed to init dev_replace: -117 BTRFS error (device loop3): open_ctree failed BTRFS warning (device ): duplicate device /dev/loop5 devid 1 generation 8 scanned by syz-executor.5 (16201) BTRFS info (device loop3): using free space tree BTRFS info (device loop3): has skinny extents BTRFS warning (device ): duplicate device /dev/loop5 devid 1 generation 8 scanned by systemd-udevd (16245) BTRFS warning (device ): duplicate device /dev/loop4 devid 1 generation 8 scanned by syz-executor.4 (16212) BTRFS error (device loop3): found replace target device without a valid replace item BTRFS error (device loop3): failed to init dev_replace: -117 BTRFS warning (device ): duplicate device /dev/loop4 devid 1 generation 8 scanned by systemd-udevd (16247) BTRFS warning (device ): duplicate device /dev/loop1 devid 1 generation 8 scanned by syz-executor.1 (16229) BTRFS warning (device ): duplicate device /dev/loop1 devid 1 generation 8 scanned by systemd-udevd (16251) BTRFS error (device loop3): open_ctree failed BTRFS info (device loop3): using free space tree BTRFS info (device loop3): has skinny extents BTRFS warning (device ): duplicate device /dev/loop1 devid 1 generation 8 scanned by syz-executor.1 (16285) BTRFS warning (device ): duplicate device /dev/loop5 devid 1 generation 8 scanned by syz-executor.5 (16288) BTRFS error (device loop3): found replace target device without a valid replace item BTRFS error (device loop3): failed to init dev_replace: -117 BTRFS error (device loop3): open_ctree failed BTRFS info (device loop3): using free space tree BTRFS info (device loop3): has skinny extents BTRFS warning (device ): duplicate device /dev/loop4 devid 1 generation 8 scanned by syz-executor.4 (16340) BTRFS warning (device ): duplicate device /dev/loop1 devid 1 generation 8 scanned by syz-executor.1 (16343) BTRFS warning (device ): duplicate device /dev/loop1 devid 1 generation 8 scanned by systemd-udevd (16365) BTRFS warning (device ): duplicate device /dev/loop5 devid 1 generation 8 scanned by syz-executor.5 (16351) BTRFS warning (device ): duplicate device /dev/loop5 devid 1 generation 8 scanned by systemd-udevd (16370) BTRFS error (device loop3): found replace target device without a valid replace item BTRFS error (device loop3): failed to init dev_replace: -117 BTRFS error (device loop3): open_ctree failed BTRFS info (device loop1): using free space tree BTRFS info (device loop1): has skinny extents