syzbot


possible deadlock in __do_page_fault

Status: fixed on 2019/03/28 12:00
Subsystems: fs mm
[Documentation on labels]
Reported-by: syzbot+a76129f18c89f3e2ddd4@syzkaller.appspotmail.com
Fix commit: fb4415a12632 staging: android: ashmem: Don't call fallocate() with ashmem_mutex held.
First crash: 2256d, last: 2088d
Discussions (4)
Title Replies (including bot) Last reply
[PATCH 5.0 00/46] 5.0.1-stable review 59 (59) 2019/03/12 09:50
[PATCH 4.20 00/76] 4.20.15-stable review 81 (81) 2019/03/09 22:35
[PATCH 4.19 00/68] 4.19.28-stable review 73 (73) 2019/03/09 22:35
possible deadlock in __do_page_fault 19 (22) 2019/01/29 10:44
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-414 possible deadlock in __do_page_fault C 3356 1816d 2053d 0/1 public: reported C repro on 2019/04/11 00:00
android-49 possible deadlock in __do_page_fault C 801 1816d 2053d 0/3 public: reported C repro on 2019/04/11 08:44
upstream possible deadlock in __do_page_fault (2) ext4 C done 8 1998d 2002d 0/28 closed as invalid on 2019/06/23 22:18

Sample crash report:
audit: type=1800 audit(1550843132.995:30): pid=7392 uid=0 auid=4294967295 ses=4294967295 subj=_ op=collect_data cause=failed(directio) comm="startpar" name="rmnologin" dev="sda1" ino=2423 res=0
hrtimer: interrupt took 45763 ns
======================================================
WARNING: possible circular locking dependency detected
5.0.0-rc7+ #82 Not tainted
------------------------------------------------------
syz-executor443/7546 is trying to acquire lock:
000000002c294172 (&mm->mmap_sem){++++}, at: do_user_addr_fault arch/x86/mm/fault.c:1426 [inline]
000000002c294172 (&mm->mmap_sem){++++}, at: __do_page_fault+0x9c2/0xd60 arch/x86/mm/fault.c:1541

