================================================================== BUG: KASAN: slab-use-after-free in usb_endpoint_dir_in include/uapi/linux/usb/ch9.h:498 [inline] BUG: KASAN: slab-use-after-free in raw_process_ep_io+0x848/0xb90 drivers/usb/gadget/legacy/raw_gadget.c:1098 Read of size 1 at addr ffff88811b33d0c2 by task syz.4.936/8437 CPU: 0 UID: 0 PID: 8437 Comm: syz.4.936 Not tainted 6.12.0-rc4-syzkaller-00052-gc6d9e43954bf #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_dir_in include/uapi/linux/usb/ch9.h:498 [inline] raw_process_ep_io+0x848/0xb90 drivers/usb/gadget/legacy/raw_gadget.c:1098 raw_ioctl_ep_write drivers/usb/gadget/legacy/raw_gadget.c:1152 [inline] raw_ioctl+0xa4d/0x2b90 drivers/usb/gadget/legacy/raw_gadget.c:1324 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:0x7f8a164de31b 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:00007f8a1512ef70 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 0000000000000097 RCX: 00007f8a164de31b RDX: 00007f8a1512eff0 RSI: 0000000040085507 RDI: 0000000000000003 RBP: 0000000000000003 R08: 00007f8a167c0320 R09: 0000000000000000 R10: 0000000000000003 R11: 0000000000000246 R12: 0000000020002140 R13: 0000000000000000 R14: 00007f8a16696058 R15: 00007ffe40b96f38 Allocated by task 8437: 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:4264 [inline] __kmalloc_node_track_caller_noprof+0x1ff/0x3e0 mm/slub.c:4283 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 8434: 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:2342 [inline] slab_free mm/slub.c:4579 [inline] kfree+0x130/0x480 mm/slub.c:4727 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 ffff88811b33d0c0 which belongs to the cache kmalloc-16 of size 16 The buggy address is located 2 bytes inside of freed 16-byte region [ffff88811b33d0c0, ffff88811b33d0d0) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88811b33da40 pfn:0x11b33d flags: 0x200000000000200(workingset|node=0|zone=2) page_type: f5(slab) raw: 0200000000000200 ffff888100041640 ffffea00047c1d50 ffffea000424cb50 raw: ffff88811b33da40 000000000080007f 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 0xd2cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5373, tgid 5373 (kworker/0:5), ts 95561372329, free_ts 89418708647 create_dummy_stack mm/page_owner.c:94 [inline] register_dummy_stack+0x8a/0xd0 mm/page_owner.c:100 init_page_owner+0x48/0xbd0 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:2667 page last free pid 5243 tgid 5243 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:3145 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:4085 [inline] slab_alloc_node mm/slub.c:4134 [inline] __kmalloc_cache_noprof+0x119/0x2c0 mm/slub.c:4290 kmalloc_noprof include/linux/slab.h:878 [inline] usb_control_msg+0xbd/0x4b0 drivers/usb/core/message.c:144 rtl8xxxu_read32+0x100/0x1f0 drivers/net/wireless/realtek/rtl8xxxu/core.c:670 rtl8710b_indirect_read32+0xa8/0x1c0 drivers/net/wireless/realtek/rtl8xxxu/8710b.c:481 rtl8710b_read_syson_reg drivers/net/wireless/realtek/rtl8xxxu/8710b.c:532 [inline] rtl8710bu_identify_chip+0x39d/0x640 drivers/net/wireless/realtek/rtl8xxxu/8710b.c:647 rtl8xxxu_probe+0xfc1/0x6460 drivers/net/wireless/realtek/rtl8xxxu/core.c:7856 usb_probe_interface+0x309/0x9d0 drivers/usb/core/driver.c:399 call_driver_probe drivers/base/dd.c:579 [inline] really_probe+0x23e/0xa90 drivers/base/dd.c:658 __driver_probe_device+0x1de/0x440 drivers/base/dd.c:800 driver_probe_device+0x4c/0x1b0 drivers/base/dd.c:830 __device_attach_driver+0x1df/0x310 drivers/base/dd.c:958 Memory state around the buggy address: ffff88811b33cf80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88811b33d000: 00 00 fc fc fa fb fc fc fa fb fc fc fa fb fc fc >ffff88811b33d080: fa fb fc fc fa fb fc fc fa fb fc fc 00 00 fc fc ^ ffff88811b33d100: 00 00 fc fc 00 00 fc fc fa fb fc fc 00 00 fc fc ffff88811b33d180: 00 00 fc fc fa fb fc fc fa fb fc fc fa fb fc fc ==================================================================