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: 47d, last: 2d22h
Duplicate of
Title Repro Cause bisect Fix bisect Count Last Reported
KASAN: invalid-free in dev_free usb C 665 5h55m 51d
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:
==================================================================
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 ffff8881016e8dc0 by task syz.3.3327/20625

CPU: 1 UID: 0 PID: 20625 Comm: syz.3.3327 Not tainted 6.12.0-rc1-syzkaller #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:2288 [inline]
 slab_free mm/slub.c:4580 [inline]
 kfree+0xff/0x480 mm/slub.c:4728
 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:0x7f5c3fc1dbfb
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:00007f5c3e88ef00 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f5c3ff00320 RCX: 00007f5c3fc1dbfb
RDX: 0000000000000000 RSI: 0000000040045506 RDI: 0000000000000003
RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000003 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f5c3ff00320 R15: 0000000000000000
 </TASK>

Allocated by task 20625:
 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:4265 [inline]
 __kmalloc_node_track_caller_noprof+0x1ff/0x3e0 mm/slub.c:4284
 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 18375:
 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:2343 [inline]
 slab_free mm/slub.c:4580 [inline]
 kfree+0x130/0x480 mm/slub.c:4728
 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
 task_work_run+0x14e/0x250 kernel/task_work.c:228
 exit_task_work include/linux/task_work.h:40 [inline]
 do_exit+0xadd/0x2ce0 kernel/exit.c:939
 do_group_exit+0xd3/0x2a0 kernel/exit.c:1088
 __do_sys_exit_group kernel/exit.c:1099 [inline]
 __se_sys_exit_group kernel/exit.c:1097 [inline]
 __x64_sys_exit_group+0x3e/0x50 kernel/exit.c:1097
 x64_sys_call+0x14a9/0x16a0 arch/x86/include/generated/asm/syscalls_64.h:232
 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 ffff8881016e8dc0
 which belongs to the cache kmalloc-16 of size 16
The buggy address is located 0 bytes inside of
 16-byte region [ffff8881016e8dc0, ffff8881016e8dd0)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1016e8
flags: 0x200000000000000(node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000000 ffff888100041640 dead000000000100 dead000000000122
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 0x52cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 8, tgid 8 (kworker/0:0), ts 2436409740, free_ts 0
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x2d1/0x350 mm/page_alloc.c:1537
 prep_new_page mm/page_alloc.c:1545 [inline]
 get_page_from_freelist+0xd5c/0x2630 mm/page_alloc.c:3457
 __alloc_pages_noprof+0x221/0x22a0 mm/page_alloc.c:4733
 alloc_pages_mpol_noprof+0xeb/0x400 mm/mempolicy.c:2265
 alloc_slab_page mm/slub.c:2413 [inline]
 allocate_slab mm/slub.c:2579 [inline]
 new_slab+0x2ba/0x3f0 mm/slub.c:2632
 ___slab_alloc+0xd45/0x1760 mm/slub.c:3819
 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3909
 __slab_alloc_node mm/slub.c:3962 [inline]
 slab_alloc_node mm/slub.c:4123 [inline]
 __do_kmalloc_node mm/slub.c:4264 [inline]
 __kmalloc_node_track_caller_noprof+0x14e/0x3e0 mm/slub.c:4284
 kvasprintf+0xbd/0x160 lib/kasprintf.c:25
 __kthread_create_on_node+0x189/0x400 kernel/kthread.c:445
 kthread_create_on_node+0xc8/0x110 kernel/kthread.c:513
 create_worker+0x413/0x800 kernel/workqueue.c:2793
 maybe_create_worker kernel/workqueue.c:3054 [inline]
 manage_workers kernel/workqueue.c:3106 [inline]
 worker_thread+0x9c5/0xf00 kernel/workqueue.c:3366
 kthread+0x2c1/0x3a0 kernel/kthread.c:389
 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
page_owner free stack trace missing

Memory state around the buggy address:
 ffff8881016e8c80: 00 00 fc fc fa fb fc fc 00 00 fc fc 00 00 fc fc
 ffff8881016e8d00: fa fb fc fc 00 00 fc fc 00 00 fc fc 00 00 fc fc
>ffff8881016e8d80: fa fb fc fc 00 00 fc fc fa fb fc fc fa fb fc fc
                                           ^
 ffff8881016e8e00: 00 00 fc fc fa fb fc fc 00 00 fc fc 00 00 fc fc
 ffff8881016e8e80: fa fb fc fc 00 00 fc fc 00 00 fc fc 00 00 fc fc
==================================================================

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
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.