======================================================
WARNING: possible circular locking dependency detected
5.6.0-rc3-syzkaller #0 Not tainted
------------------------------------------------------
khugepaged/1143 is trying to acquire lock:
ffff888096e9e248 (&sb->s_type->i_mutex_key#13){+.+.}, at: inode_lock include/linux/fs.h:791 [inline]
ffff888096e9e248 (&sb->s_type->i_mutex_key#13){+.+.}, at: shmem_fallocate+0x15a/0xd40 mm/shmem.c:2736

but task is already holding lock:
ffffffff89c510e0 (fs_reclaim){+.+.}, at: fs_reclaim_acquire.part.0+0x0/0x30 include/linux/uaccess.h:173

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (fs_reclaim){+.+.}:
       __fs_reclaim_acquire mm/page_alloc.c:4073 [inline]
       fs_reclaim_acquire.part.0+0x24/0x30 mm/page_alloc.c:4084
       fs_reclaim_acquire mm/page_alloc.c:4670 [inline]
       prepare_alloc_pages mm/page_alloc.c:4667 [inline]
       __alloc_pages_nodemask+0x52d/0x910 mm/page_alloc.c:4719
       alloc_pages_vma+0xdd/0x620 mm/mempolicy.c:2174
       shmem_alloc_page+0xc0/0x180 mm/shmem.c:1499
       shmem_alloc_and_acct_page+0x165/0x990 mm/shmem.c:1524
       shmem_getpage_gfp+0x56d/0x29b0 mm/shmem.c:1838
       shmem_getpage mm/shmem.c:154 [inline]
       shmem_write_begin+0x105/0x1e0 mm/shmem.c:2488
       generic_perform_write+0x23b/0x540 mm/filemap.c:3287
       __generic_file_write_iter+0x25e/0x630 mm/filemap.c:3416
       generic_file_write_iter+0x420/0x68e mm/filemap.c:3448
       call_write_iter include/linux/fs.h:1901 [inline]
       new_sync_write+0x4d3/0x770 fs/read_write.c:483
       __vfs_write+0xe1/0x110 fs/read_write.c:496
       vfs_write+0x268/0x5d0 fs/read_write.c:558
       ksys_write+0x14f/0x290 fs/read_write.c:611
       __do_sys_write fs/read_write.c:623 [inline]
       __se_sys_write fs/read_write.c:620 [inline]
       __x64_sys_write+0x73/0xb0 fs/read_write.c:620
       do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #0 (&sb->s_type->i_mutex_key#13){+.+.}:
       check_prev_add kernel/locking/lockdep.c:2475 [inline]
       check_prevs_add kernel/locking/lockdep.c:2580 [inline]
       validate_chain kernel/locking/lockdep.c:2970 [inline]
       __lock_acquire+0x2596/0x4a00 kernel/locking/lockdep.c:3954
       lock_acquire+0x190/0x410 kernel/locking/lockdep.c:4484
       down_write+0x93/0x150 kernel/locking/rwsem.c:1534
       inode_lock include/linux/fs.h:791 [inline]
       shmem_fallocate+0x15a/0xd40 mm/shmem.c:2736
       ashmem_shrink_scan drivers/staging/android/ashmem.c:490 [inline]
       ashmem_shrink_scan+0x370/0x510 drivers/staging/android/ashmem.c:465
       do_shrink_slab+0x40f/0xad0 mm/vmscan.c:512
       shrink_slab mm/vmscan.c:673 [inline]
       shrink_slab+0x19a/0x680 mm/vmscan.c:646
       shrink_node_memcgs mm/vmscan.c:2676 [inline]
       shrink_node+0x46a/0x1ad0 mm/vmscan.c:2780
       shrink_zones mm/vmscan.c:2983 [inline]
       do_try_to_free_pages+0x3ba/0x14f0 mm/vmscan.c:3036
       try_to_free_pages+0x2dc/0x970 mm/vmscan.c:3275
       __perform_reclaim mm/page_alloc.c:4113 [inline]
       __alloc_pages_direct_reclaim mm/page_alloc.c:4134 [inline]
       __alloc_pages_slowpath+0x97e/0x2900 mm/page_alloc.c:4537
       __alloc_pages_nodemask+0x646/0x910 mm/page_alloc.c:4751
       __alloc_pages include/linux/gfp.h:496 [inline]
       __alloc_pages_node include/linux/gfp.h:509 [inline]
       khugepaged_alloc_page+0xa7/0x170 mm/khugepaged.c:785
       collapse_huge_page+0x13e/0x41f0 mm/khugepaged.c:974
       khugepaged_scan_pmd mm/khugepaged.c:1232 [inline]
       khugepaged_scan_mm_slot mm/khugepaged.c:2002 [inline]
       khugepaged_do_scan mm/khugepaged.c:2083 [inline]
       khugepaged+0x3604/0x44e0 mm/khugepaged.c:2128
       kthread+0x361/0x430 kernel/kthread.c:255
       ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(fs_reclaim);
                               lock(&sb->s_type->i_mutex_key#13);
                               lock(fs_reclaim);
  lock(&sb->s_type->i_mutex_key#13);

 *** DEADLOCK ***

2 locks held by khugepaged/1143:
 #0: ffffffff89c510e0 (fs_reclaim){+.+.}, at: fs_reclaim_acquire.part.0+0x0/0x30 include/linux/uaccess.h:173
 #1: ffffffff89c2c788 (shrinker_rwsem){++++}, at: shrink_slab mm/vmscan.c:663 [inline]
 #1: ffffffff89c2c788 (shrinker_rwsem){++++}, at: shrink_slab+0xe6/0x680 mm/vmscan.c:646

stack backtrace:
CPU: 0 PID: 1143 Comm: khugepaged Not tainted 5.6.0-rc3-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x197/0x210 lib/dump_stack.c:118
 print_circular_bug.isra.0.cold+0x163/0x172 kernel/locking/lockdep.c:1684
 check_noncircular+0x32e/0x3e0 kernel/locking/lockdep.c:1808
 check_prev_add kernel/locking/lockdep.c:2475 [inline]
 check_prevs_add kernel/locking/lockdep.c:2580 [inline]
 validate_chain kernel/locking/lockdep.c:2970 [inline]
 __lock_acquire+0x2596/0x4a00 kernel/locking/lockdep.c:3954
 lock_acquire+0x190/0x410 kernel/locking/lockdep.c:4484
 down_write+0x93/0x150 kernel/locking/rwsem.c:1534
 inode_lock include/linux/fs.h:791 [inline]
 shmem_fallocate+0x15a/0xd40 mm/shmem.c:2736
 ashmem_shrink_scan drivers/staging/android/ashmem.c:490 [inline]
 ashmem_shrink_scan+0x370/0x510 drivers/staging/android/ashmem.c:465
 do_shrink_slab+0x40f/0xad0 mm/vmscan.c:512
 shrink_slab mm/vmscan.c:673 [inline]
 shrink_slab+0x19a/0x680 mm/vmscan.c:646
 shrink_node_memcgs mm/vmscan.c:2676 [inline]
 shrink_node+0x46a/0x1ad0 mm/vmscan.c:2780
 shrink_zones mm/vmscan.c:2983 [inline]
 do_try_to_free_pages+0x3ba/0x14f0 mm/vmscan.c:3036
 try_to_free_pages+0x2dc/0x970 mm/vmscan.c:3275
 __perform_reclaim mm/page_alloc.c:4113 [inline]
 __alloc_pages_direct_reclaim mm/page_alloc.c:4134 [inline]
 __alloc_pages_slowpath+0x97e/0x2900 mm/page_alloc.c:4537
 __alloc_pages_nodemask+0x646/0x910 mm/page_alloc.c:4751
 __alloc_pages include/linux/gfp.h:496 [inline]
 __alloc_pages_node include/linux/gfp.h:509 [inline]
 khugepaged_alloc_page+0xa7/0x170 mm/khugepaged.c:785
 collapse_huge_page+0x13e/0x41f0 mm/khugepaged.c:974
 khugepaged_scan_pmd mm/khugepaged.c:1232 [inline]
 khugepaged_scan_mm_slot mm/khugepaged.c:2002 [inline]
 khugepaged_do_scan mm/khugepaged.c:2083 [inline]
 khugepaged+0x3604/0x44e0 mm/khugepaged.c:2128
 kthread+0x361/0x430 kernel/kthread.c:255
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352