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: slab-use-after-free in usb_endpoint_xfer_isoc include/uapi/linux/usb/ch9.h:563 [inline] BUG: KASAN: slab-use-after-free in raw_ioctl_ep_set_clear_halt_wedge+0x4be/0x7c0 drivers/usb/gadget/legacy/raw_gadget.c:1012 Read of size 1 at addr ffff88810ebb6803 by task syz.3.933/8270 CPU: 0 UID: 0 PID: 8270 Comm: syz.3.933 Not tainted 6.12.0-rc1-syzkaller-00027-g4a9fe2a8ac53 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 Call Trace: __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+0xd9/0x110 mm/kasan/report.c:601 usb_endpoint_xfer_isoc include/uapi/linux/usb/ch9.h:563 [inline] raw_ioctl_ep_set_clear_halt_wedge+0x4be/0x7c0 drivers/usb/gadget/legacy/raw_gadget.c:1012 raw_ioctl+0xff/0x2b90 drivers/usb/gadget/legacy/raw_gadget.c:1350 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:0x7f68ca56dff9 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f68c91e1038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f68ca725f80 RCX: 00007f68ca56dff9 RDX: 0000000000000000 RSI: 000000004004550d RDI: 0000000000000003 RBP: 00007f68ca5e0296 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f68ca725f80 R15: 00007ffe80ff0bc8 Allocated by task 8277: 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 8270: 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 __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 ffff88810ebb6800 which belongs to the cache kmalloc-16 of size 16 The buggy address is located 3 bytes inside of freed 16-byte region [ffff88810ebb6800, ffff88810ebb6810) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10ebb6 anon flags: 0x200000000000000(node=0|zone=2) page_type: f5(slab) raw: 0200000000000000 ffff888100041640 0000000000000000 dead000000000001 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 1, tgid 1 (swapper/0), ts 6450815946, free_ts 6270913859 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_noprof+0x325/0x3c0 mm/slub.c:4277 kmalloc_noprof include/linux/slab.h:882 [inline] kzalloc_noprof include/linux/slab.h:1014 [inline] kobject_get_path+0xd9/0x2b0 lib/kobject.c:161 kobject_uevent_env+0x289/0x1860 lib/kobject_uevent.c:545 version_sysfs_builtin kernel/params.c:883 [inline] param_sysfs_builtin_init+0xfe/0x460 kernel/params.c:989 do_one_initcall+0x128/0x700 init/main.c:1269 do_initcall_level init/main.c:1331 [inline] do_initcalls init/main.c:1347 [inline] do_basic_setup init/main.c:1366 [inline] kernel_init_freeable+0x5c7/0x900 init/main.c:1580 kernel_init+0x1c/0x2b0 init/main.c:1469 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 last free pid 9 tgid 9 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1108 [inline] free_unref_page+0x58a/0xb50 mm/page_alloc.c:2638 vfree+0x17a/0x890 mm/vmalloc.c:3361 delayed_vfree_work+0x56/0x70 mm/vmalloc.c:3282 process_one_work+0x9c5/0x1ba0 kernel/workqueue.c:3229 process_scheduled_works kernel/workqueue.c:3310 [inline] worker_thread+0x6c8/0xf00 kernel/workqueue.c:3391 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 Memory state around the buggy address: ffff88810ebb6700: 00 01 fc fc 00 01 fc fc 00 00 fc fc 00 00 fc fc ffff88810ebb6780: 00 00 fc fc 00 00 fc fc 00 00 fc fc 00 00 fc fc >ffff88810ebb6800: fa fb fc fc 00 00 fc fc 00 00 fc fc 00 00 fc fc ^ ffff88810ebb6880: 00 00 fc fc 00 00 fc fc 00 01 fc fc 00 00 fc fc ffff88810ebb6900: 00 00 fc fc 00 00 fc fc 00 00 fc fc 00 00 fc fc ==================================================================