======================================================
WARNING: possible circular locking dependency detected
6.5.0-rc1-next-20230714-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.5/14106 is trying to acquire lock:
ffff88801ef4f418 (&info->lock){....}-{2:2}, at: shmem_uncharge+0x28/0x2b0 mm/shmem.c:450

but task is already holding lock:
ffff888020006068 (&lruvec->lru_lock){....}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
ffff888020006068 (&lruvec->lru_lock){....}-{2:2}, at: folio_lruvec_lock+0x1ba/0x3b0 mm/memcontrol.c:1323

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&lruvec->lru_lock){....}-{2:2}:
       __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
       _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
       spin_lock include/linux/spinlock.h:351 [inline]
       folio_lruvec_lock+0x1ba/0x3b0 mm/memcontrol.c:1323
       __split_huge_page mm/huge_memory.c:2538 [inline]
       split_huge_page_to_list+0x103b/0x49e0 mm/huge_memory.c:2772
       split_folio_to_list include/linux/huge_mm.h:400 [inline]
       shrink_folio_list+0x24c3/0x3dc0 mm/vmscan.c:1927
       reclaim_folio_list+0xe4/0x3a0 mm/vmscan.c:2801
       reclaim_pages+0x483/0x6a0 mm/vmscan.c:2837
       madvise_cold_or_pageout_pte_range+0x1174/0x1f20 mm/madvise.c:430
       walk_pmd_range mm/pagewalk.c:140 [inline]
       walk_pud_range mm/pagewalk.c:218 [inline]
       walk_p4d_range mm/pagewalk.c:253 [inline]
       walk_pgd_range+0xa36/0x1770 mm/pagewalk.c:290
       __walk_page_range+0x62e/0x770 mm/pagewalk.c:392
       walk_page_range+0x3b2/0x470 mm/pagewalk.c:490
       madvise_pageout_page_range mm/madvise.c:591 [inline]
       madvise_pageout+0x317/0x570 mm/madvise.c:618
       madvise_vma_behavior+0x1ce/0x1e60 mm/madvise.c:1039
       madvise_walk_vmas+0x1cf/0x2c0 mm/madvise.c:1268
       do_madvise+0x333/0x660 mm/madvise.c:1448
       __do_sys_madvise mm/madvise.c:1461 [inline]
       __se_sys_madvise mm/madvise.c:1459 [inline]
       __x64_sys_madvise+0xaa/0x110 mm/madvise.c:1459
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #2 (&xa->xa_lock#8){..-.}-{2:2}:
       __raw_spin_lock_irq include/linux/spinlock_api_smp.h:119 [inline]
       _raw_spin_lock_irq+0x36/0x50 kernel/locking/spinlock.c:170
       spin_lock_irq include/linux/spinlock.h:376 [inline]
       filemap_remove_folio+0xbf/0x250 mm/filemap.c:259
       truncate_inode_folio+0x49/0x70 mm/truncate.c:195
       shmem_undo_range+0x363/0x1190 mm/shmem.c:1004
       shmem_truncate_range mm/shmem.c:1120 [inline]
       shmem_evict_inode+0x334/0xb10 mm/shmem.c:1250
       evict+0x2ed/0x6b0 fs/inode.c:665
       iput_final fs/inode.c:1791 [inline]
       iput.part.0+0x55e/0x7a0 fs/inode.c:1817
       iput+0x5c/0x80 fs/inode.c:1807
       dentry_unlink_inode+0x292/0x430 fs/dcache.c:401
       __dentry_kill+0x3b8/0x640 fs/dcache.c:607
       dentry_kill fs/dcache.c:745 [inline]
       dput+0x703/0xfd0 fs/dcache.c:913
       do_renameat2+0xc4c/0xdc0 fs/namei.c:5011
       __do_sys_rename fs/namei.c:5055 [inline]
       __se_sys_rename fs/namei.c:5053 [inline]
       __x64_sys_rename+0x81/0xa0 fs/namei.c:5053
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #1 (&sb->s_type->i_lock_key){+.+.}-{2:2}:
       __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
       _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
       spin_lock include/linux/spinlock.h:351 [inline]
       inode_sub_bytes+0x28/0x100 fs/stat.c:816
       __dquot_free_space+0x8f7/0xaf0 fs/quota/dquot.c:1881
       dquot_free_space_nodirty include/linux/quotaops.h:379 [inline]
       dquot_free_block_nodirty include/linux/quotaops.h:390 [inline]
       shmem_inode_unacct_blocks mm/shmem.c:243 [inline]
       shmem_recalc_inode+0x196/0x350 mm/shmem.c:420
       shmem_undo_range+0x558/0x1190 mm/shmem.c:1114
       shmem_truncate_range mm/shmem.c:1120 [inline]
       shmem_evict_inode+0x334/0xb10 mm/shmem.c:1250
       evict+0x2ed/0x6b0 fs/inode.c:665
       iput_final fs/inode.c:1791 [inline]
       iput.part.0+0x55e/0x7a0 fs/inode.c:1817
       iput+0x5c/0x80 fs/inode.c:1807
       dentry_unlink_inode+0x292/0x430 fs/dcache.c:401
       __dentry_kill+0x3b8/0x640 fs/dcache.c:607
       dentry_kill fs/dcache.c:745 [inline]
       dput+0x703/0xfd0 fs/dcache.c:913
       do_renameat2+0xc4c/0xdc0 fs/namei.c:5011
       __do_sys_rename fs/namei.c:5055 [inline]
       __se_sys_rename fs/namei.c:5053 [inline]
       __x64_sys_rename+0x81/0xa0 fs/namei.c:5053
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 (&info->lock){....}-{2:2}:
       check_prev_add kernel/locking/lockdep.c:3142 [inline]
       check_prevs_add kernel/locking/lockdep.c:3261 [inline]
       validate_chain kernel/locking/lockdep.c:3876 [inline]
       __lock_acquire+0x2e3d/0x5de0 kernel/locking/lockdep.c:5144
       lock_acquire kernel/locking/lockdep.c:5761 [inline]
       lock_acquire+0x1ae/0x510 kernel/locking/lockdep.c:5726
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0x3a/0x50 kernel/locking/spinlock.c:162
       shmem_uncharge+0x28/0x2b0 mm/shmem.c:450
       __split_huge_page mm/huge_memory.c:2549 [inline]
       split_huge_page_to_list+0x3832/0x49e0 mm/huge_memory.c:2772
       split_folio_to_list include/linux/huge_mm.h:400 [inline]
       shrink_folio_list+0x24c3/0x3dc0 mm/vmscan.c:1927
       reclaim_folio_list+0xe4/0x3a0 mm/vmscan.c:2801
       reclaim_pages+0x483/0x6a0 mm/vmscan.c:2837
       madvise_cold_or_pageout_pte_range+0x1174/0x1f20 mm/madvise.c:430
       walk_pmd_range mm/pagewalk.c:140 [inline]
       walk_pud_range mm/pagewalk.c:218 [inline]
       walk_p4d_range mm/pagewalk.c:253 [inline]
       walk_pgd_range+0xa36/0x1770 mm/pagewalk.c:290
       __walk_page_range+0x62e/0x770 mm/pagewalk.c:392
       walk_page_range+0x3b2/0x470 mm/pagewalk.c:490
       madvise_pageout_page_range mm/madvise.c:591 [inline]
       madvise_pageout+0x317/0x570 mm/madvise.c:618
       madvise_vma_behavior+0x1ce/0x1e60 mm/madvise.c:1039
       madvise_walk_vmas+0x1cf/0x2c0 mm/madvise.c:1268
       do_madvise+0x333/0x660 mm/madvise.c:1448
       __do_sys_madvise mm/madvise.c:1461 [inline]
       __se_sys_madvise mm/madvise.c:1459 [inline]
       __x64_sys_madvise+0xaa/0x110 mm/madvise.c:1459
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

