====================================================== WARNING: possible circular locking dependency detected 4.20.0+ #11 Not tainted ------------------------------------------------------ syz-executor400/8644 is trying to acquire lock: 000000008d2e159b (&mm->mmap_sem){++++}, at: do_user_addr_fault arch/x86/mm/fault.c:1426 [inline] 000000008d2e159b (&mm->mmap_sem){++++}, at: __do_page_fault+0x9c2/0xd60 arch/x86/mm/fault.c:1541 but task is already holding lock: 000000006a106cf5 (&sb->s_type->i_mutex_key#12){+.+.}, at: inode_lock include/linux/fs.h:757 [inline] 000000006a106cf5 (&sb->s_type->i_mutex_key#12){+.+.}, at: generic_file_write_iter+0xe5/0x6a0 mm/filemap.c:3358 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (&sb->s_type->i_mutex_key#12){+.+.}: down_write+0x8a/0x130 kernel/locking/rwsem.c:70 inode_lock include/linux/fs.h:757 [inline] shmem_fallocate+0x168/0x1200 mm/shmem.c:2633 ashmem_shrink_scan drivers/staging/android/ashmem.c:455 [inline] ashmem_shrink_scan+0x239/0x630 drivers/staging/android/ashmem.c:439 ashmem_ioctl+0x38a/0x12c0 drivers/staging/android/ashmem.c:797 compat_ashmem_ioctl+0x53/0x63 drivers/staging/android/ashmem.c:818 __do_compat_sys_ioctl fs/compat_ioctl.c:1052 [inline] __se_compat_sys_ioctl fs/compat_ioctl.c:998 [inline] __ia32_compat_sys_ioctl+0x197/0x620 fs/compat_ioctl.c:998 do_syscall_32_irqs_on arch/x86/entry/common.c:326 [inline] do_fast_syscall_32+0x333/0xf98 arch/x86/entry/common.c:397 entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139 -> #1 (ashmem_mutex){+.+.}: __mutex_lock_common kernel/locking/mutex.c:925 [inline] __mutex_lock+0x12f/0x1670 kernel/locking/mutex.c:1072 mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1087 ashmem_mmap+0x55/0x520 drivers/staging/android/ashmem.c:361 call_mmap include/linux/fs.h:1867 [inline] mmap_region+0xde5/0x1ca0 mm/mmap.c:1786 do_mmap+0xa09/0x1220 mm/mmap.c:1559 do_mmap_pgoff include/linux/mm.h:2379 [inline] vm_mmap_pgoff+0x20b/0x2b0 mm/util.c:350 ksys_mmap_pgoff+0x4f8/0x650 mm/mmap.c:1609 __do_sys_mmap_pgoff mm/mmap.c:1620 [inline] __se_sys_mmap_pgoff mm/mmap.c:1616 [inline] __ia32_sys_mmap_pgoff+0xdd/0x1a0 mm/mmap.c:1616 do_syscall_32_irqs_on arch/x86/entry/common.c:326 [inline] do_fast_syscall_32+0x333/0xf98 arch/x86/entry/common.c:397 entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139 -> #0 (&mm->mmap_sem){++++}: lock_acquire+0x1db/0x570 kernel/locking/lockdep.c:3841 down_read+0x8d/0x120 kernel/locking/rwsem.c:24 do_user_addr_fault arch/x86/mm/fault.c:1426 [inline] __do_page_fault+0x9c2/0xd60 arch/x86/mm/fault.c:1541 do_page_fault+0xe6/0x7d8 arch/x86/mm/fault.c:1572 page_fault+0x1e/0x30 arch/x86/entry/entry_64.S:1143 fault_in_pages_readable include/linux/pagemap.h:611 [inline] iov_iter_fault_in_readable+0x377/0x450 lib/iov_iter.c:425 generic_perform_write+0x202/0x6b0 mm/filemap.c:3198 __generic_file_write_iter+0x25e/0x630 mm/filemap.c:3333 generic_file_write_iter+0x34e/0x6a0 mm/filemap.c:3361 call_write_iter include/linux/fs.h:1862 [inline] new_sync_write fs/read_write.c:474 [inline] __vfs_write+0x764/0xb40 fs/read_write.c:487 vfs_write+0x20c/0x580 fs/read_write.c:549 ksys_write+0x105/0x260 fs/read_write.c:598 __do_sys_write fs/read_write.c:610 [inline] __se_sys_write fs/read_write.c:607 [inline] __ia32_sys_write+0x71/0xb0 fs/read_write.c:607 do_syscall_32_irqs_on arch/x86/entry/common.c:326 [inline] do_fast_syscall_32+0x333/0xf98 arch/x86/entry/common.c:397 entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139 other info that might help us debug this: Chain exists of: &mm->mmap_sem --> ashmem_mutex --> &sb->s_type->i_mutex_key#12 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&sb->s_type->i_mutex_key#12); lock(ashmem_mutex); lock(&sb->s_type->i_mutex_key#12); lock(&mm->mmap_sem); *** DEADLOCK *** 2 locks held by syz-executor400/8644: #0: 000000009384c075 (sb_writers#5){.+.+}, at: file_start_write include/linux/fs.h:2815 [inline] #0: 000000009384c075 (sb_writers#5){.+.+}, at: vfs_write+0x429/0x580 fs/read_write.c:548 #1: 000000006a106cf5 (&sb->s_type->i_mutex_key#12){+.+.}, at: inode_lock include/linux/fs.h:757 [inline] #1: 000000006a106cf5 (&sb->s_type->i_mutex_key#12){+.+.}, at: generic_file_write_iter+0xe5/0x6a0 mm/filemap.c:3358 stack backtrace: CPU: 0 PID: 8644 Comm: syz-executor400 Not tainted 4.20.0+ #11 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+0x1db/0x2d0 lib/dump_stack.c:113 print_circular_bug.isra.0.cold+0x1cc/0x28f kernel/locking/lockdep.c:1224 check_prev_add kernel/locking/lockdep.c:1866 [inline] check_prevs_add kernel/locking/lockdep.c:1979 [inline] validate_chain kernel/locking/lockdep.c:2350 [inline] __lock_acquire+0x3014/0x4a30 kernel/locking/lockdep.c:3338 lock_acquire+0x1db/0x570 kernel/locking/lockdep.c:3841 down_read+0x8d/0x120 kernel/locking/rwsem.c:24 do_user_addr_fault arch/x86/mm/fault.c:1426 [inline] __do_page_fault+0x9c2/0xd60 arch/x86/mm/fault.c:1541 do_page_fault+0xe6/0x7d8 arch/x86/mm/fault.c:1572 page_fault+0x1e/0x30 arch/x86/entry/entry_64.S:1143 RIP: 0010:fault_in_pages_readable include/linux/pagemap.h:611 [inline] RIP: 0010:iov_iter_fault_in_readable+0x377/0x450 lib/iov_iter.c:425 Code: 89 f6 41 88 57 e0 e8 18 ad f3 fd 45 85 f6 74 c1 e9 70 fe ff ff e8 89 ab f3 fd 0f 1f 00 0f ae e8 44 89 f0 48 8b 8d 68 ff ff ff <8a> 11 89 c3 0f 1f 00 41 88 57 d0 31 ff 89 de e8 e5 ac f3 fd 85 db RSP: 0018:ffff8880a0bf7878 EFLAGS: 00010293 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000020e8623f RDX: 0000000000000000 RSI: ffffffff838e4d07 RDI: 0000000000000007 RBP: ffff8880a0bf7918 R08: ffff88808c3b81c0 R09: fffff94000496237 R10: fffff94000496236 R11: ffffea00024b11b7 R12: 0000000000001000 R13: 0000000000001000 R14: 0000000000000000 R15: ffff8880a0bf78f0 generic_perform_write+0x202/0x6b0 mm/filemap.c:3198 __generic_file_write_iter+0x25e/0x630 mm/filemap.c:3333 generic_file_write_iter+0x34e/0x6a0 mm/filemap.c:3361 call_write_iter include/linux/fs.h:1862 [inline] new_sync_write fs/read_write.c:474 [inline] __vfs_write+0x764/0xb40 fs/read_write.c:487 vfs_write+0x20c/0x580 fs/read_write.c:549 ksys_write+0x105/0x260 fs/read_write.c:598 __do_sys_write fs/read_write.c:610 [inline] __se_sys_write fs/read_write.c:607 [inline] __ia32_sys_write+0x71/0xb0 fs/read_write.c:607 do_syscall_32_irqs_on arch/x86/entry/common.c:326 [inline] do_fast_syscall_32+0x333/0xf98 arch/x86/entry/common.c:397 entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139 RIP: 0023:0xf7f73869 Code: 85 d2 74 02 89 0a 5b 5d c3 8b 04 24 c3 8b 14 24 c3 8b 3c 24 c3 90 90 90 90 90 90 90 90 90 90 90 90 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 eb 0d 90 90 90 90 90 90 90 90 90 90 90 90 RSP: 002b:00000000f7f6f1dc EFLAGS: 00000246 ORIG_RAX: 0000000000000004 RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 0000000020004240 RDX: 00000000fffffe48 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000