syzbot


KASAN: invalid-free in dev_free (2)

Status: upstream: reported on 2025/06/14 06:29
Subsystems: usb
[Documentation on labels]
Reported-by: syzbot+dd2af0b2069a926d6991@syzkaller.appspotmail.com
First crash: 24d, last: 15d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [usb?] KASAN: invalid-free in dev_free (2) 0 (1) 2025/06/14 06:29
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: invalid-free in dev_free usb C 1163 179d 325d 0/29 auto-obsoleted due to no activity on 2025/03/21 11:28

Sample crash report:
==================================================================
BUG: KASAN: double-free in dev_free+0x47e/0x740 drivers/usb/gadget/legacy/raw_gadget.c:225
Free of addr ffff8881355349e0 by task syz.2.260/6139

CPU: 0 UID: 0 PID: 6139 Comm: syz.2.260 Not tainted 6.16.0-rc2-syzkaller-00033-g9962d0433a86 #0 PREEMPT(voluntary) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
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:408 [inline]
 print_report+0xcd/0x680 mm/kasan/report.c:521
 kasan_report_invalid_free+0xb8/0xe0 mm/kasan/report.c:596
 check_slab_allocation+0xe8/0x110 mm/kasan/common.c:225
 kasan_slab_pre_free include/linux/kasan.h:198 [inline]
 slab_free_hook mm/slub.c:2326 [inline]
 slab_free mm/slub.c:4643 [inline]
 kfree+0xf3/0x470 mm/slub.c:4842
 dev_free+0x47e/0x740 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+0x3ff/0xb70 fs/file_table.c:465
 task_work_run+0x14d/0x240 kernel/task_work.c:227
 exit_task_work include/linux/task_work.h:40 [inline]
 do_exit+0x864/0x2bd0 kernel/exit.c:955
 do_group_exit+0xd3/0x2a0 kernel/exit.c:1104
 get_signal+0x2673/0x26d0 kernel/signal.c:3034
 arch_do_signal_or_restart+0x8f/0x7d0 arch/x86/kernel/signal.c:337
 exit_to_user_mode_loop+0x7c/0xe0 kernel/entry/common.c:111
 exit_to_user_mode_prepare include/linux/entry-common.h:330 [inline]
 syscall_exit_to_user_mode_work include/linux/entry-common.h:414 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:449 [inline]
 do_syscall_64+0x3e9/0x4b0 arch/x86/entry/syscall_64.c:100
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fb8db10d58a
Code: Unable to access opcode bytes at 0x7fb8db10d560.
RSP: 002b:00007fb8d9776ff0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 00007fb8db335fa0 RCX: 00007fb8db10d58a
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 00007fb8db190b39 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000003 R11: 0000000000000293 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fb8db335fa0 R15: 00007ffcf5b784c8
 </TASK>

Allocated by task 6142:
 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:260 [inline]
 __do_kmalloc_node mm/slub.c:4328 [inline]
 __kmalloc_node_track_caller_noprof+0x212/0x4c0 mm/slub.c:4347
 memdup_user+0x2a/0xe0 mm/util.c:220
 raw_ioctl_ep_enable drivers/usb/gadget/legacy/raw_gadget.c:847 [inline]
 raw_ioctl+0xc1f/0x2c30 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+0x18e/0x210 fs/ioctl.c:893
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xcd/0x4b0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 6139:
 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:576
 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:233 [inline]
 slab_free_hook mm/slub.c:2381 [inline]
 slab_free mm/slub.c:4643 [inline]
 kfree+0x283/0x470 mm/slub.c:4842
 dev_free+0x47e/0x740 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+0x3ff/0xb70 fs/file_table.c:465
 fput_close_sync+0x118/0x260 fs/file_table.c:570
 __do_sys_close fs/open.c:1589 [inline]
 __se_sys_close fs/open.c:1574 [inline]
 __x64_sys_close+0x8b/0x120 fs/open.c:1574
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xcd/0x4b0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

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

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x135534
flags: 0x200000000000000(node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000000 ffff888100041640 dead000000000100 dead000000000122
raw: 0000000000000000 0000000000800080 00000000f5000000 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 5206, tgid 5206 (udevd), ts 189574479292, free_ts 180626452945
 create_dummy_stack mm/page_owner.c:94 [inline]
 register_dummy_stack+0x89/0xd0 mm/page_owner.c:100
 init_page_owner+0x48/0x7b0 mm/page_owner.c:118
 invoke_init_callbacks mm/page_ext.c:148 [inline]
 page_ext_init+0x7aa/0xcc0 mm/page_ext.c:497
 mm_core_init+0x211/0x250 mm/mm_init.c:2783
page last free pid 5240 tgid 5240 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1248 [inline]
 __free_frozen_pages+0x78a/0x1040 mm/page_alloc.c:2706
 vfree+0x1fd/0xb50 mm/vmalloc.c:3426
 dvb_usb_adapter_dvb_exit+0xac/0x240 drivers/media/usb/dvb-usb/dvb-usb-dvb.c:225
 dvb_usb_adapter_exit drivers/media/usb/dvb-usb/dvb-usb-init.c:128 [inline]
 dvb_usb_exit drivers/media/usb/dvb-usb/dvb-usb-init.c:143 [inline]
 dvb_usb_device_exit+0x26d/0x580 drivers/media/usb/dvb-usb/dvb-usb-init.c:338
 usb_unbind_interface+0x1da/0x9a0 drivers/usb/core/driver.c:458
 device_remove drivers/base/dd.c:569 [inline]
 device_remove+0x122/0x170 drivers/base/dd.c:561
 __device_release_driver drivers/base/dd.c:1272 [inline]
 device_release_driver_internal+0x44b/0x620 drivers/base/dd.c:1295
 bus_remove_device+0x22f/0x420 drivers/base/bus.c:579
 device_del+0x396/0x9f0 drivers/base/core.c:3881
 usb_disable_device+0x355/0x7d0 drivers/usb/core/message.c:1418
 usb_disconnect+0x2e1/0x920 drivers/usb/core/hub.c:2316
 hub_port_connect drivers/usb/core/hub.c:5375 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5675 [inline]
 port_event drivers/usb/core/hub.c:5835 [inline]
 hub_event+0x1aa0/0x5030 drivers/usb/core/hub.c:5917
 process_one_work+0x9cc/0x1b70 kernel/workqueue.c:3238
 process_scheduled_works kernel/workqueue.c:3321 [inline]
 worker_thread+0x6c8/0xf10 kernel/workqueue.c:3402
 kthread+0x3c5/0x780 kernel/kthread.c:464
 ret_from_fork+0x5b3/0x6c0 arch/x86/kernel/process.c:148

Memory state around the buggy address:
 ffff888135534880: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc
 ffff888135534900: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc
>ffff888135534980: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc
                                                       ^
 ffff888135534a00: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc
 ffff888135534a80: 00 01 fc fc 00 01 fc fc 00 01 fc fc fa fb fc fc
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/06/22 22:49 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 9962d0433a86 d6cdfb8a .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: invalid-free in dev_free
2025/06/13 18:23 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 19272b37aa4f 98683f8f .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: invalid-free in dev_free
* Struck through repros no longer work on HEAD.