====================================================== WARNING: possible circular locking dependency detected 6.13.0-rc5-syzkaller-00006-g56e6a3499e14 #0 Not tainted ------------------------------------------------------ syz.0.0/5333 is trying to acquire lock: ffff888052b849d0 (&c->mark_lock){++++}-{0:0}, at: __bch2_disk_reservation_add+0xd7/0x7f0 fs/bcachefs/buckets.c:1170 but task is already holding lock: ffff888052322518 (sb_pagefaults){.+.+}-{0:0}, at: do_page_mkwrite+0x15c/0x350 mm/memory.c:3176 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #8 (sb_pagefaults){.+.+}-{0:0}: lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 percpu_down_read include/linux/percpu-rwsem.h:51 [inline] __sb_start_write include/linux/fs.h:1725 [inline] sb_start_pagefault include/linux/fs.h:1890 [inline] bch2_page_mkwrite+0x2d9/0x1020 fs/bcachefs/fs-io-pagecache.c:614 do_page_mkwrite+0x15c/0x350 mm/memory.c:3176 do_shared_fault mm/memory.c:5398 [inline] do_fault mm/memory.c:5460 [inline] do_pte_missing mm/memory.c:3979 [inline] handle_pte_fault+0x10c6/0x5ed0 mm/memory.c:5801 __handle_mm_fault mm/memory.c:5944 [inline] handle_mm_fault+0x1106/0x1bb0 mm/memory.c:6112 do_user_addr_fault arch/x86/mm/fault.c:1389 [inline] handle_page_fault arch/x86/mm/fault.c:1481 [inline] exc_page_fault+0x2b9/0x8b0 arch/x86/mm/fault.c:1539 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623 -> #7 (&mm->mmap_lock){++++}-{4:4}: lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 __might_fault+0xc6/0x120 mm/memory.c:6751 drm_mode_setcrtc+0x13bf/0x1e30 drivers/gpu/drm/drm_crtc.c:840 drm_ioctl_kernel+0x337/0x440 drivers/gpu/drm/drm_ioctl.c:796 drm_ioctl+0x60e/0xad0 drivers/gpu/drm/drm_ioctl.c:893 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:906 [inline] __se_sys_ioctl+0xf5/0x170 fs/ioctl.c:892 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #6 (crtc_ww_class_mutex){+.+.}-{4:4}: lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 ww_acquire_init include/linux/ww_mutex.h:162 [inline] drm_modeset_acquire_init+0x20b/0x3d0 drivers/gpu/drm/drm_modeset_lock.c:250 drmm_mode_config_init+0xe05/0x1800 drivers/gpu/drm/drm_mode_config.c:453 vkms_modeset_init drivers/gpu/drm/vkms/vkms_drv.c:158 [inline] vkms_create drivers/gpu/drm/vkms/vkms_drv.c:219 [inline] vkms_init+0x380/0x720 drivers/gpu/drm/vkms/vkms_drv.c:256 do_one_initcall+0x248/0x870 init/main.c:1266 do_initcall_level+0x157/0x210 init/main.c:1328 do_initcalls+0x3f/0x80 init/main.c:1344 kernel_init_freeable+0x435/0x5d0 init/main.c:1577 kernel_init+0x1d/0x2b0 init/main.c:1466 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 -> #5 (crtc_ww_class_acquire){+.+.}-{0:0}: lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 ww_acquire_init include/linux/ww_mutex.h:161 [inline] drm_modeset_acquire_init+0x1ee/0x3d0 drivers/gpu/drm/drm_modeset_lock.c:250 drm_client_modeset_commit_atomic+0xcf/0x7d0 drivers/gpu/drm/drm_client_modeset.c:1009 drm_client_modeset_commit_locked+0xe0/0x520 drivers/gpu/drm/drm_client_modeset.c:1173 drm_client_modeset_commit+0x4a/0x70 drivers/gpu/drm/drm_client_modeset.c:1199 __drm_fb_helper_restore_fbdev_mode_unlocked+0xc3/0x170 drivers/gpu/drm/drm_fb_helper.c:237 drm_fb_helper_set_par+0xaf/0x100 drivers/gpu/drm/drm_fb_helper.c:1351 fbcon_init+0x112b/0x2100 drivers/video/fbdev/core/fbcon.c:1113 visual_init+0x2e7/0x660 drivers/tty/vt/vt.c:1011 do_bind_con_driver+0x863/0xf60 drivers/tty/vt/vt.c:3833 do_take_over_console+0x5e7/0x750 drivers/tty/vt/vt.c:4399 do_fbcon_takeover+0x11a/0x200 drivers/video/fbdev/core/fbcon.c:549 do_fb_registered drivers/video/fbdev/core/fbcon.c:2988 [inline] fbcon_fb_registered+0x364/0x620 drivers/video/fbdev/core/fbcon.c:3008 do_register_framebuffer drivers/video/fbdev/core/fbmem.c:449 [inline] register_framebuffer+0x654/0x810 drivers/video/fbdev/core/fbmem.c:515 __drm_fb_helper_initial_config_and_unlock+0x1697/0x1cc0 drivers/gpu/drm/drm_fb_helper.c:1841 drm_fbdev_client_hotplug+0x16e/0x230 drivers/gpu/drm/drm_fbdev_client.c:51 drm_client_register+0x17f/0x210 drivers/gpu/drm/drm_client.c:140 drm_fbdev_client_setup+0x1a9/0x3b0 drivers/gpu/drm/drm_fbdev_client.c:158 drm_client_setup+0x1d/0x90 drivers/gpu/drm/drm_client_setup.c:29 vkms_create drivers/gpu/drm/vkms/vkms_drv.c:230 [inline] vkms_init+0x5eb/0x720 drivers/gpu/drm/vkms/vkms_drv.c:256 do_one_initcall+0x248/0x870 init/main.c:1266 do_initcall_level+0x157/0x210 init/main.c:1328 do_initcalls+0x3f/0x80 init/main.c:1344 kernel_init_freeable+0x435/0x5d0 init/main.c:1577 kernel_init+0x1d/0x2b0 init/main.c:1466 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 -> #4 (&client->modeset_mutex){+.+.}-{4:4}: lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 __mutex_lock_common kernel/locking/mutex.c:585 [inline] __mutex_lock+0x1ac/0xee0 kernel/locking/mutex.c:735 drm_client_modeset_probe+0x3ab/0x5490 drivers/gpu/drm/drm_client_modeset.c:834 __drm_fb_helper_initial_config_and_unlock+0x11e/0x1cc0 drivers/gpu/drm/drm_fb_helper.c:1818 drm_fbdev_client_hotplug+0x16e/0x230 drivers/gpu/drm/drm_fbdev_client.c:51 drm_client_register+0x17f/0x210 drivers/gpu/drm/drm_client.c:140 drm_fbdev_client_setup+0x1a9/0x3b0 drivers/gpu/drm/drm_fbdev_client.c:158 drm_client_setup+0x1d/0x90 drivers/gpu/drm/drm_client_setup.c:29 vkms_create drivers/gpu/drm/vkms/vkms_drv.c:230 [inline] vkms_init+0x5eb/0x720 drivers/gpu/drm/vkms/vkms_drv.c:256 do_one_initcall+0x248/0x870 init/main.c:1266 do_initcall_level+0x157/0x210 init/main.c:1328 do_initcalls+0x3f/0x80 init/main.c:1344 kernel_init_freeable+0x435/0x5d0 init/main.c:1577 kernel_init+0x1d/0x2b0 init/main.c:1466 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 -> #3 (&helper->lock){+.+.}-{4:4}: lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 __mutex_lock_common kernel/locking/mutex.c:585 [inline] __mutex_lock+0x1ac/0xee0 kernel/locking/mutex.c:735 __drm_fb_helper_restore_fbdev_mode_unlocked+0xa2/0x170 drivers/gpu/drm/drm_fb_helper.c:228 drm_fb_helper_set_par+0xaf/0x100 drivers/gpu/drm/drm_fb_helper.c:1351 fbcon_init+0x112b/0x2100 drivers/video/fbdev/core/fbcon.c:1113 visual_init+0x2e7/0x660 drivers/tty/vt/vt.c:1011 do_bind_con_driver+0x863/0xf60 drivers/tty/vt/vt.c:3833 do_take_over_console+0x5e7/0x750 drivers/tty/vt/vt.c:4399 do_fbcon_takeover+0x11a/0x200 drivers/video/fbdev/core/fbcon.c:549 do_fb_registered drivers/video/fbdev/core/fbcon.c:2988 [inline] fbcon_fb_registered+0x364/0x620 drivers/video/fbdev/core/fbcon.c:3008 do_register_framebuffer drivers/video/fbdev/core/fbmem.c:449 [inline] register_framebuffer+0x654/0x810 drivers/video/fbdev/core/fbmem.c:515 __drm_fb_helper_initial_config_and_unlock+0x1697/0x1cc0 drivers/gpu/drm/drm_fb_helper.c:1841 drm_fbdev_client_hotplug+0x16e/0x230 drivers/gpu/drm/drm_fbdev_client.c:51 drm_client_register+0x17f/0x210 drivers/gpu/drm/drm_client.c:140 drm_fbdev_client_setup+0x1a9/0x3b0 drivers/gpu/drm/drm_fbdev_client.c:158 drm_client_setup+0x1d/0x90 drivers/gpu/drm/drm_client_setup.c:29 vkms_create drivers/gpu/drm/vkms/vkms_drv.c:230 [inline] vkms_init+0x5eb/0x720 drivers/gpu/drm/vkms/vkms_drv.c:256 do_one_initcall+0x248/0x870 init/main.c:1266 do_initcall_level+0x157/0x210 init/main.c:1328 do_initcalls+0x3f/0x80 init/main.c:1344 kernel_init_freeable+0x435/0x5d0 init/main.c:1577 kernel_init+0x1d/0x2b0 init/main.c:1466 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 -> #2 (console_lock){+.+.}-{0:0}: lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 console_lock+0x164/0x1b0 kernel/printk/printk.c:2833 __bch2_print_string_as_lines fs/bcachefs/util.c:267 [inline] bch2_print_string_as_lines+0x20/0xc0 fs/bcachefs/util.c:286 __bch2_fsck_err+0x104d/0x1570 fs/bcachefs/error.c:411 __bch2_bkey_fsck_err+0x24d/0x280 fs/bcachefs/error.c:464 bch2_btree_ptr_v2_validate+0x354/0x550 journal_validate_key+0x59e/0xbf0 fs/bcachefs/journal_io.c:370 journal_entry_btree_root_validate+0x160/0x480 fs/bcachefs/journal_io.c:455 bch2_sb_clean_validate_late fs/bcachefs/sb-clean.c:40 [inline] bch2_read_superblock_clean+0x207/0x520 fs/bcachefs/sb-clean.c:168 bch2_fs_recovery+0x1f4/0x39d0 fs/bcachefs/recovery.c:639 bch2_fs_start+0x356/0x5b0 fs/bcachefs/super.c:1037 bch2_fs_get_tree+0xd68/0x1710 fs/bcachefs/fs.c:2170 vfs_get_tree+0x90/0x2b0 fs/super.c:1814 do_new_mount+0x2be/0xb40 fs/namespace.c:3507 do_mount fs/namespace.c:3847 [inline] __do_sys_mount fs/namespace.c:4057 [inline] __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:4034 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #1 (&c->fsck_error_msgs_lock){+.+.}-{4:4}: lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 __mutex_lock_common kernel/locking/mutex.c:585 [inline] __mutex_lock+0x1ac/0xee0 kernel/locking/mutex.c:735 __bch2_fsck_err+0x3d4/0x1570 fs/bcachefs/error.c:282 bch2_check_fix_ptr fs/bcachefs/buckets.c:137 [inline] bch2_check_fix_ptrs+0x1f24/0x6530 fs/bcachefs/buckets.c:266 bch2_trigger_extent+0x92c/0xaa0 fs/bcachefs/buckets.c:856 bch2_key_trigger fs/bcachefs/bkey_methods.h:87 [inline] bch2_gc_mark_key+0x6b5/0x10e0 fs/bcachefs/btree_gc.c:634 bch2_gc_btree fs/bcachefs/btree_gc.c:698 [inline] bch2_gc_btrees fs/bcachefs/btree_gc.c:729 [inline] bch2_check_allocations+0x2324/0x7070 fs/bcachefs/btree_gc.c:1133 bch2_run_recovery_pass+0xf0/0x1e0 fs/bcachefs/recovery_passes.c:191 bch2_run_recovery_passes+0x3a7/0x880 fs/bcachefs/recovery_passes.c:244 bch2_fs_recovery+0x25cc/0x39d0 fs/bcachefs/recovery.c:861 bch2_fs_start+0x356/0x5b0 fs/bcachefs/super.c:1037 bch2_fs_get_tree+0xd68/0x1710 fs/bcachefs/fs.c:2170 vfs_get_tree+0x90/0x2b0 fs/super.c:1814 do_new_mount+0x2be/0xb40 fs/namespace.c:3507 do_mount fs/namespace.c:3847 [inline] __do_sys_mount fs/namespace.c:4057 [inline] __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:4034 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #0 (&c->mark_lock){++++}-{0:0}: check_prev_add kernel/locking/lockdep.c:3161 [inline] check_prevs_add kernel/locking/lockdep.c:3280 [inline] validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3904 __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 percpu_down_read+0x44/0x1b0 include/linux/percpu-rwsem.h:51 __bch2_disk_reservation_add+0xd7/0x7f0 fs/bcachefs/buckets.c:1170 bch2_disk_reservation_add fs/bcachefs/buckets.h:367 [inline] __bch2_folio_reservation_get+0x3e0/0xb50 fs/bcachefs/fs-io-pagecache.c:428 bch2_folio_reservation_get fs/bcachefs/fs-io-pagecache.c:477 [inline] bch2_page_mkwrite+0xb0f/0x1020 fs/bcachefs/fs-io-pagecache.c:637 do_page_mkwrite+0x15c/0x350 mm/memory.c:3176 do_shared_fault mm/memory.c:5398 [inline] do_fault mm/memory.c:5460 [inline] do_pte_missing mm/memory.c:3979 [inline] handle_pte_fault+0x10c6/0x5ed0 mm/memory.c:5801 __handle_mm_fault mm/memory.c:5944 [inline] handle_mm_fault+0x1106/0x1bb0 mm/memory.c:6112 do_user_addr_fault arch/x86/mm/fault.c:1389 [inline] handle_page_fault arch/x86/mm/fault.c:1481 [inline] exc_page_fault+0x2b9/0x8b0 arch/x86/mm/fault.c:1539 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623 other info that might help us debug this: Chain exists of: &c->mark_lock --> &mm->mmap_lock --> sb_pagefaults Possible unsafe locking scenario: CPU0 CPU1 ---- ---- rlock(sb_pagefaults); lock(&mm->mmap_lock); lock(sb_pagefaults); rlock(&c->mark_lock); *** DEADLOCK *** 2 locks held by syz.0.0/5333: #0: ffff8880006859a0 (&mm->mmap_lock){++++}-{4:4}, at: mmap_read_trylock include/linux/mmap_lock.h:163 [inline] #0: ffff8880006859a0 (&mm->mmap_lock){++++}-{4:4}, at: get_mmap_lock_carefully mm/memory.c:6149 [inline] #0: ffff8880006859a0 (&mm->mmap_lock){++++}-{4:4}, at: lock_mm_and_find_vma+0x32/0x2f0 mm/memory.c:6209 #1: ffff888052322518 (sb_pagefaults){.+.+}-{0:0}, at: do_page_mkwrite+0x15c/0x350 mm/memory.c:3176 stack backtrace: CPU: 0 UID: 0 PID: 5333 Comm: syz.0.0 Not tainted 6.13.0-rc5-syzkaller-00006-g56e6a3499e14 #0 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+0x241/0x360 lib/dump_stack.c:120 print_circular_bug+0x13a/0x1b0 kernel/locking/lockdep.c:2074 check_noncircular+0x36a/0x4a0 kernel/locking/lockdep.c:2206 check_prev_add kernel/locking/lockdep.c:3161 [inline] check_prevs_add kernel/locking/lockdep.c:3280 [inline] validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3904 __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 percpu_down_read+0x44/0x1b0 include/linux/percpu-rwsem.h:51 __bch2_disk_reservation_add+0xd7/0x7f0 fs/bcachefs/buckets.c:1170 bch2_disk_reservation_add fs/bcachefs/buckets.h:367 [inline] __bch2_folio_reservation_get+0x3e0/0xb50 fs/bcachefs/fs-io-pagecache.c:428 bch2_folio_reservation_get fs/bcachefs/fs-io-pagecache.c:477 [inline] bch2_page_mkwrite+0xb0f/0x1020 fs/bcachefs/fs-io-pagecache.c:637 do_page_mkwrite+0x15c/0x350 mm/memory.c:3176 do_shared_fault mm/memory.c:5398 [inline] do_fault mm/memory.c:5460 [inline] do_pte_missing mm/memory.c:3979 [inline] handle_pte_fault+0x10c6/0x5ed0 mm/memory.c:5801 __handle_mm_fault mm/memory.c:5944 [inline] handle_mm_fault+0x1106/0x1bb0 mm/memory.c:6112 do_user_addr_fault arch/x86/mm/fault.c:1389 [inline] handle_page_fault arch/x86/mm/fault.c:1481 [inline] exc_page_fault+0x2b9/0x8b0 arch/x86/mm/fault.c:1539 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623 RIP: 0033:0x7f538b54f208 Code: 66 89 74 17 02 88 0f c3 c5 fa 6f 06 c5 fa 6f 4c 16 f0 c5 fa 7f 07 c5 fa 7f 4c 17 f0 c3 0f 1f 44 00 00 48 8b 4c 16 f8 48 8b 36 <48> 89 37 48 89 4c 17 f8 c3 62 e1 fe 28 6f 54 16 ff 62 e1 fe 28 6f RSP: 002b:00007ffe9416ab28 EFLAGS: 00010246 RAX: 0000000020000080 RBX: 0000000000000004 RCX: 0031656c69662f2e RDX: 0000000000000008 RSI: 0031656c69662f2e RDI: 0000000020000080 RBP: 00007f538b777ba0 R08: 00007f538b3ff02c R09: 0000000000000001 R10: 0000000000000001 R11: 0000000000000009 R12: 000000000001ebe3 R13: 00007f538b775fa0 R14: 0000000000000032 R15: fffffffffffffffe