[syzbot] general protection fault in binder_alloc_new_buf_locked

From: syzbot
Date: Fri Sep 02 2022 - 11:12:39 EST


Hello,

syzbot found the following issue on:

HEAD commit: b90cb1053190 Linux 6.0-rc3
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=1719e383080000
kernel config: https://syzkaller.appspot.com/x/.config?x=9c5c41fc03fda66f
dashboard link: https://syzkaller.appspot.com/bug?extid=ff47834028a51cf6f857
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11794975080000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1445c063080000

The issue was bisected to:

commit 44e602b4e52f70f04620bbbf4fe46ecb40170bde
Author: Liam Howlett <liam.howlett@xxxxxxxxxx>
Date: Wed Aug 10 16:02:25 2022 +0000

binder_alloc: add missing mmap_lock calls when using the VMA

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=16d0d575080000
final oops: https://syzkaller.appspot.com/x/report.txt?x=15d0d575080000
console output: https://syzkaller.appspot.com/x/log.txt?x=11d0d575080000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+ff47834028a51cf6f857@xxxxxxxxxxxxxxxxxxxxxxxxx
Fixes: 44e602b4e52f ("binder_alloc: add missing mmap_lock calls when using the VMA")

binder: 3610:3610 ioctl c0306201 20001480 returned -14
general protection fault, probably for non-canonical address 0xdffffc0000000025: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000128-0x000000000000012f]
CPU: 0 PID: 3610 Comm: syz-executor216 Not tainted 6.0.0-rc3-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/22/2022
RIP: 0010:__lock_acquire+0x6b/0x1f60 kernel/locking/lockdep.c:4923
Code: ff df 8a 04 10 84 c0 0f 85 62 16 00 00 83 3d bf 50 bc 0c 00 0f 84 13 15 00 00 83 3d 7e 93 55 0b 00 74 2c 4c 89 e8 48 c1 e8 03 <80> 3c 10 00 74 12 4c 89 ef e8 b7 f3 73 00 48 ba 00 00 00 00 00 fc
RSP: 0018:ffffc90003a2efa8 EFLAGS: 00010002
RAX: 0000000000000025 RBX: 0000000000000000 RCX: 0000000000000001
RDX: dffffc0000000000 RSI: 0000000000000000 RDI: 0000000000000128
RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000
R10: fffffbfff1c4ae0e R11: 1ffffffff1c4ae0d R12: 0000000000000001
R13: 0000000000000128 R14: 0000000000000000 R15: 0000000000000001
FS: 000055555635f300(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 000000001db40000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5666
down_read+0x39/0x50 kernel/locking/rwsem.c:1499
mmap_read_lock include/linux/mmap_lock.h:117 [inline]
binder_alloc_new_buf_locked+0x9d/0x15f0 drivers/android/binder_alloc.c:405
binder_alloc_new_buf+0x42/0x60 drivers/android/binder_alloc.c:593
binder_transaction+0x284b/0x72e0 drivers/android/binder.c:3187
binder_ioctl_write_read+0xd9a/0x8e50 drivers/android/binder.c:5024
binder_ioctl+0x385/0x18c0 drivers/android/binder.c:5311
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl+0xfb/0x170 fs/ioctl.c:856
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f292e46f339
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:00007ffda7bf8418 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f292e46f339
RDX: 0000000020000040 RSI: 00000000c0306201 RDI: 0000000000000004
RBP: 0000000000000000 R08: 00007f292e4dce40 R09: 00007f292e4dce40
R10: 00007f292e4dce40 R11: 0000000000000246 R12: 00007ffda7bf8450
R13: 00007ffda7bf8440 R14: 00007ffda7bf8430 R15: 0000000000000000
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:__lock_acquire+0x6b/0x1f60 kernel/locking/lockdep.c:4923
Code: ff df 8a 04 10 84 c0 0f 85 62 16 00 00 83 3d bf 50 bc 0c 00 0f 84 13 15 00 00 83 3d 7e 93 55 0b 00 74 2c 4c 89 e8 48 c1 e8 03 <80> 3c 10 00 74 12 4c 89 ef e8 b7 f3 73 00 48 ba 00 00 00 00 00 fc
RSP: 0018:ffffc90003a2efa8 EFLAGS: 00010002
RAX: 0000000000000025 RBX: 0000000000000000 RCX: 0000000000000001
RDX: dffffc0000000000 RSI: 0000000000000000 RDI: 0000000000000128
RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000
R10: fffffbfff1c4ae0e R11: 1ffffffff1c4ae0d R12: 0000000000000001
R13: 0000000000000128 R14: 0000000000000000 R15: 0000000000000001
FS: 000055555635f300(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 000000001db40000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess), 1 bytes skipped:
0: df 8a 04 10 84 c0 fisttps -0x3f7beffc(%rdx)
6: 0f 85 62 16 00 00 jne 0x166e
c: 83 3d bf 50 bc 0c 00 cmpl $0x0,0xcbc50bf(%rip) # 0xcbc50d2
13: 0f 84 13 15 00 00 je 0x152c
19: 83 3d 7e 93 55 0b 00 cmpl $0x0,0xb55937e(%rip) # 0xb55939e
20: 74 2c je 0x4e
22: 4c 89 e8 mov %r13,%rax
25: 48 c1 e8 03 shr $0x3,%rax
* 29: 80 3c 10 00 cmpb $0x0,(%rax,%rdx,1) <-- trapping instruction
2d: 74 12 je 0x41
2f: 4c 89 ef mov %r13,%rdi
32: e8 b7 f3 73 00 callq 0x73f3ee
37: 48 rex.W
38: ba 00 00 00 00 mov $0x0,%edx
3d: 00 fc add %bh,%ah


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@xxxxxxxxxxxxxxxx.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches