syzbot


KASAN: invalid-free in raw_ioctl

Status: closed as dup on 2024/09/21 21:01
Subsystems: usb
[Documentation on labels]
Reported-by: syzbot+c17537a52fdd1e1bf35a@syzkaller.appspotmail.com
First crash: 122d, last: 47d
Duplicate of
Title Repro Cause bisect Fix bisect Count Last Reported
KASAN: invalid-free in dev_free usb C 1162 46d 126d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [usb?] KASAN: invalid-free in raw_ioctl 1 (2) 2024/09/21 21:01

Sample crash report:
misc raw-gadget: fail, usb_gadget_register_driver returned -16
UDC core: USB Raw Gadget: couldn't find an available UDC or it's busy
misc raw-gadget: fail, usb_gadget_register_driver returned -16
==================================================================
BUG: KASAN: double-free in raw_ioctl_ep_disable drivers/usb/gadget/legacy/raw_gadget.c:964 [inline]
BUG: KASAN: double-free in raw_ioctl+0x4e1/0x2b90 drivers/usb/gadget/legacy/raw_gadget.c:1321
Free of addr ffff888118cab620 by task syz.1.381/6701

CPU: 0 UID: 0 PID: 6701 Comm: syz.1.381 Not tainted 6.12.0-rc4-syzkaller-00066-gbf373d2919d9 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0xc3/0x620 mm/kasan/report.c:488
 kasan_report_invalid_free+0xaa/0xd0 mm/kasan/report.c:563
 check_slab_allocation+0xfd/0x130 mm/kasan/common.c:225
 kasan_slab_pre_free include/linux/kasan.h:195 [inline]
 slab_free_hook mm/slub.c:2287 [inline]
 slab_free mm/slub.c:4579 [inline]
 kfree+0xff/0x480 mm/slub.c:4727
 raw_ioctl_ep_disable drivers/usb/gadget/legacy/raw_gadget.c:964 [inline]
 raw_ioctl+0x4e1/0x2b90 drivers/usb/gadget/legacy/raw_gadget.c:1321
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:907 [inline]
 __se_sys_ioctl fs/ioctl.c:893 [inline]
 __x64_sys_ioctl+0x18f/0x220 fs/ioctl.c:893
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f7ec627e31b
Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <89> c2 3d 00 f0 ff ff 77 1c 48 8b 44 24 18 64 48 2b 04 25 28 00 00
RSP: 002b:00007f7ec4ed3f00 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f7ec6560320 RCX: 00007f7ec627e31b
RDX: 0000000000000009 RSI: 0000000040045506 RDI: 0000000000000004
RBP: 0000000000000004 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000004 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f7ec6560320 R15: 0000000000000000
 </TASK>

Allocated by task 6701:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:377 [inline]
 __kasan_kmalloc+0x8f/0xa0 mm/kasan/common.c:394
 kasan_kmalloc include/linux/kasan.h:257 [inline]
 __do_kmalloc_node mm/slub.c:4264 [inline]
 __kmalloc_node_track_caller_noprof+0x1ff/0x3e0 mm/slub.c:4283
 memdup_user+0x2a/0xd0 mm/util.c:226
 raw_ioctl_ep_enable drivers/usb/gadget/legacy/raw_gadget.c:847 [inline]
 raw_ioctl+0xbc4/0x2b90 drivers/usb/gadget/legacy/raw_gadget.c:1318
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:907 [inline]
 __se_sys_ioctl fs/ioctl.c:893 [inline]
 __x64_sys_ioctl+0x18f/0x220 fs/ioctl.c:893
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 6695:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:579
 poison_slab_object mm/kasan/common.c:247 [inline]
 __kasan_slab_free+0x37/0x50 mm/kasan/common.c:264
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:2342 [inline]
 slab_free mm/slub.c:4579 [inline]
 kfree+0x130/0x480 mm/slub.c:4727
 dev_free+0x446/0x700 drivers/usb/gadget/legacy/raw_gadget.c:225
 kref_put include/linux/kref.h:65 [inline]
 raw_release+0x168/0x2b0 drivers/usb/gadget/legacy/raw_gadget.c:473
 __fput+0x3f6/0xb60 fs/file_table.c:431
 __fput_sync+0x45/0x50 fs/file_table.c:516
 __do_sys_close fs/open.c:1565 [inline]
 __se_sys_close fs/open.c:1550 [inline]
 __x64_sys_close+0x86/0x100 fs/open.c:1550
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff888118cab620
 which belongs to the cache kmalloc-16 of size 16
