================================================================== 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 ffff8881174a5cc3 by task syz.1.8006/6239 CPU: 0 UID: 0 PID: 6239 Comm: syz.1.8006 Not tainted 6.12.0-rc1-syzkaller #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:0x7fb8b834dff9 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:00007fb8b6fc7038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007fb8b8505f80 RCX: 00007fb8b834dff9 RDX: 0000000000000000 RSI: 000000004004550d RDI: 0000000000000003 RBP: 00007fb8b83c0296 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fb8b8505f80 R15: 00007ffebbba09a8 Allocated by task 6255: 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 6239: 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 ffff8881174a5cc0 which belongs to the cache kmalloc-16 of size 16 The buggy address is located 3 bytes inside of freed 16-byte region [ffff8881174a5cc0, ffff8881174a5cd0) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1174a5 flags: 0x200000000000000(node=0|zone=2) page_type: f5(slab) raw: 0200000000000000 ffff888100041640 dead000000000100 dead000000000122 raw: 0000000000000000 0000000080800080 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 4942, tgid 4942 (kworker/1:5), ts 752483515098, free_ts 751465866541 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 kasprintf+0xc8/0x100 lib/kasprintf.c:59 device_get_devnode+0xb2/0x2c0 drivers/base/core.c:3959 dev_uevent+0x513/0x8f0 drivers/base/core.c:2650 kobject_uevent_env+0x656/0x1860 lib/kobject_uevent.c:573 device_add+0x10e0/0x1a70 drivers/base/core.c:3656 usb_new_device+0xd90/0x1a10 drivers/usb/core/hub.c:2651 hub_port_connect drivers/usb/core/hub.c:5521 [inline] hub_port_connect_change drivers/usb/core/hub.c:5661 [inline] port_event drivers/usb/core/hub.c:5821 [inline] hub_event+0x2e58/0x4f40 drivers/usb/core/hub.c:5903 page last free pid 41 tgid 41 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 __put_partials+0x14c/0x170 mm/slub.c:3146 qlink_free mm/kasan/quarantine.c:163 [inline] qlist_free_all+0x4e/0x120 mm/kasan/quarantine.c:179 kasan_quarantine_reduce+0x192/0x1e0 mm/kasan/quarantine.c:286 __kasan_slab_alloc+0x4e/0x70 mm/kasan/common.c:329 kasan_slab_alloc include/linux/kasan.h:247 [inline] slab_post_alloc_hook mm/slub.c:4086 [inline] slab_alloc_node mm/slub.c:4135 [inline] __kmalloc_cache_noprof+0x119/0x2c0 mm/slub.c:4291 kmalloc_noprof include/linux/slab.h:878 [inline] usb_control_msg+0xbd/0x4b0 drivers/usb/core/message.c:144 _usbctrl_vendorreq_sync+0xc6/0x1f0 drivers/net/wireless/realtek/rtlwifi/usb.c:42 _usb_read_sync+0x11d/0x190 drivers/net/wireless/realtek/rtlwifi/usb.c:75 rtl_read_dword drivers/net/wireless/realtek/rtlwifi/wifi.h:2911 [inline] read_efuse_byte+0x612/0x910 drivers/net/wireless/realtek/rtlwifi/efuse.c:182 read_efuse+0x9a7/0xd60 drivers/net/wireless/realtek/rtlwifi/efuse.c:282 efuse_read_all_map drivers/net/wireless/realtek/rtlwifi/efuse.c:648 [inline] rtl_efuse_shadow_map_update+0x1f8/0x2c0 drivers/net/wireless/realtek/rtlwifi/efuse.c:494 rtl_get_hwinfo+0xdb/0x880 drivers/net/wireless/realtek/rtlwifi/efuse.c:1224 _rtl92cu_read_adapter_info drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c:334 [inline] rtl92cu_read_eeprom_info+0x2bc/0x2730 drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c:411 rtl_usb_probe+0x915/0x24d0 drivers/net/wireless/realtek/rtlwifi/usb.c:1011 usb_probe_interface+0x309/0x9d0 drivers/usb/core/driver.c:399 Memory state around the buggy address: ffff8881174a5b80: fa fb fc fc fa fb fc fc 00 00 fc fc fa fb fc fc ffff8881174a5c00: 00 00 fc fc fa fb fc fc 00 00 fc fc 00 00 fc fc >ffff8881174a5c80: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc ^ ffff8881174a5d00: 00 00 fc fc 00 00 fc fc 00 00 fc fc 00 00 fc fc ffff8881174a5d80: fa fb fc fc 00 00 fc fc 00 00 fc fc 00 00 fc fc ==================================================================