but task is already holding lock:
00000000aff3c791 (&sb->s_type->i_mutex_key#11){+.+.}, at: inode_lock include/linux/fs.h:757 [inline]
00000000aff3c791 (&sb->s_type->i_mutex_key#11){+.+.}, at: generic_file_write_iter+0xdf/0x610 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#11){+.+.}:
       down_write+0x38/0x90 kernel/locking/rwsem.c:70
       inode_lock include/linux/fs.h:757 [inline]
       shmem_fallocate+0x15a/0xc60 mm/shmem.c:2633
       ashmem_shrink_scan drivers/staging/android/ashmem.c:455 [inline]
       ashmem_shrink_scan+0x1d7/0x4f0 drivers/staging/android/ashmem.c:439
       ashmem_ioctl+0x2f0/0x11a0 drivers/staging/android/ashmem.c:797
       vfs_ioctl fs/ioctl.c:46 [inline]
       file_ioctl fs/ioctl.c:509 [inline]
       do_vfs_ioctl+0xd6e/0x1390 fs/ioctl.c:696
       ksys_ioctl+0xab/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+0x103/0x610 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+0xf7/0x1310 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+0xc37/0x1760 mm/mmap.c:1786
       do_mmap+0x8e2/0x1080 mm/mmap.c:1559
       do_mmap_pgoff include/linux/mm.h:2379 [inline]
       vm_mmap_pgoff+0x1c5/0x230 mm/util.c:350
       ksys_mmap_pgoff+0x4aa/0x630 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+0x103/0x610 arch/x86/entry/common.c:290
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #0 (&mm->mmap_sem){++++}:
       lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:3841
       down_read+0x3b/0x90 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+0x71/0x581 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+0x195/0x530 mm/filemap.c:3198
       __generic_file_write_iter+0x25e/0x630 mm/filemap.c:3333
       generic_file_write_iter+0x360/0x610 mm/filemap.c:3361
       call_write_iter include/linux/fs.h:1863 [inline]
       new_sync_write fs/read_write.c:474 [inline]
       __vfs_write+0x613/0x8e0 fs/read_write.c:487
       vfs_write+0x20c/0x580 fs/read_write.c:549
       ksys_write+0xea/0x1f0 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+0x103/0x610 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#11

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&sb->s_type->i_mutex_key#11);
                               lock(ashmem_mutex);
                               lock(&sb->s_type->i_mutex_key#11);
  lock(&mm->mmap_sem);

 *** DEADLOCK ***

2 locks held by syz-executor443/7546:
 #0: 000000003fdabbab (sb_writers#5){.+.+}, at: file_start_write include/linux/fs.h:2816 [inline]
 #0: 000000003fdabbab (sb_writers#5){.+.+}, at: vfs_write+0x429/0x580 fs/read_write.c:548
 #1: 00000000aff3c791 (&sb->s_type->i_mutex_key#11){+.+.}, at: inode_lock include/linux/fs.h:757 [inline]
 #1: 00000000aff3c791 (&sb->s_type->i_mutex_key#11){+.+.}, at: generic_file_write_iter+0xdf/0x610 mm/filemap.c:3358

stack backtrace:
CPU: 1 PID: 7546 Comm: syz-executor443 Not tainted 5.0.0-rc7+ #82
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+0x172/0x1f0 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+0x2f00/0x4700 kernel/locking/lockdep.c:3338
 lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:3841
 down_read+0x3b/0x90 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+0x71/0x581 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 b8 2b 47 fe 45 85 f6 74 c1 e9 70 fe ff ff e8 29 2a 47 fe 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 85 2b 47 fe 85 db
RSP: 0018:ffff8880a3ed79b8 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000020e3f53f
RDX: 0000000000000000 RSI: ffffffff8328b757 RDI: 0000000000000007
RBP: ffff8880a3ed7a58 R08: ffff8880a1796300 R09: fffff94000445f67
R10: fffff94000445f66 R11: ffffea000222fb37 R12: 0000000000001000
R13: 0000000000001000 R14: 0000000000000000 R15: ffff8880a3ed7a30
 generic_perform_write+0x195/0x530 mm/filemap.c:3198
 __generic_file_write_iter+0x25e/0x630 mm/filemap.c:3333
 generic_file_write_iter+0x360/0x610 mm/filemap.c:3361
 call_write_iter include/linux/fs.h:1863 [inline]
 new_sync_write fs/read_write.c:474 [inline]
 __vfs_write+0x613/0x8e0 fs/read_write.c:487
 vfs_write+0x20c/0x580 fs/read_write.c:549
 ksys_write+0xea/0x1f0 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+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4469a9
Code: e8 bc b9 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 fb 07 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f7bedf8edb8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00000000006dcc28 RCX: 00000000004469a9
RDX: 00000000fffffda2 RSI: 0000000020000540 RDI: 0000000000000005
RBP: 00000000006dcc20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dcc2c
R13: 00007ffe47da6d2f R14: 00007f7bedf8f9c0 R15: 20c49ba5e353f7cf

Crashes (820):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/02/22 13:48 upstream 8a61716ff2ab 6a5fcca4 .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/02/22 01:49 upstream 8a61716ff2ab 7ff74a98 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/02/22 01:45 upstream 8a61716ff2ab 7ff74a98 .config console log report syz C ci-upstream-kasan-gce-root
2019/02/12 13:08 upstream aa0c38cf39de 65a0d619 .config console log report syz C ci-upstream-kasan-gce-root
2019/02/12 11:21 upstream aa0c38cf39de 65a0d619 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/02/05 00:48 upstream 8834f5600cf3 d672172c .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/02/04 22:39 upstream 8834f5600cf3 d672172c .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/02/04 21:21 upstream 8834f5600cf3 d672172c .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/02/03 10:16 upstream 12491ed354d2 c198d5dd .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/02/03 08:09 upstream 12491ed354d2 c198d5dd .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/02/03 07:12 upstream 12491ed354d2 c198d5dd .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/02/03 06:38 upstream 12491ed354d2 c198d5dd .config console log report syz C ci-upstream-kasan-gce-root
2019/02/03 06:01 upstream 12491ed354d2 c198d5dd .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/02/03 05:53 upstream 12491ed354d2 c198d5dd .config console log report syz C ci-upstream-kasan-gce-root
2019/02/01 15:44 upstream 5b4746a03199 0c07abcf .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/02/01 13:57 upstream 5b4746a03199 0c07abcf .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/02/01 13:24 upstream 5b4746a03199 0c07abcf .config console log report syz C ci-upstream-kasan-gce-root
2019/02/01 06:48 upstream 9f789567142c 0e8ea0a3 .config console log report syz C ci-upstream-kasan-gce-root
2019/02/01 05:26 upstream 9f789567142c 0e8ea0a3 .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/01/06 03:32 upstream f1c2f8857c5a 53be0a37 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/01/04 18:38 upstream 96d4f267e40f 0127e3ba .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/01/04 11:57 upstream 645ff1e8e704 7da23925 .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/01/04 08:56 upstream 645ff1e8e704 7da23925 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/01/04 05:46 upstream 645ff1e8e704 7da23925 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/01/03 19:38 upstream 645ff1e8e704 66fcd29b .config console log report syz C ci-upstream-kasan-gce-root
2018/12/21 15:22 upstream 9097a058d49e 588075e6 .config console log report syz C ci-upstream-kasan-gce-smack-root
2018/12/21 15:22 upstream 9097a058d49e 588075e6 .config console log report syz C ci-upstream-kasan-gce-root
2018/12/14 22:34 upstream eb6cf9f8cb9d 7624ddd6 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2018/10/01 05:22 upstream 17b57b1883c1 41e4b329 .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/01/06 05:50 upstream f1c2f8857c5a 53be0a37 .config console log report syz C ci-upstream-kasan-gce-386
2019/02/12 13:10 linux-next b5829453d81a 65a0d619 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/02/04 22:41 linux-next dc4c89997735 d672172c .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/02/03 08:37 linux-next dc4c89997735 c198d5dd .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/02/03 06:25 linux-next dc4c89997735 c198d5dd .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/02/01 14:40 linux-next dc4c89997735 0c07abcf .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/01/03 17:26 linux-next a4983672f9ca 66fcd29b .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2018/12/23 05:40 linux-next 6648e120dd1a e3bd7ab8 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/02/12 11:06 upstream aa0c38cf39de 65a0d619 .config console log report syz ci-upstream-kasan-gce-smack-root
2019/02/01 08:29 upstream 9f789567142c 0e8ea0a3 .config console log report syz ci-upstream-kasan-gce-selinux-root
2019/01/06 15:10 upstream b5aef86e089a 94f8adb5 .config console log report syz ci-upstream-kasan-gce-root
2018/12/14 20:34 upstream eb6cf9f8cb9d 7624ddd6 .config console log report syz ci-upstream-kasan-gce-root
2019/01/06 10:18 linux-next a4983672f9ca 53be0a37 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2019/03/06 23:11 upstream afe6fe7036c6 18215b8d .config console log report ci-upstream-kasan-gce-root
2019/03/06 19:50 upstream 3717f613f48d 05cf83bf .config console log report ci-upstream-kasan-gce-smack-root
2019/03/06 01:58 upstream 63bdf4284c38 16559f86 .config console log report ci-upstream-kasan-gce-root
2019/03/05 23:41 upstream 63bdf4284c38 16559f86 .config console log report ci-upstream-kasan-gce-smack-root
2019/03/05 20:18 upstream 63bdf4284c38 16559f86 .config console log report ci-upstream-kasan-gce-root
2019/03/05 13:49 upstream cd2a3bf02625 bb91cf81 .config console log report ci-upstream-kasan-gce-smack-root
2019/03/05 00:29 upstream 736706bee329 7c693b52 .config console log report ci-upstream-kasan-gce-root
2019/03/02 09:32 upstream a215ce8f0e00 1c0e457a .config console log report ci-upstream-kasan-gce-selinux-root
2019/03/02 06:21 upstream a215ce8f0e00 1c0e457a .config console log report ci-upstream-kasan-gce-root
2019/03/01 19:23 upstream 7d762d69145a 68d9e495 .config console log report ci-upstream-kasan-gce-selinux-root
2019/03/01 18:19 upstream 7d762d69145a 68d9e495 .config console log report ci-upstream-kasan-gce-selinux-root
2019/03/01 03:17 upstream 7d762d69145a 09aeeba4 .config console log report ci-upstream-kasan-gce-root
2019/02/28 22:49 upstream 7d762d69145a 09aeeba4 .config console log report ci-upstream-kasan-gce-root
2019/02/27 12:55 upstream 7d762d69145a 083cfd0e .config console log report ci-upstream-kasan-gce-selinux-root
2019/02/27 11:46 upstream 7d762d69145a 083cfd0e .config console log report ci-upstream-kasan-gce-smack-root
2019/02/27 03:18 upstream 7d762d69145a f2468c12 .config console log report ci-upstream-kasan-gce-smack-root
2019/02/25 22:57 upstream 7d762d69145a 8022bafd .config console log report ci-upstream-kasan-gce-smack-root
2019/02/25 00:22 upstream c3619a482e15 7a06e792 .config console log report ci-upstream-kasan-gce-selinux-root
2019/02/24 20:38 upstream c3619a482e15 7a06e792 .config console log report ci-upstream-kasan-gce-selinux-root
2019/02/24 10:45 upstream e60b5f79bd75 7a06e792 .config console log report ci-upstream-kasan-gce-root
2019/02/24 08:48 upstream e60b5f79bd75 7a06e792 .config console log report ci-upstream-kasan-gce-root
2019/02/24 03:22 upstream e60b5f79bd75 7a06e792 .config console log report ci-upstream-kasan-gce-selinux-root
2019/02/23 21:52 upstream e60b5f79bd75 7a06e792 .config console log report ci-upstream-kasan-gce-root
2019/02/22 20:52 upstream 6ee2846cb4e7 6a5fcca4 .config console log report ci-upstream-kasan-gce-smack-root
2019/02/22 10:21 upstream 8a61716ff2ab 7ff74a98 .config console log report ci-upstream-kasan-gce-selinux-root
2019/02/22 08:53 upstream 8a61716ff2ab 7ff74a98 .config console log report ci-upstream-kasan-gce-selinux-root
2019/02/21 19:18 upstream f6163d67cc31 3133098b .config console log report ci-upstream-kasan-gce-smack-root
2019/02/21 10:15 upstream f6163d67cc31 3133098b .config console log report ci-upstream-kasan-gce-smack-root
2019/02/21 06:36 upstream 2137397c92ae c95f0707 .config console log report ci-upstream-kasan-gce-root
2019/02/20 15:27 upstream 40e196a906d9 c95f0707 .config console log report ci-upstream-kasan-gce-smack-root
2019/02/20 02:00 upstream 40e196a906d9 4df543c9 .config console log report ci-upstream-kasan-gce-selinux-root
2019/02/19 15:27 upstream b5372fe5dc84 4df543c9 .config console log report ci-upstream-kasan-gce-selinux-root
2019/02/18 17:30 upstream a3b22b9f11d9 59f36113 .config console log report ci-upstream-kasan-gce-root
2019/02/17 18:52 upstream 8d33316d5205 3e98cc30 .config console log report ci-upstream-kasan-gce-selinux-root
2019/02/17 03:45 upstream 64c0133eb88a f42dee6d .config console log report ci-upstream-kasan-gce-root
2019/02/17 01:27 upstream 5ded5871030e f42dee6d .config console log report ci-upstream-kasan-gce-root
2019/02/15 22:03 upstream cb5b020a8d38 f6f233c0 .config console log report ci-upstream-kasan-gce-smack-root
2019/02/15 09:18 upstream cb5b020a8d38 76dd003f .config console log report ci-upstream-kasan-gce-root
2019/02/14 20:01 upstream 23e93c9b2cde 76dd003f .config console log report ci-upstream-kasan-gce-smack-root
2019/02/14 12:59 upstream 1f947a7a011f 6a46f448 .config console log report ci-upstream-kasan-gce-root
2019/02/13 22:49 upstream 1f947a7a011f 0a49c954 .config console log report ci-upstream-kasan-gce-root
2019/02/18 00:55 linux-next 7a92eb7cc1dc 3e98cc30 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/02/17 14:06 linux-next 7a92eb7cc1dc f42dee6d .config console log report ci-upstream-linux-next-kasan-gce-root
2019/02/17 11:36 linux-next 7a92eb7cc1dc f42dee6d .config console log report ci-upstream-linux-next-kasan-gce-root
2019/02/17 07:16 linux-next 7a92eb7cc1dc f42dee6d .config console log report ci-upstream-linux-next-kasan-gce-root
2019/02/17 05:32 linux-next 7a92eb7cc1dc f42dee6d .config console log report ci-upstream-linux-next-kasan-gce-root
2019/02/17 02:36 linux-next 7a92eb7cc1dc f42dee6d .config console log report ci-upstream-linux-next-kasan-gce-root
2019/02/16 22:57 linux-next 7a92eb7cc1dc f42dee6d .config console log report ci-upstream-linux-next-kasan-gce-root
2019/02/16 17:49 linux-next 7a92eb7cc1dc f42dee6d .config console log report ci-upstream-linux-next-kasan-gce-root
2019/02/13 15:31 linux-next c4f3ef3eb53f 0a49c954 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/02/13 01:41 linux-next b5829453d81a 1eedba36 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/20 15:01 linux-next a0cb0cabe4bb 565a5452 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.