The buggy address is located 0 bytes inside of
 16-byte region [ffff888118cab620, ffff888118cab630)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x118cab
flags: 0x200000000000000(node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000000 ffff888100041640 ffffea000440a800 dead000000000002
raw: 0000000000000000 0000000000800080 00000001f5000000 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0xd2cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5210, tgid 5210 (kworker/0:2), ts 85377514579, free_ts 83131417426
 create_dummy_stack mm/page_owner.c:94 [inline]
 register_dummy_stack+0x8a/0xd0 mm/page_owner.c:100
 init_page_owner+0x48/0xbd0 mm/page_owner.c:118
 invoke_init_callbacks mm/page_ext.c:148 [inline]
 page_ext_init+0x725/0xbf0 mm/page_ext.c:497
 mm_core_init+0x202/0x240 mm/mm_init.c:2667
page last free pid 5415 tgid 5415 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1108 [inline]
 free_unref_folios+0x8a5/0x1170 mm/page_alloc.c:2686
 folios_put_refs+0x363/0x4d0 mm/swap.c:1007
 free_pages_and_swap_cache+0x45f/0x510 mm/swap_state.c:335
 __tlb_batch_free_encoded_pages+0xf9/0x290 mm/mmu_gather.c:136
 tlb_batch_pages_flush mm/mmu_gather.c:149 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:366 [inline]
 tlb_flush_mmu mm/mmu_gather.c:373 [inline]
 tlb_finish_mmu+0x168/0x7b0 mm/mmu_gather.c:465
 exit_mmap+0x3df/0xb30 mm/mmap.c:1887
 __mmput kernel/fork.c:1347 [inline]
 mmput+0xdb/0x3e0 kernel/fork.c:1369
 exec_mmap fs/exec.c:1014 [inline]
 begin_new_exec+0x13b9/0x3390 fs/exec.c:1280
 load_elf_binary+0x7ee/0x4e20 fs/binfmt_elf.c:996
 search_binary_handler fs/exec.c:1752 [inline]
 exec_binprm fs/exec.c:1794 [inline]
 bprm_execve fs/exec.c:1845 [inline]
 bprm_execve+0x703/0x1950 fs/exec.c:1821
 do_execveat_common.isra.0+0x4f1/0x630 fs/exec.c:1952
 do_execve fs/exec.c:2026 [inline]
 __do_sys_execve fs/exec.c:2102 [inline]
 __se_sys_execve fs/exec.c:2097 [inline]
 __x64_sys_execve+0x8c/0xb0 fs/exec.c:2097
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
 ffff888118cab500: 00 00 fc fc fa fb fc fc fa fb fc fc fa fb fc fc
 ffff888118cab580: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc
>ffff888118cab600: fa fb fc fc fa fb fc fc 00 00 fc fc fa fb fc fc
                               ^
 ffff888118cab680: fa fb fc fc fa fb fc fc 00 00 fc fc fa fb fc fc
 ffff888118cab700: 00 00 fc fc fa fb fc fc 00 00 fc fc 00 00 fc fc
==================================================================

Crashes (13):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/04 08:15 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing bf373d2919d9 f00eed24 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: invalid-free in raw_ioctl
2024/11/03 18:01 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing c67e9601e29a f00eed24 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: invalid-free in raw_ioctl
2024/10/26 13:24 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing c6d9e43954bf 65e8686b .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: invalid-free in raw_ioctl
2024/10/21 13:32 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing c6d9e43954bf f1e4447c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: invalid-free in raw_ioctl
2024/10/20 20:18 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 07b887f8236e cd6fc0a3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: invalid-free in raw_ioctl
2024/10/15 02:50 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 64f3b5a6bc49 b01b6661 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: invalid-free in raw_ioctl
2024/10/10 02:29 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 4a9fe2a8ac53 0278d004 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: invalid-free in raw_ioctl
2024/10/04 13:17 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 9852d85ec9d4 d7906eff .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: invalid-free in raw_ioctl
2024/09/23 21:23 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 68d4209158f4 89298aad .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: invalid-free in raw_ioctl
2024/09/07 19:08 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 9c0c11bb87b0 9750182a .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: invalid-free in raw_ioctl
2024/09/03 06:08 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing fc88bb116179 8045124c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: invalid-free in raw_ioctl
2024/08/25 01:05 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 9a03b9a88e4a d7d32352 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: invalid-free in raw_ioctl
2024/08/20 17:37 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing ca7df2c7bb5f 9f0ab3fb .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: invalid-free in raw_ioctl
* Struck through repros no longer work on HEAD.