syzbot


BUG: sleeping function called from invalid context in binder_ioctl

Status: upstream: reported C repro on 2022/05/17 07:22
Reported-by: syzbot+46fff6434a7f968ecb39@syzkaller.appspotmail.com
Fix commit: aed86f8add0e binder: fix atomic sleep when get extended error
Patched on: [ci-qemu-upstream ci-qemu-upstream-386 ci-qemu2-arm32 ci-qemu2-arm64 ci-qemu2-arm64-compat ci-qemu2-arm64-mte ci-upstream-bpf-kasan-gce ci-upstream-bpf-next-kasan-gce ci-upstream-gce-leak ci-upstream-kasan-gce ci-upstream-kasan-gce-386 ci-upstream-kasan-gce-root ci-upstream-kasan-gce-selinux-root ci-upstream-kasan-gce-smack-root ci-upstream-kmsan-gce ci-upstream-kmsan-gce-386 ci-upstream-linux-next-kasan-gce-root ci-upstream-net-kasan-gce ci-upstream-net-this-kasan-gce ci2-upstream-kcsan-gce ci2-upstream-usb], missing on: [ci-qemu2-riscv64]
First crash: 43d, last: 37d

Cause bisection: introduced by (bisect log) :
commit bd32889e841c12533d09a1bd02bba932baa9ed8f
Author: Carlos Llamas <cmllamas@google.com>
Date: Fri Apr 29 23:56:41 2022 +0000

  binder: add BINDER_GET_EXTENDED_ERROR ioctl

Crash: SYZFATAL: executor failed NUM times: executor NUM: exit status NUM (log)
Repro: C syz .config

Sample crash report:
BUG: sleeping function called from invalid context at lib/usercopy.c:28
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 3613, name: syz-executor152
preempt_count: 1, expected: 0
RCU nest depth: 0, expected: 0
1 lock held by syz-executor152/3613:
 #0: ffff8880777572f8 (&proc->inner_lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:360 [inline]
 #0: ffff8880777572f8 (&proc->inner_lock){+.+.}-{2:2}, at: _binder_inner_proc_lock drivers/android/binder.c:283 [inline]
 #0: ffff8880777572f8 (&proc->inner_lock){+.+.}-{2:2}, at: binder_ioctl_get_extended_error drivers/android/binder.c:5167 [inline]
 #0: ffff8880777572f8 (&proc->inner_lock){+.+.}-{2:2}, at: binder_ioctl+0x798/0x6d80 drivers/android/binder.c:5390
Preemption disabled at:
[<0000000000000000>] 0x0
CPU: 0 PID: 3613 Comm: syz-executor152 Not tainted 5.18.0-rc6-next-20220516-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 __might_resched.cold+0x222/0x26b kernel/sched/core.c:9791
 __might_fault+0x6c/0x170 mm/memory.c:5567
 _copy_to_user+0x25/0x140 lib/usercopy.c:28
 copy_to_user include/linux/uaccess.h:160 [inline]
 binder_ioctl_get_extended_error drivers/android/binder.c:5168 [inline]
 binder_ioctl+0x7aa/0x6d80 drivers/android/binder.c:5390
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl fs/ioctl.c:856 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x46/0xb0
RIP: 0033:0x7f3ae108e059
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 11 15 00 00 90 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 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff28fbd878 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f3ae108e059
RDX: 0000000000000000 RSI: 00000000c00c6211 RDI: 0000000000000003
RBP: 0000000000000000 R08: 00007f3ae10fbe40 R09: 00007f3ae10fbe40
R10: 00007fff28fbd2f0 R11: 0000000000000246 R12: 00007fff28fbd8b0
R13: 00007fff28fbd8a0 R14: 00007fff28fbd890 R15: 0000000000000000
 </TASK>

