syzbot


KASAN: use-after-free Read in mon_bin_flush

Status: fixed on 2022/10/19 01:02
Reported-by: syzbot+23f57c5ae902429285d7@syzkaller.appspotmail.com
Fix commit: 1b257f97fec4 usb: mon: make mmapped memory read only
First crash: 134d, last: 132d

Cause bisection: failed (bisect log)
similar bugs (3):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in mon_bin_flush C inconclusive 15 2d15h 132d 0/24 upstream: reported C repro on 2022/09/18 10:24
android-5-15 KASAN: use-after-free Read in mon_bin_flush 1 106d 106d 0/2 auto-obsoleted due to no activity on 2023/01/14 11:53
android-54 general protection fault in mon_bin_flush C 2 132d 134d 0/2 upstream: reported C repro on 2022/09/16 06:36
Last patch testing requests:
Created Duration User Patch Repo Result
2022/09/19 18:15 17m tadeusz.struk@linaro.org patch android12-5.10-lts OK log
2022/09/16 22:10 16m tadeusz.struk@linaro.org patch git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master OK log
2022/09/16 21:44 9m tadeusz.struk@linaro.org git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master report log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in MON_OFF2HDR drivers/usb/mon/mon_bin.c:207 [inline]
BUG: KASAN: use-after-free in mon_bin_flush+0x121/0x260 drivers/usb/mon/mon_bin.c:884
Read of size 8 at addr ffff88811d8f5ab8 by task syz-executor653/386

CPU: 1 PID: 386 Comm: syz-executor653 Not tainted 5.10.140-syzkaller-00825-g59390358870a #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x81/0x3c0 mm/kasan/report.c:233
 __kasan_report mm/kasan/report.c:419 [inline]
 kasan_report+0x1a4/0x1f0 mm/kasan/report.c:436
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:309
 MON_OFF2HDR drivers/usb/mon/mon_bin.c:207 [inline]
 mon_bin_flush+0x121/0x260 drivers/usb/mon/mon_bin.c:884
 mon_bin_ioctl+0x2fb/0xed0 drivers/usb/mon/mon_bin.c:1060
 vfs_ioctl fs/ioctl.c:48 [inline]
 __do_sys_ioctl fs/ioctl.c:753 [inline]
 __se_sys_ioctl+0x115/0x190 fs/ioctl.c:739
 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:739
 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x61/0xc6
RIP: 0033:0x7f8570d8b819
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 01 18 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f8570d302f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f8570e09480 RCX: 00007f8570d8b819
RDX: 0000000000000006 RSI: 0000000000009208 RDI: 0000000000000003
RBP: 00007f8570dd62bc R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f8570dd52f0
R13: 0000000020001978 R14: 6273752f7665642f R15: 00007f8570e09488

The buggy address belongs to the page:
page:ffffea0004763d40 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11d8f5
flags: 0x8000000000000000()
raw: 8000000000000000 ffffea0004763d48 ffffea0004763d48 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner info is not present (never set?)

Memory state around the buggy address:
 ffff88811d8f5980: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88811d8f5a00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88811d8f5a80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                        ^
 ffff88811d8f5b00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88811d8f5b80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================
