syzbot


possible deadlock in mon_bin_vma_fault

Status: fixed on 2020/01/07 21:27
Reported-by: syzbot+d7c97cadc3eee6ee853d@syzkaller.appspotmail.com
Fix commit: d41971493d28 usb: mon: Fix a deadlock in usbmon between mmap and read
First crash: 1322d, last: 1086d

Fix bisection: fixed by (bisect log) :
commit d41971493d28edf2b916ad5201d8301a8513ed51
Author: Pete Zaitcev <zaitcev@redhat.com>
Date: Thu Dec 5 02:39:41 2019 +0000

  usb: mon: Fix a deadlock in usbmon between mmap and read

similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in mon_bin_vma_fault C done 11427 1080d 1547d 16/24 fixed on 2020/02/14 01:19
linux-4.19 possible deadlock in mon_bin_vma_fault C done 375 1078d 1328d 1/1 fixed on 2020/01/15 15:23

Sample crash report:
audit: type=1400 audit(1571728630.760:37): avc:  denied  { map } for  pid=6820 comm="syz-executor273" path="/root/syz-executor273489809" dev="sda1" ino=16483 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
audit: type=1400 audit(1571728630.830:38): avc:  denied  { map } for  pid=6821 comm="syz-executor273" path="/dev/usbmon4" dev="devtmpfs" ino=1499 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=system_u:object_r:usbmon_device_t:s0 tclass=chr_file permissive=1
======================================================
WARNING: possible circular locking dependency detected
4.14.150 #0 Not tainted
------------------------------------------------------
syz-executor273/6823 is trying to acquire lock:
 (&rp->fetch_lock){+.+.}, at: [<ffffffff83f76c6f>] mon_bin_vma_fault+0x6f/0x280 drivers/usb/mon/mon_bin.c:1236

but task is already holding lock:
 (&mm->mmap_sem){++++}, at: [<ffffffff817bec75>] __mm_populate+0x1e5/0x2c0 mm/gup.c:1259

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&mm->mmap_sem){++++}:
       lock_acquire+0x16f/0x430 kernel/locking/lockdep.c:3994
       __might_fault mm/memory.c:4584 [inline]
       __might_fault+0x143/0x1d0 mm/memory.c:4569
       _copy_to_user+0x2c/0xd0 lib/usercopy.c:25
       copy_to_user include/linux/uaccess.h:155 [inline]
       mon_bin_read+0x2fb/0x5e0 drivers/usb/mon/mon_bin.c:825
       __vfs_read+0x105/0x6a0 fs/read_write.c:411
       vfs_read+0x137/0x350 fs/read_write.c:447
       SYSC_read fs/read_write.c:574 [inline]
       SyS_read+0xfd/0x230 fs/read_write.c:567
       do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x42/0xb7

-> #0 (&rp->fetch_lock){+.+.}:
       check_prev_add kernel/locking/lockdep.c:1901 [inline]
       check_prevs_add kernel/locking/lockdep.c:2018 [inline]
       validate_chain kernel/locking/lockdep.c:2460 [inline]
       __lock_acquire+0x2cb3/0x4620 kernel/locking/lockdep.c:3487
       lock_acquire+0x16f/0x430 kernel/locking/lockdep.c:3994
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xe8/0x1470 kernel/locking/mutex.c:893
       mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:908
       mon_bin_vma_fault+0x6f/0x280 drivers/usb/mon/mon_bin.c:1236
       __do_fault+0x104/0x390 mm/memory.c:3223
       do_read_fault mm/memory.c:3633 [inline]
       do_fault mm/memory.c:3759 [inline]
       handle_pte_fault mm/memory.c:3989 [inline]
       __handle_mm_fault+0x2460/0x3470 mm/memory.c:4113
       handle_mm_fault+0x293/0x7c0 mm/memory.c:4150
       faultin_page mm/gup.c:514 [inline]
       __get_user_pages+0x465/0x1220 mm/gup.c:714
       populate_vma_page_range+0x18e/0x230 mm/gup.c:1231
       __mm_populate+0x198/0x2c0 mm/gup.c:1279
       mm_populate include/linux/mm.h:2187 [inline]
       vm_mmap_pgoff+0x1be/0x1d0 mm/util.c:338
       SYSC_mmap_pgoff mm/mmap.c:1551 [inline]
       SyS_mmap_pgoff+0x3ca/0x520 mm/mmap.c:1509
       SYSC_mmap arch/x86/kernel/sys_x86_64.c:100 [inline]
       SyS_mmap+0x16/0x20 arch/x86/kernel/sys_x86_64.c:91
       do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x42/0xb7

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&mm->mmap_sem);
                               lock(&rp->fetch_lock);
                               lock(&mm->mmap_sem);
  lock(&rp->fetch_lock);

 *** DEADLOCK ***

1 lock held by syz-executor273/6823:
 #0:  (&mm->mmap_sem){++++}, at: [<ffffffff817bec75>] __mm_populate+0x1e5/0x2c0 mm/gup.c:1259

stack backtrace:
CPU: 0 PID: 6823 Comm: syz-executor273 Not tainted 4.14.150 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x138/0x197 lib/dump_stack.c:53
 print_circular_bug.isra.0.cold+0x1cc/0x28f kernel/locking/lockdep.c:1258
 check_prev_add kernel/locking/lockdep.c:1901 [inline]
 check_prevs_add kernel/locking/lockdep.c:2018 [inline]
 validate_chain kernel/locking/lockdep.c:2460 [inline]
 __lock_acquire+0x2cb3/0x4620 kernel/locking/lockdep.c:3487
 lock_acquire+0x16f/0x430 kernel/locking/lockdep.c:3994
 __mutex_lock_common kernel/locking/mutex.c:756 [inline]
 __mutex_lock+0xe8/0x1470 kernel/locking/mutex.c:893
 mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:908
 mon_bin_vma_fault+0x6f/0x280 drivers/usb/mon/mon_bin.c:1236
 __do_fault+0x104/0x390 mm/memory.c:3223
 do_read_fault mm/memory.c:3633 [inline]
 do_fault mm/memory.c:3759 [inline]
 handle_pte_fault mm/memory.c:3989 [inline]
 __handle_mm_fault+0x2460/0x3470 mm/memory.c:4113
 handle_mm_fault+0x293/0x7c0 mm/memory.c:4150
 faultin_page mm/gup.c:514 [inline]
 __get_user_pages+0x465/0x1220 mm/gup.c:714
 populate_vma_page_range+0x18e/0x230 mm/gup.c:1231
 __mm_populate+0x198/0x2c0 mm/gup.c:1279
 mm_populate include/linux/mm.h:2187 [inline]
 vm_mmap_pgoff+0x1be/0x1d0 mm/util.c:338
 SYSC_mmap_pgoff mm/mmap.c:1551 [inline]
 SyS_mmap_pgoff+0x3ca/0x520 mm/mmap.c:1509
 SYSC_mmap arch/x86/kernel/sys_x86_64.c:100 [inline]
 SyS_mmap+0x16/0x20 arch/x86/kernel/sys_x86_64.c:91
 do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x44a689
RSP: 002b:00007f71e4a95cd8 EFLAGS: 00000246 ORIG_RAX: 0000000000000009
RAX: ffffffffffffffda RBX: 00000000006dbc38 RCX: 000000000044a689
RDX: 0000000002000001 RSI: 0000000002000000 RDI: 0000000020ffd000
RBP: 00000000006dbc30 R08: 0000000000000005 R09: 0000000000000000
R10: 03eb6b06d1207692 R11: 0000000000000246 R12: 00000000006dbc3c
R13: 00007ffc8cfdc57f R14: 00007f71e4a969c0 R15: 20c49ba5e353f7cf

Crashes (282):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-linux-4-14 2019/10/22 07:20 linux-4.14.y b98aebd29824 c59a7cd8 .config log report syz C
ci2-linux-4-14 2019/10/21 14:00 linux-4.14.y b98aebd29824 b24d2b8a .config log report syz C
ci2-linux-4-14 2019/10/21 03:30 linux-4.14.y b98aebd29824 8c88c9c1 .config log report syz C
ci2-linux-4-14 2019/07/05 04:36 linux-4.14.y e3c1b27308ae deef5fbc .config log report syz C
ci2-linux-4-14 2019/04/23 22:39 linux-4.14.y 68d7a45eec10 2398edea .config log report syz C
ci2-linux-4-14 2019/12/08 10:50 linux-4.14.y a844dc4c5442 1508f453 .config log report
ci2-linux-4-14 2019/12/08 05:37 linux-4.14.y a844dc4c5442 1508f453 .config log report
ci2-linux-4-14 2019/12/07 20:21 linux-4.14.y a844dc4c5442 1508f453 .config log report
ci2-linux-4-14 2019/11/27 17:01 linux-4.14.y 43598c571e7e 0d63f89c .config log report
ci2-linux-4-14 2019/11/26 20:17 linux-4.14.y 43598c571e7e 1048481f .config log report
ci2-linux-4-14 2019/11/26 07:28 linux-4.14.y 43598c571e7e 598ca6c8 .config log report
ci2-linux-4-14 2019/11/25 02:11 linux-4.14.y 43598c571e7e 598ca6c8 .config log report
ci2-linux-4-14 2019/11/22 00:20 linux-4.14.y f56f3d0e65ad 8098ea0f .config log report
ci2-linux-4-14 2019/11/20 17:52 linux-4.14.y 775d01b65b5d 432c7650 .config log report
ci2-linux-4-14 2019/11/18 23:52 linux-4.14.y 775d01b65b5d d5696d51 .config log report
ci2-linux-4-14 2019/11/15 00:31 linux-4.14.y 775d01b65b5d 048f2d49 .config log report
ci2-linux-4-14 2019/11/14 15:32 linux-4.14.y 775d01b65b5d 048f2d49 .config log report
ci2-linux-4-14 2019/11/12 17:05 linux-4.14.y 4762bcd451a9 048f2d49 .config log report
ci2-linux-4-14 2019/11/11 16:35 linux-4.14.y 4762bcd451a9 377d77fa .config log report
ci2-linux-4-14 2019/11/07 16:42 linux-4.14.y c9fda4f22428 f39aff9e .config log report
ci2-linux-4-14 2019/10/27 21:37 linux-4.14.y b98aebd29824 25bb509e .config log report
ci2-linux-4-14 2019/10/27 20:15 linux-4.14.y b98aebd29824 25bb509e .config log report
ci2-linux-4-14 2019/10/27 07:36 linux-4.14.y b98aebd29824 25bb509e .config log report
ci2-linux-4-14 2019/10/26 00:25 linux-4.14.y b98aebd29824 413926c5 .config log report
ci2-linux-4-14 2019/10/25 09:08 linux-4.14.y b98aebd29824 d01bb02a .config log report
ci2-linux-4-14 2019/10/21 10:55 linux-4.14.y b98aebd29824 8c88c9c1 .config log report
ci2-linux-4-14 2019/10/21 02:55 linux-4.14.y b98aebd29824 8c88c9c1 .config log report
ci2-linux-4-14 2019/10/20 14:48 linux-4.14.y b98aebd29824 8c88c9c1 .config log report
ci2-linux-4-14 2019/10/20 03:45 linux-4.14.y b98aebd29824 8c88c9c1 .config log report
ci2-linux-4-14 2019/10/19 23:11 linux-4.14.y b98aebd29824 8c88c9c1 .config log report
ci2-linux-4-14 2019/10/19 18:53 linux-4.14.y b98aebd29824 8c88c9c1 .config log report
ci2-linux-4-14 2019/10/19 12:08 linux-4.14.y b98aebd29824 8c88c9c1 .config log report
ci2-linux-4-14 2019/10/16 16:34 linux-4.14.y e132c8d7b58d d4ea592f .config log report
ci2-linux-4-14 2019/10/15 23:58 linux-4.14.y e132c8d7b58d d4ea592f .config log report
ci2-linux-4-14 2019/10/15 11:50 linux-4.14.y e132c8d7b58d b5268b89 .config log report
ci2-linux-4-14 2019/10/07 18:12 linux-4.14.y 42327896f194 28ac6e64 .config log report
ci2-linux-4-14 2019/10/06 06:49 linux-4.14.y db1892238c55 f3f7d9c8 .config log report
ci2-linux-4-14 2019/10/05 18:07 linux-4.14.y db1892238c55 f3f7d9c8 .config log report
ci2-linux-4-14 2019/10/05 12:54 linux-4.14.y db1892238c55 f3f7d9c8 .config log report
ci2-linux-4-14 2019/10/05 03:14 linux-4.14.y f6e27dbb1afa f3f7d9c8 .config log report
ci2-linux-4-14 2019/10/02 01:13 linux-4.14.y f6e27dbb1afa b7a87a83 .config log report
ci2-linux-4-14 2019/10/01 14:23 linux-4.14.y f6e27dbb1afa b7a87a83 .config log report
ci2-linux-4-14 2019/10/01 14:07 linux-4.14.y f6e27dbb1afa b7a87a83 .config log report
ci2-linux-4-14 2019/09/30 12:37 linux-4.14.y f6e27dbb1afa c7a4fb99 .config log report
ci2-linux-4-14 2019/09/29 07:04 linux-4.14.y f6e27dbb1afa eb6b9855 .config log report
ci2-linux-4-14 2019/09/28 11:01 linux-4.14.y f6e27dbb1afa eb6b9855 .config log report
ci2-linux-4-14 2019/09/26 11:42 linux-4.14.y f6e27dbb1afa 24d405a3 .config log report
ci2-linux-4-14 2019/04/16 18:36 linux-4.14.y 1ec8f1f0bffe 505ab413 .config log report
* Struck through repros no longer work on HEAD.