================================================================== 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+0x4e7/0x2b90 drivers/usb/gadget/legacy/raw_gadget.c:1321 Free of addr ffff888116f057e0 by task syz.4.2564/13645 CPU: 1 UID: 0 PID: 13645 Comm: syz.4.2564 Not tainted 6.11.0-rc4-syzkaller-00071-g9a03b9a88e4a #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024 Call Trace: __dump_stack lib/dump_stack.c:93 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:119 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 poison_slab_object+0x135/0x160 mm/kasan/common.c:232 __kasan_slab_free+0x14/0x30 mm/kasan/common.c:256 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2252 [inline] slab_free mm/slub.c:4473 [inline] kfree+0x10b/0x380 mm/slub.c:4594 raw_ioctl_ep_disable drivers/usb/gadget/legacy/raw_gadget.c:964 [inline] raw_ioctl+0x4e7/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+0x193/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:0x7f26896d9a7b 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:00007f2688354f00 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f26899a0320 RCX: 00007f26896d9a7b RDX: 000000000000000b RSI: 0000000040045506 RDI: 0000000000000003 RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000010 R10: 0000000000000003 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f26899a0320 R15: 0000000000000000 Allocated by task 13654: 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:370 [inline] __kasan_kmalloc+0x8f/0xa0 mm/kasan/common.c:387 kasan_kmalloc include/linux/kasan.h:211 [inline] __do_kmalloc_node mm/slub.c:4158 [inline] __kmalloc_node_track_caller_noprof+0x1ff/0x3e0 mm/slub.c:4177 memdup_user+0x2a/0xd0 mm/util.c:226 raw_ioctl_ep_enable drivers/usb/gadget/legacy/raw_gadget.c:847 [inline] raw_ioctl+0xbca/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+0x193/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 13645: 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+0xf7/0x160 mm/kasan/common.c:240 __kasan_slab_free+0x14/0x30 mm/kasan/common.c:256 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2252 [inline] slab_free mm/slub.c:4473 [inline] kfree+0x10b/0x380 mm/slub.c:4594 dev_free+0x446/0x700 drivers/usb/gadget/legacy/raw_gadget.c:225 kref_put include/linux/kref.h:65 [inline] raw_release+0x16e/0x2c0 drivers/usb/gadget/legacy/raw_gadget.c:473 __fput+0x408/0xbb0 fs/file_table.c:422 __fput_sync+0x47/0x50 fs/file_table.c:507 __do_sys_close fs/open.c:1566 [inline] __se_sys_close fs/open.c:1551 [inline] __x64_sys_close+0x86/0x100 fs/open.c:1551 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 ffff888116f057e0 which belongs to the cache kmalloc-16 of size 16 The buggy address is located 0 bytes inside of 16-byte region [ffff888116f057e0, ffff888116f057f0) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x116f05 flags: 0x200000000000000(node=0|zone=2) page_type: 0xfdffffff(slab) raw: 0200000000000000 ffff888100041640 dead000000000100 dead000000000122 raw: 0000000000000000 0000000000800080 00000001fdffffff 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 0x1d2c00(GFP_NOIO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 42, tgid 42 (kworker/0:2), ts 903720997446, free_ts 903529686205 create_dummy_stack mm/page_owner.c:94 [inline] register_dummy_stack+0x8a/0xd0 mm/page_owner.c:100 init_page_owner+0x48/0xbe0 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:2673 page last free pid 11986 tgid 11985 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1094 [inline] free_unref_folios+0x909/0x12d0 mm/page_alloc.c:2660 folios_put_refs+0x370/0x4e0 mm/swap.c:1039 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+0x3d1/0xb20 mm/mmap.c:3425 __mmput kernel/fork.c:1345 [inline] mmput+0xdb/0x3e0 kernel/fork.c:1367 exit_mm kernel/exit.c:571 [inline] do_exit+0x9bf/0x2b30 kernel/exit.c:869 do_group_exit+0xd3/0x2a0 kernel/exit.c:1031 get_signal+0x25fd/0x2770 kernel/signal.c:2917 arch_do_signal_or_restart+0x90/0x7e0 arch/x86/kernel/signal.c:310 exit_to_user_mode_loop kernel/entry/common.c:111 [inline] exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline] __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline] syscall_exit_to_user_mode+0x147/0x260 kernel/entry/common.c:218 do_syscall_64+0xda/0x250 arch/x86/entry/common.c:89 entry_SYSCALL_64_after_hwframe+0x77/0x7f Memory state around the buggy address: ffff888116f05680: fa fb fc fc fa fb fc fc fa fb fc fc 00 00 fc fc ffff888116f05700: fa fb fc fc 00 00 fc fc fa fb fc fc fa fb fc fc >ffff888116f05780: 00 00 fc fc fa fb fc fc fa fb fc fc fa fb fc fc ^ ffff888116f05800: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc ffff888116f05880: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc ==================================================================