other info that might help us debug this:

Chain exists of:
  &info->lock --> &xa->xa_lock#8 --> &lruvec->lru_lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&lruvec->lru_lock);
                               lock(&xa->xa_lock#8);
                               lock(&lruvec->lru_lock);
  lock(&info->lock);

 *** DEADLOCK ***

4 locks held by syz-executor.5/14106:
 #0: ffff888013b91e20 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock include/linux/mmap_lock.h:132 [inline]
 #0: ffff888013b91e20 (&mm->mmap_lock){++++}-{3:3}, at: do_madvise+0x4ae/0x660 mm/madvise.c:1441
 #1: ffff88801ef4f9b0 (&mapping->i_mmap_rwsem){++++}-{3:3}, at: i_mmap_lock_read include/linux/fs.h:501 [inline]
 #1: ffff88801ef4f9b0 (&mapping->i_mmap_rwsem){++++}-{3:3}, at: split_huge_page_to_list+0x7d5/0x49e0 mm/huge_memory.c:2712
 #2: ffff88801ef4f820 (&xa->xa_lock#8){..-.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
 #2: ffff88801ef4f820 (&xa->xa_lock#8){..-.}-{2:2}, at: split_huge_page_to_list+0x980/0x49e0 mm/huge_memory.c:2744
 #3: ffff888020006068 (&lruvec->lru_lock){....}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
 #3: ffff888020006068 (&lruvec->lru_lock){....}-{2:2}, at: folio_lruvec_lock+0x1ba/0x3b0 mm/memcontrol.c:1323

stack backtrace:
CPU: 1 PID: 14106 Comm: syz-executor.5 Not tainted 6.5.0-rc1-next-20230714-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/03/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
 check_noncircular+0x311/0x3f0 kernel/locking/lockdep.c:2195
 check_prev_add kernel/locking/lockdep.c:3142 [inline]
 check_prevs_add kernel/locking/lockdep.c:3261 [inline]
 validate_chain kernel/locking/lockdep.c:3876 [inline]
 __lock_acquire+0x2e3d/0x5de0 kernel/locking/lockdep.c:5144
 lock_acquire kernel/locking/lockdep.c:5761 [inline]
 lock_acquire+0x1ae/0x510 kernel/locking/lockdep.c:5726
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0x3a/0x50 kernel/locking/spinlock.c:162
 shmem_uncharge+0x28/0x2b0 mm/shmem.c:450
 __split_huge_page mm/huge_memory.c:2549 [inline]
 split_huge_page_to_list+0x3832/0x49e0 mm/huge_memory.c:2772
 split_folio_to_list include/linux/huge_mm.h:400 [inline]
 shrink_folio_list+0x24c3/0x3dc0 mm/vmscan.c:1927
 reclaim_folio_list+0xe4/0x3a0 mm/vmscan.c:2801
 reclaim_pages+0x483/0x6a0 mm/vmscan.c:2837
 madvise_cold_or_pageout_pte_range+0x1174/0x1f20 mm/madvise.c:430
 walk_pmd_range mm/pagewalk.c:140 [inline]
 walk_pud_range mm/pagewalk.c:218 [inline]
 walk_p4d_range mm/pagewalk.c:253 [inline]
 walk_pgd_range+0xa36/0x1770 mm/pagewalk.c:290
 __walk_page_range+0x62e/0x770 mm/pagewalk.c:392
 walk_page_range+0x3b2/0x470 mm/pagewalk.c:490
 madvise_pageout_page_range mm/madvise.c:591 [inline]
 madvise_pageout+0x317/0x570 mm/madvise.c:618
 madvise_vma_behavior+0x1ce/0x1e60 mm/madvise.c:1039
 madvise_walk_vmas+0x1cf/0x2c0 mm/madvise.c:1268
 do_madvise+0x333/0x660 mm/madvise.c:1448
 __do_sys_madvise mm/madvise.c:1461 [inline]
 __se_sys_madvise mm/madvise.c:1459 [inline]
 __x64_sys_madvise+0xaa/0x110 mm/madvise.c:1459
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f9bbe67cb29
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f9bbf3bc0c8 EFLAGS: 00000246 ORIG_RAX: 000000000000001c
RAX: ffffffffffffffda RBX: 00007f9bbe79bf80 RCX: 00007f9bbe67cb29
RDX: 0000000000000015 RSI: 0000000000600003 RDI: 0000000020000000
RBP: 00007f9bbe6c847a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f9bbe79bf80 R15: 00007ffcef04f108
 </TASK>