general protection fault, probably for non-canonical address 0xdffffc000000013c: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x00000000000009e0-0x00000000000009e7]
CPU: 1 PID: 386 Comm: syz-executor653 Tainted: G    B             5.10.140-syzkaller-00825-g59390358870a #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022
RIP: 0010:mon_bin_flush+0x141/0x260 drivers/usb/mon/mon_bin.c:885
Code: 74 08 48 89 df e8 8f 3a 94 fe 48 8b 03 41 81 e7 ff 0f 00 00 4d 8d 7c 07 24 4c 89 f8 48 c1 e8 03 48 bb 00 00 00 00 00 fc ff df <0f> b6 04 18 84 c0 75 6b 41 8b 37 83 c6 40 4c 89 f7 e8 a9 fd ff ff
RSP: 0018:ffffc90000c97d08 EFLAGS: 00010007
RAX: 000000000000013c RBX: dffffc0000000000 RCX: 0000000000000002
RDX: 0000000000000000 RSI: 0000000000000082 RDI: 0000000000000001
RBP: ffffc90000c97d70 R08: ffffffff813efe13 R09: fffffbfff0d864f9
R10: fffffbfff0d864f9 R11: 1ffffffff0d864f8 R12: 00000000fffffffd
R13: ffff88811cd19618 R14: ffff88811cd19600 R15: 00000000000009e4
FS:  00007f8570d30700(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020002000 CR3: 000000011785e000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 mon_bin_ioctl+0x2fb/0xed0 drivers/usb/mon/mon_bin.c:1060
 vfs_ioctl fs/ioctl.c:48 [inline]
 __do_sys_ioctl fs/ioctl.c:753 [inline]
 __se_sys_ioctl+0x115/0x190 fs/ioctl.c:739
 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:739
 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x61/0xc6
RIP: 0033:0x7f8570d8b819
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 01 18 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f8570d302f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f8570e09480 RCX: 00007f8570d8b819
RDX: 0000000000000006 RSI: 0000000000009208 RDI: 0000000000000003
RBP: 00007f8570dd62bc R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f8570dd52f0
R13: 0000000020001978 R14: 6273752f7665642f R15: 00007f8570e09488
Modules linked in:
---[ end trace a8255d76b47e1058 ]---
RIP: 0010:mon_bin_flush+0x141/0x260 drivers/usb/mon/mon_bin.c:885
Code: 74 08 48 89 df e8 8f 3a 94 fe 48 8b 03 41 81 e7 ff 0f 00 00 4d 8d 7c 07 24 4c 89 f8 48 c1 e8 03 48 bb 00 00 00 00 00 fc ff df <0f> b6 04 18 84 c0 75 6b 41 8b 37 83 c6 40 4c 89 f7 e8 a9 fd ff ff
RSP: 0018:ffffc90000c97d08 EFLAGS: 00010007
RAX: 000000000000013c RBX: dffffc0000000000 RCX: 0000000000000002
RDX: 0000000000000000 RSI: 0000000000000082 RDI: 0000000000000001
RBP: ffffc90000c97d70 R08: ffffffff813efe13 R09: fffffbfff0d864f9
R10: fffffbfff0d864f9 R11: 1ffffffff0d864f8 R12: 00000000fffffffd
R13: ffff88811cd19618 R14: ffff88811cd19600 R15: 00000000000009e4
FS:  00007f8570d30700(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020002000 CR3: 000000011785e000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
   0:	74 08                	je     0xa
   2:	48 89 df             	mov    %rbx,%rdi
   5:	e8 8f 3a 94 fe       	callq  0xfe943a99
   a:	48 8b 03             	mov    (%rbx),%rax
   d:	41 81 e7 ff 0f 00 00 	and    $0xfff,%r15d
  14:	4d 8d 7c 07 24       	lea    0x24(%r15,%rax,1),%r15
  19:	4c 89 f8             	mov    %r15,%rax
  1c:	48 c1 e8 03          	shr    $0x3,%rax
  20:	48 bb 00 00 00 00 00 	movabs $0xdffffc0000000000,%rbx
  27:	fc ff df
* 2a:	0f b6 04 18          	movzbl (%rax,%rbx,1),%eax <-- trapping instruction
  2e:	84 c0                	test   %al,%al
  30:	75 6b                	jne    0x9d
  32:	41 8b 37             	mov    (%r15),%esi
  35:	83 c6 40             	add    $0x40,%esi
  38:	4c 89 f7             	mov    %r14,%rdi
  3b:	e8 a9 fd ff ff       	callq  0xfffffde9

Crashes (2):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci2-android-5-10 2022/09/16 06:35 android12-5.10-lts 59390358870a dd9a85ff .config console log report syz C [disk image] [vmlinux] KASAN: use-after-free Read in mon_bin_flush
ci2-android-5-10 2022/09/18 00:42 android12-5.10-lts 59390358870a dd9a85ff .config strace log report syz C [disk image] [vmlinux] KASAN: slab-out-of-bounds Read in mon_bin_flush
* Struck through repros no longer work on HEAD.