====================================================== WARNING: possible circular locking dependency detected 6.15.0-rc3-syzkaller-00076-ge72e9e693307 #0 Not tainted ------------------------------------------------------ syz.9.665/8354 is trying to acquire lock: ffff888028e9f5a8 (kn->active#5){++++}-{0:0}, at: __kernfs_remove+0x271/0x890 fs/kernfs/dir.c:1506 but task is already holding lock: ffff888026d60358 (&disk->open_mutex){+.+.}-{4:4}, at: bdev_open+0x41a/0xe40 block/bdev.c:907 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (&disk->open_mutex){+.+.}-{4:4}: __mutex_lock_common kernel/locking/mutex.c:601 [inline] __mutex_lock+0x199/0xb90 kernel/locking/mutex.c:746 bdev_open+0x41a/0xe40 block/bdev.c:907 bdev_file_open_by_dev block/bdev.c:1021 [inline] bdev_file_open_by_dev+0x17d/0x210 block/bdev.c:996 disk_scan_partitions+0x1ed/0x320 block/genhd.c:374 add_disk_fwnode+0x1060/0x13a0 block/genhd.c:526 pmem_attach_disk+0x981/0x1350 drivers/nvdimm/pmem.c:574 nd_pmem_probe+0x1a9/0x1f0 drivers/nvdimm/pmem.c:647 nvdimm_bus_probe+0x169/0x5d0 drivers/nvdimm/bus.c:94 call_driver_probe drivers/base/dd.c:579 [inline] really_probe+0x23e/0xa90 drivers/base/dd.c:658 __driver_probe_device+0x1de/0x440 drivers/base/dd.c:800 driver_probe_device+0x4c/0x1b0 drivers/base/dd.c:830 __driver_attach+0x283/0x580 drivers/base/dd.c:1216 bus_for_each_dev+0x13b/0x1d0 drivers/base/bus.c:370 bus_add_driver+0x2e9/0x690 drivers/base/bus.c:678 driver_register+0x15c/0x4b0 drivers/base/driver.c:249 __nd_driver_register+0x103/0x1a0 drivers/nvdimm/bus.c:622 do_one_initcall+0x120/0x6e0 init/main.c:1257 do_initcall_level init/main.c:1319 [inline] do_initcalls init/main.c:1335 [inline] do_basic_setup init/main.c:1354 [inline] kernel_init_freeable+0x5c2/0x900 init/main.c:1567 kernel_init+0x1c/0x2b0 init/main.c:1457 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:153 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 -> #1 (&nvdimm_namespace_key){+.+.}-{4:4}: __mutex_lock_common kernel/locking/mutex.c:601 [inline] __mutex_lock+0x199/0xb90 kernel/locking/mutex.c:746 device_lock include/linux/device.h:922 [inline] uevent_show+0x187/0x3b0 drivers/base/core.c:2730 dev_attr_show+0x53/0xe0 drivers/base/core.c:2424 sysfs_kf_seq_show+0x213/0x3e0 fs/sysfs/file.c:65 seq_read_iter+0x506/0x12c0 fs/seq_file.c:230 kernfs_fop_read_iter+0x40f/0x5a0 fs/kernfs/file.c:279 new_sync_read fs/read_write.c:489 [inline] vfs_read+0x8c8/0xc70 fs/read_write.c:570 ksys_read+0x12a/0x240 fs/read_write.c:713 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xcd/0x260 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #0 (kn->active#5){++++}-{0:0}: check_prev_add kernel/locking/lockdep.c:3166 [inline] check_prevs_add kernel/locking/lockdep.c:3285 [inline] validate_chain kernel/locking/lockdep.c:3909 [inline] __lock_acquire+0x1173/0x1ba0 kernel/locking/lockdep.c:5235 lock_acquire kernel/locking/lockdep.c:5866 [inline] lock_acquire+0x179/0x350 kernel/locking/lockdep.c:5823 kernfs_drain+0x4af/0x570 fs/kernfs/dir.c:511 __kernfs_remove+0x271/0x890 fs/kernfs/dir.c:1506 kernfs_remove_by_name_ns+0x68/0x110 fs/kernfs/dir.c:1714 sysfs_remove_file include/linux/sysfs.h:794 [inline] device_remove_file drivers/base/core.c:3048 [inline] device_remove_file drivers/base/core.c:3044 [inline] device_del+0x381/0x9f0 drivers/base/core.c:3853 drop_partition+0x109/0x1c0 block/partitions/core.c:278 bdev_disk_changed+0x24f/0x1520 block/partitions/core.c:674 blkdev_get_whole+0x187/0x290 block/bdev.c:710 bdev_open+0x2c7/0xe40 block/bdev.c:919 bdev_file_open_by_dev block/bdev.c:1021 [inline] bdev_file_open_by_dev+0x17d/0x210 block/bdev.c:996 disk_scan_partitions+0x1ed/0x320 block/genhd.c:374 blkdev_common_ioctl+0x2f6/0x2250 block/ioctl.c:618 blkdev_ioctl+0x1cb/0x6d0 block/ioctl.c:692 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:906 [inline] __se_sys_ioctl fs/ioctl.c:892 [inline] __x64_sys_ioctl+0x190/0x200 fs/ioctl.c:892 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xcd/0x260 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f other info that might help us debug this: Chain exists of: kn->active#5 --> &nvdimm_namespace_key --> &disk->open_mutex Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&disk->open_mutex); lock(&nvdimm_namespace_key); lock(&disk->open_mutex); lock(kn->active#5); *** DEADLOCK *** 1 lock held by syz.9.665/8354: #0: ffff888026d60358 (&disk->open_mutex){+.+.}-{4:4}, at: bdev_open+0x41a/0xe40 block/bdev.c:907 stack backtrace: CPU: 2 UID: 0 PID: 8354 Comm: syz.9.665 Not tainted 6.15.0-rc3-syzkaller-00076-ge72e9e693307 #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120 print_circular_bug+0x275/0x350 kernel/locking/lockdep.c:2079 check_noncircular+0x14c/0x170 kernel/locking/lockdep.c:2211 check_prev_add kernel/locking/lockdep.c:3166 [inline] check_prevs_add kernel/locking/lockdep.c:3285 [inline] validate_chain kernel/locking/lockdep.c:3909 [inline] __lock_acquire+0x1173/0x1ba0 kernel/locking/lockdep.c:5235 lock_acquire kernel/locking/lockdep.c:5866 [inline] lock_acquire+0x179/0x350 kernel/locking/lockdep.c:5823 kernfs_drain+0x4af/0x570 fs/kernfs/dir.c:511 __kernfs_remove+0x271/0x890 fs/kernfs/dir.c:1506 kernfs_remove_by_name_ns+0x68/0x110 fs/kernfs/dir.c:1714 sysfs_remove_file include/linux/sysfs.h:794 [inline] device_remove_file drivers/base/core.c:3048 [inline] device_remove_file drivers/base/core.c:3044 [inline] device_del+0x381/0x9f0 drivers/base/core.c:3853 drop_partition+0x109/0x1c0 block/partitions/core.c:278 bdev_disk_changed+0x24f/0x1520 block/partitions/core.c:674 blkdev_get_whole+0x187/0x290 block/bdev.c:710 bdev_open+0x2c7/0xe40 block/bdev.c:919 bdev_file_open_by_dev block/bdev.c:1021 [inline] bdev_file_open_by_dev+0x17d/0x210 block/bdev.c:996 disk_scan_partitions+0x1ed/0x320 block/genhd.c:374 blkdev_common_ioctl+0x2f6/0x2250 block/ioctl.c:618 blkdev_ioctl+0x1cb/0x6d0 block/ioctl.c:692 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:906 [inline] __se_sys_ioctl fs/ioctl.c:892 [inline] __x64_sys_ioctl+0x190/0x200 fs/ioctl.c:892 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xcd/0x260 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f5fee18e969 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f5fef035038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f5fee3b5fa0 RCX: 00007f5fee18e969 RDX: 0000000000000000 RSI: 000000000000125f RDI: 0000000000000003 RBP: 00007f5fee210ab1 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f5fee3b5fa0 R15: 00007ffe9db2aa88