====================================================== WARNING: possible circular locking dependency detected syzkaller #0 Not tainted ------------------------------------------------------ syz.3.1387/11840 is trying to acquire lock: ffff88805bc51978 (&fs_info->qgroup_ioctl_lock){+.+.}-{4:4}, at: btrfs_quota_enable+0x28e/0x2600 fs/btrfs/qgroup.c:1051 but task is already holding lock: ffff88805bc52538 (btrfs_trans_num_extwriters){++++}-{0:0}, at: join_transaction+0x164/0xd70 fs/btrfs/transaction.c:320 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #4 (btrfs_trans_num_extwriters){++++}-{0:0}: lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868 join_transaction+0x1a4/0xd70 fs/btrfs/transaction.c:321 start_transaction+0x6b6/0x1620 fs/btrfs/transaction.c:705 btrfs_dirty_inode+0x9f/0x190 fs/btrfs/inode.c:6235 inode_update_time fs/inode.c:2075 [inline] touch_atime+0x2f9/0x6d0 fs/inode.c:2148 file_accessed include/linux/fs.h:2663 [inline] filemap_read+0x1002/0x11a0 mm/filemap.c:2784 __kernel_read+0x4cf/0x960 fs/read_write.c:530 integrity_kernel_read+0x89/0xd0 security/integrity/iint.c:28 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:480 [inline] ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline] ima_calc_file_hash+0x85e/0x16f0 security/integrity/ima/ima_crypto.c:568 ima_collect_measurement+0x428/0x8e0 security/integrity/ima/ima_api.c:293 process_measurement+0x1121/0x1a40 security/integrity/ima/ima_main.c:405 ima_file_check+0xd7/0x120 security/integrity/ima/ima_main.c:633 security_file_post_open+0xbb/0x290 security/security.c:3160 do_open fs/namei.c:3889 [inline] path_openat+0x2f26/0x3830 fs/namei.c:4046 do_filp_open+0x1fa/0x410 fs/namei.c:4073 do_sys_openat2+0x121/0x1c0 fs/open.c:1435 do_sys_open fs/open.c:1450 [inline] __do_sys_openat fs/open.c:1466 [inline] __se_sys_openat fs/open.c:1461 [inline] __x64_sys_openat+0x138/0x170 fs/open.c:1461 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #3 (btrfs_trans_num_writers){++++}-{0:0}: reacquire_held_locks+0x127/0x1d0 kernel/locking/lockdep.c:5385 __lock_release kernel/locking/lockdep.c:5574 [inline] lock_release+0x1b4/0x3e0 kernel/locking/lockdep.c:5889 percpu_up_read include/linux/percpu-rwsem.h:112 [inline] __sb_end_write include/linux/fs.h:1793 [inline] sb_end_intwrite+0x26/0x1c0 include/linux/fs.h:1910 __btrfs_end_transaction+0x248/0x640 fs/btrfs/transaction.c:1076 btrfs_dirty_inode+0x14c/0x190 fs/btrfs/inode.c:6249 inode_update_time fs/inode.c:2075 [inline] touch_atime+0x2f9/0x6d0 fs/inode.c:2148 file_accessed include/linux/fs.h:2663 [inline] btrfs_file_mmap_prepare+0xd5/0x140 fs/btrfs/file.c:2050 vfs_mmap_prepare include/linux/fs.h:2294 [inline] call_mmap_prepare mm/vma.c:2585 [inline] __mmap_region mm/vma.c:2653 [inline] mmap_region+0xb41/0x20c0 mm/vma.c:2739 do_mmap+0xc45/0x10d0 mm/mmap.c:558 vm_mmap_pgoff+0x2a6/0x4d0 mm/util.c:580 ksys_mmap_pgoff+0x51f/0x760 mm/mmap.c:604 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #2 (&mm->mmap_lock){++++}-{4:4}: lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868 down_read_killable+0x50/0x350 kernel/locking/rwsem.c:1560 mmap_read_lock_killable+0x1d/0x70 include/linux/mmap_lock.h:462 get_mmap_lock_carefully mm/mmap_lock.c:286 [inline] lock_mm_and_find_vma+0x2a8/0x300 mm/mmap_lock.c:337 do_user_addr_fault+0x331/0x1390 arch/x86/mm/fault.c:1359 handle_page_fault arch/x86/mm/fault.c:1476 [inline] exc_page_fault+0x76/0xf0 arch/x86/mm/fault.c:1532 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623 filldir+0x2bc/0x6c0 fs/readdir.c:295 dir_emit include/linux/fs.h:3958 [inline] kernfs_fop_readdir+0x537/0x870 fs/kernfs/dir.c:1910 iterate_dir+0x399/0x570 fs/readdir.c:108 __do_sys_getdents fs/readdir.c:326 [inline] __se_sys_getdents+0xe4/0x250 fs/readdir.c:312 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #1 (&root->kernfs_rwsem){++++}-{4:4}: lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868 down_write+0x96/0x1f0 kernel/locking/rwsem.c:1590 kernfs_add_one+0x41/0x520 fs/kernfs/dir.c:791 kernfs_create_dir_ns+0xde/0x130 fs/kernfs/dir.c:1093 sysfs_create_dir_ns+0x123/0x280 fs/sysfs/dir.c:59 create_dir lib/kobject.c:73 [inline] kobject_add_internal+0x59f/0xb40 lib/kobject.c:240 kobject_add_varg lib/kobject.c:374 [inline] kobject_init_and_add+0x125/0x190 lib/kobject.c:457 btrfs_sysfs_add_qgroups+0x111/0x2b0 fs/btrfs/sysfs.c:2641 btrfs_quota_enable+0x253/0x2600 fs/btrfs/qgroup.c:1022 btrfs_ioctl_quota_ctl+0x183/0x1c0 fs/btrfs/ioctl.c:3667 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:598 [inline] __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:584 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #0 (&fs_info->qgroup_ioctl_lock){+.+.}-{4:4}: check_prev_add kernel/locking/lockdep.c:3165 [inline] check_prevs_add kernel/locking/lockdep.c:3284 [inline] validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3908 __lock_acquire+0xab9/0xd20 kernel/locking/lockdep.c:5237 lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868 __mutex_lock_common kernel/locking/mutex.c:598 [inline] __mutex_lock+0x187/0x1350 kernel/locking/mutex.c:760 btrfs_quota_enable+0x28e/0x2600 fs/btrfs/qgroup.c:1051 btrfs_ioctl_quota_ctl+0x183/0x1c0 fs/btrfs/ioctl.c:3667 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:598 [inline] __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:584 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 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: &fs_info->qgroup_ioctl_lock --> btrfs_trans_num_writers --> btrfs_trans_num_extwriters Possible unsafe locking scenario: CPU0 CPU1 ---- ---- rlock(btrfs_trans_num_extwriters); lock(btrfs_trans_num_writers); lock(btrfs_trans_num_extwriters); lock(&fs_info->qgroup_ioctl_lock); *** DEADLOCK *** 5 locks held by syz.3.1387/11840: #0: ffff8880283f6428 (sb_writers#25){.+.+}-{0:0}, at: mnt_want_write_file+0x60/0x200 fs/namespace.c:601 #1: ffff88805bc50c40 (&fs_info->subvol_sem){+.+.}-{4:4}, at: btrfs_ioctl_quota_ctl+0x178/0x1c0 fs/btrfs/ioctl.c:3666 #2: ffff8880283f6618 (sb_internal#6){.+.+}-{0:0}, at: btrfs_quota_enable+0x281/0x2600 fs/btrfs/qgroup.c:1049 #3: ffff88805bc52510 (btrfs_trans_num_writers){++++}-{0:0}, at: join_transaction+0x164/0xd70 fs/btrfs/transaction.c:320 #4: ffff88805bc52538 (btrfs_trans_num_extwriters){++++}-{0:0}, at: join_transaction+0x164/0xd70 fs/btrfs/transaction.c:320 stack backtrace: CPU: 1 UID: 0 PID: 11840 Comm: syz.3.1387 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025 Call Trace: dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120 print_circular_bug+0x2ee/0x310 kernel/locking/lockdep.c:2043 check_noncircular+0x134/0x160 kernel/locking/lockdep.c:2175 check_prev_add kernel/locking/lockdep.c:3165 [inline] check_prevs_add kernel/locking/lockdep.c:3284 [inline] validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3908 __lock_acquire+0xab9/0xd20 kernel/locking/lockdep.c:5237 lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868 __mutex_lock_common kernel/locking/mutex.c:598 [inline] __mutex_lock+0x187/0x1350 kernel/locking/mutex.c:760 btrfs_quota_enable+0x28e/0x2600 fs/btrfs/qgroup.c:1051 btrfs_ioctl_quota_ctl+0x183/0x1c0 fs/btrfs/ioctl.c:3667 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:598 [inline] __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:584 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7ff25778ebe9 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:00007ff2586d6038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007ff2579b5fa0 RCX: 00007ff25778ebe9 RDX: 00002000000000c0 RSI: 00000000c0109428 RDI: 0000000000000006 RBP: 00007ff257811e19 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ff2579b6038 R14: 00007ff2579b5fa0 R15: 00007ffd58f4e438