====================================================== WARNING: possible circular locking dependency detected 4.20.0-rc6-next-20181217+ #172 Not tainted ------------------------------------------------------ syz-executor278/7915 is trying to acquire lock: 0000000084634b42 (&mm->mmap_sem){++++}, at: do_user_addr_fault arch/x86/mm/fault.c:1426 [inline] 0000000084634b42 (&mm->mmap_sem){++++}, at: __do_page_fault+0xa0f/0xd70 arch/x86/mm/fault.c:1541 but task is already holding lock: 0000000036fd0791 (&sb->s_type->i_mutex_key#12){+.+.}, at: inode_lock include/linux/fs.h:771 [inline] 0000000036fd0791 (&sb->s_type->i_mutex_key#12){+.+.}, at: generic_file_write_iter+0xe4/0x6b0 mm/filemap.c:3351 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:771 [inline] shmem_fallocate+0x18b/0x12c0 mm/shmem.c:2676 ashmem_shrink_scan+0x238/0x660 drivers/staging/android/ashmem.c:455 ashmem_ioctl+0x3ae/0x13a0 drivers/staging/android/ashmem.c:797 vfs_ioctl fs/ioctl.c:46 [inline] file_ioctl fs/ioctl.c:509 [inline] do_vfs_ioctl+0x1de/0x1790 fs/ioctl.c:696 ksys_ioctl+0xa9/0xd0 fs/ioctl.c:713 __do_sys_ioctl fs/ioctl.c:720 [inline] __se_sys_ioctl fs/ioctl.c:718 [inline] __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe -> #1 (ashmem_mutex){+.+.}: __mutex_lock_common kernel/locking/mutex.c:925 [inline] __mutex_lock+0x166/0x16f0 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:1868 [inline] mmap_region+0xe85/0x1cd0 mm/mmap.c:1786 do_mmap+0xa22/0x1230 mm/mmap.c:1559 do_mmap_pgoff include/linux/mm.h:2421 [inline] vm_mmap_pgoff+0x213/0x2c0 mm/util.c:350 ksys_mmap_pgoff+0x4da/0x660 mm/mmap.c:1609 __do_sys_mmap arch/x86/kernel/sys_x86_64.c:100 [inline] __se_sys_mmap arch/x86/kernel/sys_x86_64.c:91 [inline] __x64_sys_mmap+0xe9/0x1b0 arch/x86/kernel/sys_x86_64.c:91 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe -> #0 (&mm->mmap_sem){++++}: lock_acquire+0x1ed/0x520 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+0xa0f/0xd70 arch/x86/mm/fault.c:1541 do_page_fault+0xf2/0x7e0 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:603 [inline] iov_iter_fault_in_readable+0x1b4/0x450 lib/iov_iter.c:425 generic_perform_write+0x216/0x6a0 mm/filemap.c:3191 __generic_file_write_iter+0x26e/0x630 mm/filemap.c:3326 generic_file_write_iter+0x34d/0x6b0 mm/filemap.c:3354 call_write_iter include/linux/fs.h:1863 [inline] new_sync_write fs/read_write.c:474 [inline] __vfs_write+0x72c/0xab0 fs/read_write.c:487 vfs_write+0x1fc/0x580 fs/read_write.c:549 ksys_write+0x101/0x260 fs/read_write.c:598 __do_sys_write fs/read_write.c:610 [inline] __se_sys_write fs/read_write.c:607 [inline] __x64_sys_write+0x73/0xb0 fs/read_write.c:607 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe 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-executor278/7915: #0: 00000000c3071aba (sb_writers#5){.+.+}, at: file_start_write include/linux/fs.h:2826 [inline] #0: 00000000c3071aba (sb_writers#5){.+.+}, at: vfs_write+0x42a/0x580 fs/read_write.c:548 #1: 0000000036fd0791 (&sb->s_type->i_mutex_key#12){+.+.}, at: inode_lock include/linux/fs.h:771 [inline] #1: 0000000036fd0791 (&sb->s_type->i_mutex_key#12){+.+.}, at: generic_file_write_iter+0xe4/0x6b0 mm/filemap.c:3351 stack backtrace: CPU: 0 PID: 7915 Comm: syz-executor278 Not tainted 4.20.0-rc6-next-20181217+ #172 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+0x244/0x39d lib/dump_stack.c:113 print_circular_bug.isra.36.cold.58+0x1bd/0x27d 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+0x3399/0x4c20 kernel/locking/lockdep.c:3338 lock_acquire+0x1ed/0x520 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+0xa0f/0xd70 arch/x86/mm/fault.c:1541 do_page_fault+0xf2/0x7e0 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:603 [inline] RIP: 0010:iov_iter_fault_in_readable+0x1b4/0x450 lib/iov_iter.c:425 Code: fd 49 39 dc 76 17 eb 3c e8 e9 53 ee fd 49 81 c4 00 10 00 00 4c 39 a5 28 ff ff ff 72 2e e8 d4 53 ee fd 0f 1f 00 0f ae e8 31 db <41> 8a 04 24 0f 1f 00 31 ff 89 de 88 85 58 ff ff ff e8 c6 54 ee fd RSP: 0018:ffff8881b6d1f7d8 EFLAGS: 00010246 RAX: ffff8881d476e580 RBX: 0000000000000000 RCX: ffffffff8392380d RDX: 0000000000000000 RSI: ffffffff8392383c RDI: 0000000000000005 RBP: ffff8881b6d1f8b0 R08: ffff8881d476e580 R09: fffff94000d700ce R10: fffff94000d700ce R11: ffffea0006b80677 R12: 0000000020400000 R13: 0000000000001000 R14: 0000000000001000 R15: ffff8881b6d1fbc8 generic_perform_write+0x216/0x6a0 mm/filemap.c:3191 __generic_file_write_iter+0x26e/0x630 mm/filemap.c:3326 generic_file_write_iter+0x34d/0x6b0 mm/filemap.c:3354 call_write_iter include/linux/fs.h:1863 [inline] new_sync_write fs/read_write.c:474 [inline] __vfs_write+0x72c/0xab0 fs/read_write.c:487 vfs_write+0x1fc/0x580 fs/read_write.c:549 ksys_write+0x101/0x260 fs/read_write.c:598 __do_sys_write fs/read_write.c:610 [inline] __se_sys_write fs/read_write.c:607 [inline] __x64_sys_write+0x73/0xb0 fs/read_write.c:607 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x4496c9 Code: e8 8c bb 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 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 0f 83 4b 00 fc ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007f84338bfce8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00000000006e5a08 RCX: 00000000004496c9 RDX: 00000000ffffff76 RSI: 0000000020000000 RDI: 0000000000000005 RBP: 00000000006e5a00 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006e5a0c R13: 00007ffd40815daf R14: 00007f84338c09c0 R15: 0000000000000000