syzbot


KASAN: null-ptr-deref Read in ida_free (2)

Status: upstream: reported C repro on 2022/06/24 13:10
Reported-by: syzbot+aa620fb1ece874a3f34c@syzkaller.appspotmail.com
Fix commit: 90bc2af24638 USB: gadget: Fix double-free bug in raw_gadget driver
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-arm64 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-fs ci2-upstream-kcsan-gce ci2-upstream-usb], missing on: [ci-qemu2-riscv64]
First crash: 166d, last: 165d

Cause bisection: introduced by (bisect log) :
commit f2d8c2606825317b77db1f9ba0fc26ef26160b30
Author: Alan Stern <stern@rowland.harvard.edu>
Date: Mon Jun 13 14:17:03 2022 +0000

  usb: gadget: Fix non-unique driver names in raw-gadget driver

Crash: KASAN: null-ptr-deref Read in ida_free (log)
Repro: C syz .config
similar bugs (1):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: null-ptr-deref Read in ida_free 1 727d 726d 0/24 auto-closed as invalid on 2021/04/09 00:32
Patch testing requests:
Created Duration User Patch Repo Result
2022/06/24 14:34 18m stern@rowland.harvard.edu https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git 90bc2af24638 OK log

Sample crash report:
==================================================================
BUG: KASAN: null-ptr-deref in instrument_atomic_read include/linux/instrumented.h:71 [inline]
BUG: KASAN: null-ptr-deref in test_bit include/asm-generic/bitops/instrumented-non-atomic.h:134 [inline]
BUG: KASAN: null-ptr-deref in ida_free+0x1b6/0x2e0 lib/idr.c:510
Read of size 8 at addr 0000000000000000 by task syz-executor185/3627

CPU: 1 PID: 3627 Comm: syz-executor185 Not tainted 5.19.0-rc3-next-20220623-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
 kasan_report+0xbe/0x1f0 mm/kasan/report.c:495
 check_region_inline mm/kasan/generic.c:183 [inline]
 kasan_check_range+0x13d/0x180 mm/kasan/generic.c:189
 instrument_atomic_read include/linux/instrumented.h:71 [inline]
 test_bit include/asm-generic/bitops/instrumented-non-atomic.h:134 [inline]
 ida_free+0x1b6/0x2e0 lib/idr.c:510
 dev_free+0xec/0x700 drivers/usb/gadget/legacy/raw_gadget.c:212
 kref_put include/linux/kref.h:65 [inline]
 raw_release+0x219/0x290 drivers/usb/gadget/legacy/raw_gadget.c:424
 __fput+0x277/0x9d0 fs/file_table.c:317
 task_work_run+0xdd/0x1a0 kernel/task_work.c:177
 exit_task_work include/linux/task_work.h:38 [inline]
 do_exit+0xb05/0x2a00 kernel/exit.c:795
 do_group_exit+0xd2/0x2f0 kernel/exit.c:925
 __do_sys_exit_group kernel/exit.c:936 [inline]
 __se_sys_exit_group kernel/exit.c:934 [inline]
 __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:934
 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:0x7f12d28b6bd9
Code: Unable to access opcode bytes at RIP 0x7f12d28b6baf.
RSP: 002b:00007ffea2859da8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007f12d292b3f0 RCX: 00007f12d28b6bd9
RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
RBP: 0000000000000000 R08: ffffffffffffffc0 R09: 000000000000000b
R10: 00007ffea2857e00 R11: 0000000000000246 R12: 00007f12d292b3f0
R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000001
 </TASK>
==================================================================

Crashes (3):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-linux-next-kasan-gce-root 2022/06/23 19:00 linux-next 08897940f458 912f5df7 .config log report syz C KASAN: null-ptr-deref Read in ida_free
ci-upstream-linux-next-kasan-gce-root 2022/06/25 03:37 linux-next 2f9cb3d3bd73 a371c43c .config log report info KASAN: null-ptr-deref Read in ida_free
ci-upstream-linux-next-kasan-gce-root 2022/06/23 18:46 linux-next 08897940f458 912f5df7 .config log report info KASAN: null-ptr-deref Read in ida_free
* Struck through repros no longer work on HEAD.