=============================
[ BUG: Invalid wait context ]
5.18.0-rc6-next-20220516-syzkaller #0 Tainted: G        W        
-----------------------------
syz-executor152/3613 is trying to lock:
ffff888073415f98 (&mm->mmap_lock#2){++++}-{3:3}, at: __might_fault+0xa1/0x170 mm/memory.c:5569
other info that might help us debug this:
context-{4:4}
1 lock held by syz-executor152/3613:
 #0: ffff8880777572f8 (&proc->inner_lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:360 [inline]
 #0: ffff8880777572f8 (&proc->inner_lock){+.+.}-{2:2}, at: _binder_inner_proc_lock drivers/android/binder.c:283 [inline]
 #0: ffff8880777572f8 (&proc->inner_lock){+.+.}-{2:2}, at: binder_ioctl_get_extended_error drivers/android/binder.c:5167 [inline]
 #0: ffff8880777572f8 (&proc->inner_lock){+.+.}-{2:2}, at: binder_ioctl+0x798/0x6d80 drivers/android/binder.c:5390
stack backtrace:
CPU: 0 PID: 3613 Comm: syz-executor152 Tainted: G        W         5.18.0-rc6-next-20220516-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_lock_invalid_wait_context kernel/locking/lockdep.c:4705 [inline]
 check_wait_context kernel/locking/lockdep.c:4766 [inline]
 __lock_acquire.cold+0xdb/0x3b4 kernel/locking/lockdep.c:5003
 lock_acquire kernel/locking/lockdep.c:5665 [inline]
 lock_acquire+0x1ab/0x570 kernel/locking/lockdep.c:5630
 __might_fault mm/memory.c:5570 [inline]
 __might_fault+0x104/0x170 mm/memory.c:5563
 _copy_to_user+0x25/0x140 lib/usercopy.c:28
 copy_to_user include/linux/uaccess.h:160 [inline]
 binder_ioctl_get_extended_error drivers/android/binder.c:5168 [inline]
 binder_ioctl+0x7aa/0x6d80 drivers/android/binder.c:5390
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl fs/ioctl.c:856 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x46/0xb0
RIP: 0033:0x7f3ae108e059
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 11 15 00 00 90 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 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff28fbd878 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f3ae108e059
RDX: 0000000000000000 RSI: 00000000c00c6211 RDI: 0000000000000003
RBP: 0000000000000000 R08: 00007f3ae10fbe40 R09: 00007f3ae10fbe40
R10: 00007fff28fbd2f0 R11: 0000000000000246 R12: 00007fff28fbd8b0
R13: 00007fff28fbd8a0 R14: 00007fff28fbd890 R15: 0000000000000000
 </TASK>
binder: 3613:3613 ioctl c00c6211 0 returned -14

Crashes (30):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-linux-next-kasan-gce-root 2022/05/16 17:05 linux-next 3f7bdc402fb0 744a39e2 .config log report syz C BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/23 04:22 linux-next 18ecd30af1a8 7268fa62 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/22 23:57 linux-next 18ecd30af1a8 7268fa62 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/22 21:20 linux-next 18ecd30af1a8 7268fa62 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/22 18:56 linux-next 18ecd30af1a8 7268fa62 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/22 16:53 linux-next 18ecd30af1a8 7268fa62 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/22 13:32 linux-next 18ecd30af1a8 7268fa62 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/22 12:08 linux-next 18ecd30af1a8 7268fa62 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/21 14:55 linux-next 18ecd30af1a8 7268fa62 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/21 13:04 linux-next 18ecd30af1a8 7268fa62 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/21 11:08 linux-next 18ecd30af1a8 7268fa62 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/20 16:45 linux-next 18ecd30af1a8 bd37ad7e .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/20 14:31 linux-next 18ecd30af1a8 cb1ac2e7 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/20 13:08 linux-next 3f7bdc402fb0 cb1ac2e7 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/20 02:05 linux-next 3f7bdc402fb0 cb1ac2e7 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/20 01:07 linux-next 3f7bdc402fb0 cb1ac2e7 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/19 13:03 linux-next 3f7bdc402fb0 50c53f39 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/19 11:36 linux-next 3f7bdc402fb0 50c53f39 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/19 09:39 linux-next 3f7bdc402fb0 50c53f39 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/19 02:16 linux-next 3f7bdc402fb0 50c53f39 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/18 15:32 linux-next 3f7bdc402fb0 50c53f39 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/18 09:47 linux-next 3f7bdc402fb0 744a39e2 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/18 06:07 linux-next 3f7bdc402fb0 744a39e2 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/18 05:59 linux-next 3f7bdc402fb0 744a39e2 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/18 03:12 linux-next 3f7bdc402fb0 744a39e2 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/18 01:19 linux-next 3f7bdc402fb0 744a39e2 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/17 22:09 linux-next 3f7bdc402fb0 744a39e2 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/17 12:32 linux-next 3f7bdc402fb0 744a39e2 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/16 17:09 linux-next 3f7bdc402fb0 744a39e2 .config log report info BUG: sleeping function called from invalid context in binder_ioctl
ci-upstream-linux-next-kasan-gce-root 2022/05/16 16:50 linux-next 3f7bdc402fb0 744a39e2 .config log report info BUG: sleeping function called from invalid context in binder_ioctl