================================================================== BUG: KASAN: slab-use-after-free in find_endpoint+0x2a3/0x2c0 drivers/usb/gadget/udc/dummy_hcd.c:1622 Read of size 1 at addr ffff8880526504e8 by task syz.0.2665/14733 CPU: 0 UID: 0 PID: 14733 Comm: syz.0.2665 Tainted: G L syzkaller #0 PREEMPT(full) Tainted: [L]=SOFTLOCKUP Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0x13d/0x4b0 mm/kasan/report.c:482 kasan_report+0xdf/0x1c0 mm/kasan/report.c:595 find_endpoint+0x2a3/0x2c0 drivers/usb/gadget/udc/dummy_hcd.c:1622 dummy_timer+0x500/0x3820 drivers/usb/gadget/udc/dummy_hcd.c:1894 __run_hrtimer kernel/time/hrtimer.c:2074 [inline] __hrtimer_run_queues+0x462/0x9c0 kernel/time/hrtimer.c:2131 hrtimer_run_softirq+0x1ca/0x360 kernel/time/hrtimer.c:2148 handle_softirqs+0x1e6/0x9d0 kernel/softirq.c:645 __do_softirq kernel/softirq.c:679 [inline] invoke_softirq kernel/softirq.c:519 [inline] __irq_exit_rcu+0x16a/0x210 kernel/softirq.c:758 irq_exit_rcu+0x9/0x30 kernel/softirq.c:775 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1062 [inline] sysvec_apic_timer_interrupt+0x56/0xc0 arch/x86/kernel/apic/apic.c:1062 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:674 RIP: 0023:0xf7000505 Code: 89 54 24 10 8d ab 0c 70 02 00 89 4c 24 1c 89 44 24 18 89 7c 24 04 89 ca 8b 5c 24 08 8b 7c 24 0c 81 e2 ff 1f 00 00 8b 44 d5 00 <8b> 74 d5 04 31 c3 31 f7 09 fb 74 4f 09 f0 74 7c 8b 74 24 04 0f b6 RSP: 002b:00000000ffc3ce88 EFLAGS: 00000202 RAX: 000000008bce99e3 RBX: 000000008bce99e3 RCX: 000000008bce99e3 RDX: 00000000000019e3 RSI: 0000000000000d82 RDI: 00000000ffffffff RBP: 00000000f73d2000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 12124: kasan_save_stack+0x30/0x50 mm/kasan/common.c:57 kasan_save_track+0x14/0x30 mm/kasan/common.c:78 poison_kmalloc_redzone mm/kasan/common.c:409 [inline] __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:426 kasan_kmalloc include/linux/kasan.h:263 [inline] __do_kmalloc_node mm/slub.c:5414 [inline] __kmalloc_noprof+0x32f/0x840 mm/slub.c:5439 _kmalloc_noprof include/linux/slab.h:995 [inline] usb_copy_descriptors+0xcd/0x320 drivers/usb/gadget/config.c:82 f_midi2_bind+0x1dad/0x2770 drivers/usb/gadget/function/f_midi2.c:2025 usb_add_function+0x219/0x890 drivers/usb/gadget/composite.c:333 configfs_composite_bind+0xd83/0x1960 drivers/usb/gadget/configfs.c:1802 gadget_bind_driver+0x28c/0xbf0 drivers/usb/gadget/udc/core.c:1662 call_driver_probe drivers/base/dd.c:628 [inline] really_probe+0x241/0xa60 drivers/base/dd.c:706 __driver_probe_device+0x210/0x460 drivers/base/dd.c:868 driver_probe_device+0x4a/0x140 drivers/base/dd.c:898 __driver_attach+0x21f/0x5b0 drivers/base/dd.c:1292 bus_for_each_dev+0x13e/0x1d0 drivers/base/bus.c:383 bus_add_driver+0x305/0x5b0 drivers/base/bus.c:763 driver_register+0x1e2/0x360 drivers/base/driver.c:174 usb_gadget_register_driver_owner+0x132/0x210 drivers/usb/gadget/udc/core.c:1752 gadget_dev_desc_UDC_store+0x1b0/0x2e0 drivers/usb/gadget/configfs.c:300 flush_write_buffer fs/configfs/file.c:207 [inline] configfs_write_iter+0x302/0x4e0 fs/configfs/file.c:229 new_sync_write fs/read_write.c:595 [inline] vfs_write+0x6af/0x1050 fs/read_write.c:687 ksys_write+0x12a/0x250 fs/read_write.c:739 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x13a/0x8b0 arch/x86/entry/syscall_32.c:291 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:316 entry_SYSENTER_compat_after_hwframe+0x84/0x8e Freed by task 14708: kasan_save_stack+0x30/0x50 mm/kasan/common.c:57 kasan_save_track+0x14/0x30 mm/kasan/common.c:78 kasan_save_free_info+0x3b/0x70 mm/kasan/generic.c:584 poison_slab_object mm/kasan/common.c:264 [inline] __kasan_slab_free+0x5f/0x80 mm/kasan/common.c:296 kasan_slab_free include/linux/kasan.h:235 [inline] slab_free_hook mm/slub.c:2748 [inline] slab_free mm/slub.c:6509 [inline] kfree+0x22b/0x6d0 mm/slub.c:6802 usb_free_descriptors include/linux/usb/gadget.h:903 [inline] usb_free_all_descriptors+0x81/0x1a0 drivers/usb/gadget/config.c:151 purge_configs_funcs+0x285/0x510 drivers/usb/gadget/configfs.c:1600 configfs_composite_unbind+0xae/0x210 drivers/usb/gadget/configfs.c:1846 gadget_unbind_driver+0x20c/0x4f0 drivers/usb/gadget/udc/core.c:1724 device_remove+0xcb/0x180 drivers/base/dd.c:616 __device_release_driver drivers/base/dd.c:1349 [inline] device_release_driver_internal+0x44e/0x620 drivers/base/dd.c:1372 driver_detach+0xd8/0x1b0 drivers/base/dd.c:1435 bus_remove_driver+0x13b/0x2e0 drivers/base/bus.c:832 driver_unregister+0x76/0xb0 drivers/base/driver.c:202 usb_gadget_unregister_driver+0x49/0x70 drivers/usb/gadget/udc/core.c:1784 unregister_gadget drivers/usb/gadget/configfs.c:263 [inline] gadget_dev_desc_UDC_store+0x170/0x2e0 drivers/usb/gadget/configfs.c:290 flush_write_buffer fs/configfs/file.c:207 [inline] configfs_write_iter+0x302/0x4e0 fs/configfs/file.c:229 new_sync_write fs/read_write.c:595 [inline] vfs_write+0x6af/0x1050 fs/read_write.c:687 ksys_write+0x12a/0x250 fs/read_write.c:739 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x13a/0x8b0 arch/x86/entry/syscall_32.c:291 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:316 entry_SYSENTER_compat_after_hwframe+0x84/0x8e The buggy address belongs to the object at ffff888052650400 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 232 bytes inside of freed 512-byte region [ffff888052650400, ffff888052650600) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff888052650000 pfn:0x52650 head: order:2 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0x4fff00000000240(workingset|head|node=1|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 04fff00000000240 ffff88801d042c80 ffffea00013cce10 ffffea000165c810 raw: ffff888052650000 000000000010000d 00000000f5000000 0000000000000000 head: 04fff00000000240 ffff88801d042c80 ffffea00013cce10 ffffea000165c810 head: ffff888052650000 000000000010000d 00000000f5000000 0000000000000000 head: 04fff00000000002 ffffffffffffff01 00000000ffffffff 00000000ffffffff head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000004 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 12124, tgid 12123 (syz.2.1848), ts 313691700317 set_page_owner include/linux/page_owner.h:33 [inline] post_alloc_hook+0xfd/0x120 mm/page_alloc.c:1871 prep_new_page mm/page_alloc.c:1879 [inline] get_page_from_freelist+0x110d/0x35d0 mm/page_alloc.c:3943 __alloc_frozen_pages_noprof+0x2eb/0x3300 mm/page_alloc.c:5436 alloc_slab_page mm/slub.c:3347 [inline] allocate_slab mm/slub.c:3462 [inline] new_slab+0xa9/0x6e0 mm/slub.c:3513 refill_objects+0xe3/0x410 mm/slub.c:7418 refill_sheaf mm/slub.c:2885 [inline] __pcs_replace_empty_main+0x35e/0x650 mm/slub.c:4774 alloc_from_pcs mm/slub.c:4850 [inline] slab_alloc_node mm/slub.c:4984 [inline] __kmalloc_cache_noprof+0x4f4/0x6d0 mm/slub.c:5559 _kmalloc_noprof include/linux/slab.h:991 [inline] snd_mixer_oss_build_test+0x7a/0x380 sound/core/oss/mixer_oss.c:893 snd_mixer_oss_build_test_all+0x1ac/0x6e0 sound/core/oss/mixer_oss.c:948 snd_mixer_oss_build_input+0x139/0xd50 sound/core/oss/mixer_oss.c:1017 snd_mixer_oss_build sound/core/oss/mixer_oss.c:1276 [inline] snd_mixer_oss_notify_handler+0x48d/0x990 sound/core/oss/mixer_oss.c:1344 snd_card_register+0x2af/0x760 sound/core/init.c:936 f_midi2_create_card drivers/usb/gadget/function/f_midi2.c:1615 [inline] f_midi2_bind+0x1198/0x2770 drivers/usb/gadget/function/f_midi2.c:1947 usb_add_function+0x219/0x890 drivers/usb/gadget/composite.c:333 configfs_composite_bind+0xd83/0x1960 drivers/usb/gadget/configfs.c:1802 gadget_bind_driver+0x28c/0xbf0 drivers/usb/gadget/udc/core.c:1662 page last free pid 5747 tgid 5747 ts 311036368776 stack trace: reset_page_owner include/linux/page_owner.h:26 [inline] __free_pages_prepare mm/page_alloc.c:1418 [inline] __free_frozen_pages+0x79f/0x10f0 mm/page_alloc.c:2962 qlink_free mm/kasan/quarantine.c:163 [inline] qlist_free_all+0x47/0xf0 mm/kasan/quarantine.c:179 kasan_quarantine_reduce+0x1a0/0x1f0 mm/kasan/quarantine.c:286 __kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:361 kasan_slab_alloc include/linux/kasan.h:253 [inline] slab_post_alloc_hook mm/slub.c:4683 [inline] slab_alloc_node mm/slub.c:4996 [inline] __kmalloc_cache_node_noprof+0x28e/0x720 mm/slub.c:5578 _kmalloc_node_noprof include/linux/slab.h:1196 [inline] __get_vm_area_node+0x124/0x350 mm/vmalloc.c:3237 __vmalloc_node_range_noprof+0x268/0x1420 mm/vmalloc.c:4064 __vmalloc_node_noprof+0xad/0xf0 mm/vmalloc.c:4165 xt_compat_init_offsets+0xe2/0x1f0 net/netfilter/x_tables.c:779 ebt_compat_init_offsets net/bridge/netfilter/ebtables.c:1841 [inline] compat_table_info+0x11b/0x870 net/bridge/netfilter/ebtables.c:1852 compat_do_ebt_get_ctl+0x270/0xbb0 net/bridge/netfilter/ebtables.c:2439 do_ebt_get_ctl+0x243/0x7a0 net/bridge/netfilter/ebtables.c:2504 nf_getsockopt+0x7c/0xe0 net/netfilter/nf_sockopt.c:116 ip_getsockopt+0x192/0x1e0 net/ipv4/ip_sockglue.c:1777 tcp_getsockopt+0xa1/0x110 net/ipv4/tcp.c:4875 do_sock_getsockopt+0x50a/0x6e0 net/socket.c:2503 Memory state around the buggy address: ffff888052650380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888052650400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888052650480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888052650500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888052650580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== ---------------- Code disassembly (best guess): 0: 89 54 24 10 mov %edx,0x10(%rsp) 4: 8d ab 0c 70 02 00 lea 0x2700c(%rbx),%ebp a: 89 4c 24 1c mov %ecx,0x1c(%rsp) e: 89 44 24 18 mov %eax,0x18(%rsp) 12: 89 7c 24 04 mov %edi,0x4(%rsp) 16: 89 ca mov %ecx,%edx 18: 8b 5c 24 08 mov 0x8(%rsp),%ebx 1c: 8b 7c 24 0c mov 0xc(%rsp),%edi 20: 81 e2 ff 1f 00 00 and $0x1fff,%edx 26: 8b 44 d5 00 mov 0x0(%rbp,%rdx,8),%eax * 2a: 8b 74 d5 04 mov 0x4(%rbp,%rdx,8),%esi <-- trapping instruction 2e: 31 c3 xor %eax,%ebx 30: 31 f7 xor %esi,%edi 32: 09 fb or %edi,%ebx 34: 74 4f je 0x85 36: 09 f0 or %esi,%eax 38: 74 7c je 0xb6 3a: 8b 74 24 04 mov 0x4(%rsp),%esi 3e: 0f .byte 0xf 3f: b6 .byte 0xb6