[syzbot] [xfs?] possible deadlock in xfs_qm_dqfree_one

From: syzbot
Date: Mon Mar 18 2024 - 23:33:41 EST


Hello,

syzbot found the following issue on:

HEAD commit: 906a93befec8 Merge tag 'efi-fixes-for-v6.9-1' of git://git..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=12d6ea6e180000
kernel config: https://syzkaller.appspot.com/x/.config?x=5206351398500a90
dashboard link: https://syzkaller.appspot.com/bug?extid=b44399433a41aaed7a9f
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/7bc7510fe41f/non_bootable_disk-906a93be.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/f096ab7eaede/vmlinux-906a93be.xz
kernel image: https://storage.googleapis.com/syzbot-assets/52e0859d6157/bzImage-906a93be.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+b44399433a41aaed7a9f@xxxxxxxxxxxxxxxxxxxxxxxxx

======================================================
WARNING: possible circular locking dependency detected
6.8.0-syzkaller-11405-g906a93befec8 #0 Not tainted
------------------------------------------------------
kswapd0/109 is trying to acquire lock:
ffff888022fc0958 (&qinf->qi_tree_lock){+.+.}-{3:3}, at: xfs_qm_dqfree_one+0x6f/0x1a0 fs/xfs/xfs_qm.c:1654

but task is already holding lock:
ffffffff8d930be0 (fs_reclaim){+.+.}-{0:0}, at: balance_pgdat+0x166/0x19a0 mm/vmscan.c:6782

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (fs_reclaim){+.+.}-{0:0}:
__fs_reclaim_acquire mm/page_alloc.c:3698 [inline]
fs_reclaim_acquire+0x102/0x160 mm/page_alloc.c:3712
might_alloc include/linux/sched/mm.h:312 [inline]
slab_pre_alloc_hook mm/slub.c:3746 [inline]
slab_alloc_node mm/slub.c:3827 [inline]
kmem_cache_alloc+0x4f/0x320 mm/slub.c:3852
radix_tree_node_alloc.constprop.0+0x7c/0x350 lib/radix-tree.c:276
radix_tree_extend+0x1a2/0x4d0 lib/radix-tree.c:425
__radix_tree_create lib/radix-tree.c:613 [inline]
radix_tree_insert+0x499/0x630 lib/radix-tree.c:712
xfs_qm_dqget_cache_insert.constprop.0+0x38/0x2c0 fs/xfs/xfs_dquot.c:826
xfs_qm_dqget+0x182/0x4a0 fs/xfs/xfs_dquot.c:901
xfs_qm_scall_setqlim+0x172/0x1980 fs/xfs/xfs_qm_syscalls.c:300
xfs_fs_set_dqblk+0x166/0x1e0 fs/xfs/xfs_quotaops.c:267
quota_setquota+0x4c5/0x5f0 fs/quota/quota.c:310
do_quotactl+0xb03/0x13e0 fs/quota/quota.c:802
__do_sys_quotactl fs/quota/quota.c:961 [inline]
__se_sys_quotactl fs/quota/quota.c:917 [inline]
__x64_sys_quotactl+0x1b4/0x440 fs/quota/quota.c:917
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xd2/0x260 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x6d/0x75

-> #0 (&qinf->qi_tree_lock){+.+.}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3134 [inline]
check_prevs_add kernel/locking/lockdep.c:3253 [inline]
validate_chain kernel/locking/lockdep.c:3869 [inline]
__lock_acquire+0x2478/0x3b30 kernel/locking/lockdep.c:5137
lock_acquire kernel/locking/lockdep.c:5754 [inline]
lock_acquire+0x1b1/0x540 kernel/locking/lockdep.c:5719
__mutex_lock_common kernel/locking/mutex.c:608 [inline]
__mutex_lock+0x175/0x9c0 kernel/locking/mutex.c:752
xfs_qm_dqfree_one+0x6f/0x1a0 fs/xfs/xfs_qm.c:1654
xfs_qm_shrink_scan+0x25c/0x3f0 fs/xfs/xfs_qm.c:531
do_shrink_slab+0x44f/0x1160 mm/shrinker.c:435
shrink_slab+0x18a/0x1310 mm/shrinker.c:662
shrink_one+0x493/0x7c0 mm/vmscan.c:4774
shrink_many mm/vmscan.c:4835 [inline]
lru_gen_shrink_node mm/vmscan.c:4935 [inline]
shrink_node+0x231f/0x3a80 mm/vmscan.c:5894
kswapd_shrink_node mm/vmscan.c:6704 [inline]
balance_pgdat+0x9a0/0x19a0 mm/vmscan.c:6895
kswapd+0x5ea/0xb90 mm/vmscan.c:7164
kthread+0x2c1/0x3a0 kernel/kthread.c:388
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:243

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(fs_reclaim);
lock(&qinf->qi_tree_lock);
lock(fs_reclaim);
lock(&qinf->qi_tree_lock);

*** DEADLOCK ***

1 lock held by kswapd0/109:
#0: ffffffff8d930be0 (fs_reclaim){+.+.}-{0:0}, at: balance_pgdat+0x166/0x19a0 mm/vmscan.c:6782

stack backtrace:
CPU: 3 PID: 109 Comm: kswapd0 Not tainted 6.8.0-syzkaller-11405-g906a93befec8 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:114
check_noncircular+0x31a/0x400 kernel/locking/lockdep.c:2187
check_prev_add kernel/locking/lockdep.c:3134 [inline]
check_prevs_add kernel/locking/lockdep.c:3253 [inline]
validate_chain kernel/locking/lockdep.c:3869 [inline]
__lock_acquire+0x2478/0x3b30 kernel/locking/lockdep.c:5137
lock_acquire kernel/locking/lockdep.c:5754 [inline]
lock_acquire+0x1b1/0x540 kernel/locking/lockdep.c:5719
__mutex_lock_common kernel/locking/mutex.c:608 [inline]
__mutex_lock+0x175/0x9c0 kernel/locking/mutex.c:752
xfs_qm_dqfree_one+0x6f/0x1a0 fs/xfs/xfs_qm.c:1654
xfs_qm_shrink_scan+0x25c/0x3f0 fs/xfs/xfs_qm.c:531
do_shrink_slab+0x44f/0x1160 mm/shrinker.c:435
shrink_slab+0x18a/0x1310 mm/shrinker.c:662
shrink_one+0x493/0x7c0 mm/vmscan.c:4774
shrink_many mm/vmscan.c:4835 [inline]
lru_gen_shrink_node mm/vmscan.c:4935 [inline]
shrink_node+0x231f/0x3a80 mm/vmscan.c:5894
kswapd_shrink_node mm/vmscan.c:6704 [inline]
balance_pgdat+0x9a0/0x19a0 mm/vmscan.c:6895
kswapd+0x5ea/0xb90 mm/vmscan.c:7164
kthread+0x2c1/0x3a0 kernel/kthread.c:388
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:243
</TASK>


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@xxxxxxxxxxxxxxxx.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup