syzbot


possible deadlock in __might_fault
Status: fixed on 2020/01/09 09:47
Reported-by: syzbot+dd3e1ed823e8f95e8845@syzkaller.appspotmail.com
Fix commit: d41971493d28 usb: mon: Fix a deadlock in usbmon between mmap and read
First crash: 1138d, last: 898d

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 (7):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in __might_fault C 8978 1533d 1548d 4/22 fixed on 2018/03/23 18:14
linux-4.19 possible deadlock in __might_fault C done 385 889d 1139d 1/1 fixed on 2020/01/18 20:51
android-44 possible deadlock in __might_fault C 6745 1522d 1549d 2/2 fixed on 2018/04/24 18:02
android-49 possible deadlock in __might_fault C 10264 1528d 1549d 3/3 fixed on 2018/04/24 17:23
android-414 possible deadlock in __might_fault 136 911d 1139d 0/1 auto-closed as invalid on 2020/03/25 09:38
upstream possible deadlock in __might_fault (3) C 10722 893d 1364d 0/22 closed as dup on 2018/09/16 01:51
upstream possible deadlock in __might_fault (2) C 20 1486d 1489d 9/22 fixed on 2018/07/09 18:05

Sample crash report:
audit: type=1400 audit(1571664420.365:37): avc:  denied  { map } for  pid=7053 comm="syz-executor788" path="/dev/usbmon0" dev="devtmpfs" ino=14731 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-executor788/7064 is trying to acquire lock:
 (&mm->mmap_sem){++++}, at: [<ffffffff817c00b0>] __might_fault+0xe0/0x1d0 mm/memory.c:4583

but task is already holding lock:
 (&rp->fetch_lock){+.+.}, at: [<ffffffff83f77c97>] mon_bin_fetch+0x37/0x2e0 drivers/usb/mon/mon_bin.c:909

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&rp->fetch_lock){+.+.}:
       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_cow_fault mm/memory.c:3662 [inline]
       do_fault mm/memory.c:3761 [inline]
       handle_pte_fault mm/memory.c:3989 [inline]
       __handle_mm_fault+0xde1/0x3470 mm/memory.c:4113
       handle_mm_fault+0x293/0x7c0 mm/memory.c:4150
       __do_page_fault+0x4c1/0xb80 arch/x86/mm/fault.c:1420
       do_page_fault+0x71/0x511 arch/x86/mm/fault.c:1495
       page_fault+0x45/0x50 arch/x86/entry/entry_64.S:1122

-> #0 (&mm->mmap_sem){++++}:
       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
       __might_fault mm/memory.c:4584 [inline]
       __might_fault+0x143/0x1d0 mm/memory.c:4569
       mon_bin_fetch+0x212/0x2e0 drivers/usb/mon/mon_bin.c:928
       mon_bin_ioctl+0x1c5/0xb50 drivers/usb/mon/mon_bin.c:1090
       vfs_ioctl fs/ioctl.c:46 [inline]
       file_ioctl fs/ioctl.c:500 [inline]
       do_vfs_ioctl+0x7ae/0x1060 fs/ioctl.c:684
       SYSC_ioctl fs/ioctl.c:701 [inline]
       SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
       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(&rp->fetch_lock);
                               lock(&mm->mmap_sem);
                               lock(&rp->fetch_lock);
  lock(&mm->mmap_sem);

 *** DEADLOCK ***

1 lock held by syz-executor788/7064:
 #0:  (&rp->fetch_lock){+.+.}, at: [<ffffffff83f77c97>] mon_bin_fetch+0x37/0x2e0 drivers/usb/mon/mon_bin.c:909

stack backtrace:
CPU: 1 PID: 7064 Comm: syz-executor788 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
 __might_fault mm/memory.c:4584 [inline]
 __might_fault+0x143/0x1d0 mm/memory.c:4569
 mon_bin_fetch+0x212/0x2e0 drivers/usb/mon/mon_bin.c:928
 mon_bin_ioctl+0x1c5/0xb50 drivers/usb/mon/mon_bin.c:1090
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x7ae/0x1060 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
 do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x44b0a9
RSP: 002b:00007f09f146fce8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000006ddc38 RCX: 000000000044b0a9
RDX: 0000000020000140 RSI: 00000000c0109207 RDI: 0000000000000003
RBP: 00000000006ddc30 R08: 00007f09f1470700 R09: 0000000000000000
R10: 00007f09f1470700 R11: 0000000000000246 R12: 00000000006ddc3c
R13: 00007ffe757f2fef R14: 00007f09f14709c0 R15: 000000000000002d
IPv6: ADDRCONF(NETDEV_CHANGE): bond0: link becomes ready
syz-executor788 (7053) used greatest stack depth: 24624 bytes left

Crashes (295):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-linux-4-14 2019/10/21 13:30 linux-4.14.y b98aebd29824 b24d2b8a .config log report syz C
ci2-linux-4-14 2019/10/21 09:47 linux-4.14.y b98aebd29824 8c88c9c1 .config log report syz C
ci2-linux-4-14 2019/10/21 08:54 linux-4.14.y b98aebd29824 8c88c9c1 .config log report syz C
ci2-linux-4-14 2019/10/21 07:46 linux-4.14.y b98aebd29824 8c88c9c1 .config log report syz C
ci2-linux-4-14 2019/10/21 07:27 linux-4.14.y b98aebd29824 8c88c9c1 .config log report syz C
ci2-linux-4-14 2019/10/21 06:43 linux-4.14.y b98aebd29824 8c88c9c1 .config log report syz C
ci2-linux-4-14 2019/06/16 12:34 linux-4.14.y a74d0e937a3a 442206d7 .config log report syz C
ci2-linux-4-14 2019/04/22 06:01 linux-4.14.y 68d7a45eec10 b0e8efcb .config log report syz C
ci2-linux-4-14 2019/04/22 01:28 linux-4.14.y 68d7a45eec10 b0e8efcb .config log report syz C
ci2-linux-4-14 2019/04/21 22:00 linux-4.14.y 68d7a45eec10 b0e8efcb .config log report syz C
ci2-linux-4-14 2019/04/20 06:01 linux-4.14.y 58b454ebf81e b0e8efcb .config log report syz C
ci2-linux-4-14 2019/04/19 08:51 linux-4.14.y 58b454ebf81e b0e8efcb .config log report syz C
ci2-linux-4-14 2019/04/16 19:52 linux-4.14.y 1ec8f1f0bffe 505ab413 .config log report syz C
ci2-linux-4-14 2019/04/13 11:08 linux-4.14.y 1ec8f1f0bffe c402d8f1 .config log report syz C
ci2-linux-4-14 2019/10/22 06:05 linux-4.14.y b98aebd29824 c59a7cd8 .config log report syz
ci2-linux-4-14 2019/12/09 12:46 linux-4.14.y a844dc4c5442 1508f453 .config log report
ci2-linux-4-14 2019/12/06 09:27 linux-4.14.y a844dc4c5442 98b4ef2d .config log report
ci2-linux-4-14 2019/12/05 12:09 linux-4.14.y fbc5fe7a54d0 9fd5a512 .config log report
ci2-linux-4-14 2019/12/05 05:59 linux-4.14.y fbc5fe7a54d0 b2088328 .config log report
ci2-linux-4-14 2019/12/03 21:01 linux-4.14.y fbc5fe7a54d0 0ecb9746 .config log report
ci2-linux-4-14 2019/11/30 02:35 linux-4.14.y 43598c571e7e 3a75be00 .config log report
ci2-linux-4-14 2019/11/29 22:38 linux-4.14.y 43598c571e7e 4f7e1d0f .config log report
ci2-linux-4-14 2019/11/29 08:31 linux-4.14.y 43598c571e7e 76357d6f .config log report
ci2-linux-4-14 2019/11/28 10:14 linux-4.14.y 43598c571e7e 97264cb1 .config log report
ci2-linux-4-14 2019/11/27 16:27 linux-4.14.y 43598c571e7e 0d63f89c .config log report
ci2-linux-4-14 2019/11/26 21:46 linux-4.14.y 43598c571e7e 1048481f .config log report
ci2-linux-4-14 2019/11/26 05:53 linux-4.14.y 43598c571e7e 598ca6c8 .config log report
ci2-linux-4-14 2019/11/26 00:54 linux-4.14.y 43598c571e7e 598ca6c8 .config log report
ci2-linux-4-14 2019/11/24 21:22 linux-4.14.y 43598c571e7e 598ca6c8 .config log report
ci2-linux-4-14 2019/11/23 10:47 linux-4.14.y f56f3d0e65ad 598ca6c8 .config log report
ci2-linux-4-14 2019/11/22 11:01 linux-4.14.y f56f3d0e65ad 598ca6c8 .config log report
ci2-linux-4-14 2019/11/21 19:28 linux-4.14.y f56f3d0e65ad 8098ea0f .config log report
ci2-linux-4-14 2019/11/20 13:28 linux-4.14.y 775d01b65b5d 432c7650 .config log report
ci2-linux-4-14 2019/11/19 09:16 linux-4.14.y 775d01b65b5d 432c7650 .config log report
ci2-linux-4-14 2019/11/19 06:00 linux-4.14.y 775d01b65b5d d5696d51 .config log report
ci2-linux-4-14 2019/11/18 16:37 linux-4.14.y 775d01b65b5d d5696d51 .config log report
ci2-linux-4-14 2019/11/17 09:57 linux-4.14.y 775d01b65b5d d5696d51 .config log report
ci2-linux-4-14 2019/11/17 07:50 linux-4.14.y 775d01b65b5d cdac920b .config log report
ci2-linux-4-14 2019/11/12 16:50 linux-4.14.y 4762bcd451a9 048f2d49 .config log report
ci2-linux-4-14 2019/11/11 14:03 linux-4.14.y c9fda4f22428 dc438b91 .config log report
ci2-linux-4-14 2019/11/11 12:27 linux-4.14.y c9fda4f22428 dc438b91 .config log report
ci2-linux-4-14 2019/11/11 00:21 linux-4.14.y c9fda4f22428 dc438b91 .config log report
ci2-linux-4-14 2019/10/23 02:31 linux-4.14.y b98aebd29824 d0686497 .config log report
ci2-linux-4-14 2019/10/21 02:42 linux-4.14.y b98aebd29824 8c88c9c1 .config log report
ci2-linux-4-14 2019/10/20 19:38 linux-4.14.y b98aebd29824 8c88c9c1 .config log report
ci2-linux-4-14 2019/10/20 10:16 linux-4.14.y b98aebd29824 8c88c9c1 .config log report
ci2-linux-4-14 2019/10/19 23:55 linux-4.14.y b98aebd29824 8c88c9c1 .config log report
ci2-linux-4-14 2019/10/17 16:38 linux-4.14.y e132c8d7b58d 8c88c9c1 .config log report
ci2-linux-4-14 2019/10/17 03:41 linux-4.14.y e132c8d7b58d 8c88c9c1 .config log report
ci2-linux-4-14 2019/10/13 05:40 linux-4.14.y e132c8d7b58d 426631dd .config log report
ci2-linux-4-14 2019/10/11 09:05 linux-4.14.y 42327896f194 1a3bad90 .config log report
ci2-linux-4-14 2019/10/07 05:37 linux-4.14.y db1892238c55 f3f7d9c8 .config log report
ci2-linux-4-14 2019/10/06 22:35 linux-4.14.y db1892238c55 f3f7d9c8 .config log report
ci2-linux-4-14 2019/10/06 09:04 linux-4.14.y db1892238c55 f3f7d9c8 .config log report
ci2-linux-4-14 2019/10/05 12:27 linux-4.14.y db1892238c55 f3f7d9c8 .config log report
ci2-linux-4-14 2019/10/04 16:54 linux-4.14.y f6e27dbb1afa c86336cf .config log report
ci2-linux-4-14 2019/10/04 15:12 linux-4.14.y f6e27dbb1afa c86336cf .config log report
ci2-linux-4-14 2019/10/03 22:44 linux-4.14.y f6e27dbb1afa fc17ba49 .config log report
ci2-linux-4-14 2019/04/13 03:10 linux-4.14.y 1ec8f1f0bffe c402d8f1 .config log report