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: 50d, last: 7d21h
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 Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: invalid-free in dev_free usb 22 C 1163 204d 351d 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 ffff8881366c9800 by task syz.4.1149/9320

CPU: 0 UID: 0 PID: 9320 Comm: syz.4.1149 Not tainted 6.16.0-rc7-syzkaller-g51d4b0a44c82 #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:378 [inline]
 print_report+0xcd/0x610 mm/kasan/report.c:480
 kasan_report_invalid_free+0xb8/0xe0 mm/kasan/report.c:555
 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+0x402/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
RIP: 0033:0x7f093905d60a
Code: 48 3d 00 f0 ff ff 77 48 c3 0f 1f 80 00 00 00 00 48 83 ec 18 89 7c 24 0c e8 43 91 02 00 8b 7c 24 0c 89 c2 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 36 89 d7 89 44 24 0c e8 a3 91 02 00 8b 44 24
RSP: 002b:00007f09376c6ff0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: ffffffffffffffda RBX: 00007f0939285fa0 RCX: 00007f093905d60a
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 00007f09390e0d69 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000003 R11: 0000000000000293 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f0939285fa0 R15: 00007fff9a4c1ac8
 </TASK>

Allocated by task 9323:
 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 9323:
 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+0x402/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 ffff8881366c9800
 which belongs to the cache kmalloc-16 of size 16
The buggy address is located 0 bytes inside of
 16-byte region [ffff8881366c9800, ffff8881366c9810)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1366c9
anon flags: 0x200000000000000(node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000000 ffff888100041640 0000000000000000 dead000000000001
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 0x52820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 5233, tgid 5233 (kworker/0:3), ts 217766349931, free_ts 217754980930
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1c0/0x230 mm/page_alloc.c:1704
 prep_new_page mm/page_alloc.c:1712 [inline]
 get_page_from_freelist+0xf98/0x2ce0 mm/page_alloc.c:3669
 __alloc_frozen_pages_noprof+0x259/0x21e0 mm/page_alloc.c:4959
 alloc_pages_mpol+0xe4/0x410 mm/mempolicy.c:2419
 alloc_slab_page mm/slub.c:2451 [inline]
 allocate_slab mm/slub.c:2619 [inline]
 new_slab+0x23b/0x330 mm/slub.c:2673
 ___slab_alloc+0xda5/0x1940 mm/slub.c:3859
 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3949
 __slab_alloc_node mm/slub.c:4024 [inline]
 slab_alloc_node mm/slub.c:4185 [inline]
 __do_kmalloc_node mm/slub.c:4327 [inline]
 __kmalloc_noprof+0x15b/0x4d0 mm/slub.c:4340
 kmalloc_noprof include/linux/slab.h:909 [inline]
 raw_event_queue_add+0x84/0x220 drivers/usb/gadget/legacy/raw_gadget.c:72
 raw_queue_event drivers/usb/gadget/legacy/raw_gadget.c:239 [inline]
 gadget_setup+0x1a7/0x410 drivers/usb/gadget/legacy/raw_gadget.c:360
 dummy_timer+0x19e6/0x3a30 drivers/usb/gadget/udc/dummy_hcd.c:1927
 __run_hrtimer kernel/time/hrtimer.c:1761 [inline]
 __hrtimer_run_queues+0x1ff/0xad0 kernel/time/hrtimer.c:1825
 hrtimer_run_softirq+0x17d/0x350 kernel/time/hrtimer.c:1842
 handle_softirqs+0x208/0x8d0 kernel/softirq.c:579
 __do_softirq kernel/softirq.c:613 [inline]
 invoke_softirq kernel/softirq.c:453 [inline]
 __irq_exit_rcu+0xfa/0x160 kernel/softirq.c:680
 irq_exit_rcu+0x9/0x30 kernel/softirq.c:696
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
 selinux_genfs_get_sid security/selinux/hooks.c:1353 [inline]
 inode_doinit_with_dentry+0xacb/0x12e0 security/selinux/hooks.c:1551
 selinux_d_instantiate+0x26/0x30 security/selinux/hooks.c:6495
 security_d_instantiate+0x58/0xc0 security/security.c:4079
 d_splice_alias+0x93/0xf80 fs/dcache.c:2997
 kernfs_iop_lookup+0x23f/0x2d0 fs/kernfs/dir.c:1251
 lookup_open.isra.0+0x4c6/0x1560 fs/namei.c:3695
 open_last_lookups fs/namei.c:3816 [inline]
 path_openat+0x893/0x2cb0 fs/namei.c:4052
 do_filp_open+0x20b/0x470 fs/namei.c:4082
 do_sys_openat2+0x11b/0x1d0 fs/open.c:1437
 do_sys_open fs/open.c:1452 [inline]
 __do_sys_openat fs/open.c:1468 [inline]
 __se_sys_openat fs/open.c:1463 [inline]
 __x64_sys_openat+0x174/0x210 fs/open.c:1463
 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

Memory state around the buggy address:
 ffff8881366c9700: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc
 ffff8881366c9780: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc
>ffff8881366c9800: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc
                   ^
 ffff8881366c9880: 00 00 fc fc fa fb fc fc fa fb fc fc 00 05 fc fc
 ffff8881366c9900: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/07/26 02:30 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 51d4b0a44c82 fb8f743d .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: invalid-free in dev_free
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.