================================================================== BUG: KASAN: slab-use-after-free in find_endpoint+0x2a3/0x2c0 drivers/usb/gadget/udc/dummy_hcd.c:1650 Read of size 1 at addr ffff88804dbd04e8 by task kworker/1:2/1360 CPU: 1 UID: 0 PID: 1360 Comm: kworker/1:2 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 Workqueue: usb_hub_wq hub_event 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:1650 dummy_timer+0x506/0x3840 drivers/usb/gadget/udc/dummy_hcd.c:1922 __run_hrtimer kernel/time/hrtimer.c:2079 [inline] __hrtimer_run_queues+0x448/0x9a0 kernel/time/hrtimer.c:2136 hrtimer_run_softirq+0x1ca/0x360 kernel/time/hrtimer.c:2153 handle_softirqs+0x216/0xa20 kernel/softirq.c:669 __do_softirq kernel/softirq.c:703 [inline] invoke_softirq kernel/softirq.c:542 [inline] __irq_exit_rcu+0x178/0x220 kernel/softirq.c:786 irq_exit_rcu+0x9/0x30 kernel/softirq.c:809 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1062 [inline] sysvec_apic_timer_interrupt+0xa3/0xc0 arch/x86/kernel/apic/apic.c:1062 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:674 RIP: 0010:vsnprintf+0x222/0x1300 lib/vsprintf.c:2892 Code: 30 e8 12 52 23 f6 41 80 fc 04 0f 84 f3 05 00 00 0f 87 3e 01 00 00 41 80 fc 02 0f 84 02 09 00 00 41 80 fc 03 0f 84 d7 07 00 00 <45> 84 e4 0f 84 2e 05 00 00 e8 10 57 23 f6 48 8b 54 24 38 48 b8 00 RSP: 0018:ffffc90006e2ecb0 EFLAGS: 00000293 RAX: 0000000000000002 RBX: ffffffff8ce98c24 RCX: ffff8880004d4b00 RDX: 0000000000000000 RSI: ffffffff8bea74de RDI: 0000000000000001 RBP: ffffc90006e2eda0 R08: 0000000000000007 R09: 0000000000000000 R10: ffff8880279782fe R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000069 R14: ffffffff8ce98c22 R15: 0000000000000004 add_uevent_var+0x183/0x3a0 lib/kobject_uevent.c:682 usb_if_uevent+0x335/0x4e0 drivers/usb/core/message.c:1903 dev_uevent+0x2f1/0x870 drivers/base/core.c:2783 kobject_uevent_env+0x6eb/0x18b0 lib/kobject_uevent.c:576 driver_bound+0x13e/0x220 drivers/base/dd.c:470 really_probe+0x3d4/0xa60 drivers/base/dd.c:757 __driver_probe_device+0x210/0x460 drivers/base/dd.c:869 driver_probe_device+0x4a/0x140 drivers/base/dd.c:899 __device_attach_driver+0x1df/0x320 drivers/base/dd.c:1027 bus_for_each_drv+0x159/0x1e0 drivers/base/bus.c:500 __device_attach+0x1e4/0x4c0 drivers/base/dd.c:1131 device_initial_probe+0xaf/0xf0 drivers/base/dd.c:1190 __bus_probe_device+0x60/0x160 drivers/base/bus.c:614 device_add+0x121d/0x1970 drivers/base/core.c:3778 usb_set_configuration+0xd97/0x1dc0 drivers/usb/core/message.c:2280 usb_generic_driver_probe+0xa1/0xe0 drivers/usb/core/generic.c:250 usb_probe_device+0xef/0x400 drivers/usb/core/driver.c:293 call_driver_probe drivers/base/dd.c:629 [inline] really_probe+0x241/0xa60 drivers/base/dd.c:707 __driver_probe_device+0x210/0x460 drivers/base/dd.c:869 driver_probe_device+0x4a/0x140 drivers/base/dd.c:899 __device_attach_driver+0x1df/0x320 drivers/base/dd.c:1027 bus_for_each_drv+0x159/0x1e0 drivers/base/bus.c:500 __device_attach+0x1e4/0x4c0 drivers/base/dd.c:1131 device_initial_probe+0xaf/0xf0 drivers/base/dd.c:1190 __bus_probe_device+0x60/0x160 drivers/base/bus.c:614 device_add+0x121d/0x1970 drivers/base/core.c:3778 usb_new_device.part.0+0xcc2/0x1686 drivers/usb/core/hub.c:2713 usb_new_device include/linux/workqueue.h:715 [inline] hub_port_connect drivers/usb/core/hub.c:5585 [inline] hub_port_connect_change drivers/usb/core/hub.c:5725 [inline] port_event drivers/usb/core/hub.c:5889 [inline] hub_event.cold+0x1e3/0xe90 drivers/usb/core/hub.c:5971 process_one_work+0xac7/0x1b10 kernel/workqueue.c:3495 process_scheduled_works kernel/workqueue.c:3578 [inline] worker_thread+0x5ef/0xe50 kernel/workqueue.c:3659 kthread+0x373/0x450 kernel/kthread.c:436 ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 Allocated by task 7197: 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] __kmalloc_cache_noprof+0x2f8/0x6d0 mm/slub.c:5680 _kmalloc_noprof include/linux/slab.h:991 [inline] _kzalloc_noprof include/linux/slab.h:1312 [inline] kernfs_fop_open+0x347/0x10f0 fs/kernfs/file.c:648 do_dentry_open+0x674/0x1470 fs/open.c:1000 vfs_open_consume+0xcc/0x460 fs/open.c:1131 do_open fs/namei.c:4851 [inline] path_openat+0x1547/0x23f0 fs/namei.c:5016 do_file_open+0x20e/0x430 fs/namei.c:5045 do_sys_openat2+0x163/0x1d0 fs/open.c:1443 do_sys_open fs/open.c:1449 [inline] __do_sys_openat fs/open.c:1465 [inline] __se_sys_openat fs/open.c:1460 [inline] __x64_sys_openat+0x12d/0x210 fs/open.c:1460 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x121/0x770 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 7197: 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:2780 [inline] slab_free mm/slub.c:6630 [inline] kfree+0x22b/0x6d0 mm/slub.c:6923 kernfs_fop_release+0x12c/0x1f0 fs/kernfs/file.c:793 __fput+0x3fb/0xb50 fs/file_table.c:512 fput_close_sync+0x118/0x250 fs/file_table.c:618 filp_close_sync+0x75/0xa0 fs/open.c:1574 __do_sys_close fs/open.c:1597 [inline] __se_sys_close fs/open.c:1584 [inline] __x64_sys_close+0x81/0x110 fs/open.c:1584 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x121/0x770 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f The buggy address belongs to the object at ffff88804dbd0400 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 232 bytes inside of freed 512-byte region [ffff88804dbd0400, ffff88804dbd0600) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff88804dbd0000 pfn:0x4dbd0 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 ffff88801d442c80 ffffea0001107910 ffffea0001200a10 raw: ffff88804dbd0000 0000000000100008 00000000f5000000 0000000000000000 head: 04fff00000000240 ffff88801d442c80 ffffea0001107910 ffffea0001200a10 head: ffff88804dbd0000 0000000000100008 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 7158, tgid 7157 (syz.3.292), ts 102127256214 set_page_owner include/linux/page_owner.h:33 [inline] post_alloc_hook+0xfd/0x120 mm/page_alloc.c:1859 prep_new_page mm/page_alloc.c:1867 [inline] get_page_from_freelist+0x112f/0x3640 mm/page_alloc.c:3940 __alloc_frozen_pages_noprof+0x2ad/0x31e0 mm/page_alloc.c:5464 alloc_slab_page mm/slub.c:3384 [inline] allocate_slab mm/slub.c:3499 [inline] new_slab+0xb1/0x6d0 mm/slub.c:3550 refill_objects+0xe3/0x410 mm/slub.c:7539 refill_sheaf mm/slub.c:2917 [inline] __pcs_replace_empty_main+0x35e/0x650 mm/slub.c:4811 alloc_from_pcs mm/slub.c:4887 [inline] slab_alloc_node mm/slub.c:5021 [inline] __kmalloc_cache_noprof+0x4ef/0x6d0 mm/slub.c:5676 _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:1277 [inline] snd_mixer_oss_notify_handler+0x4e5/0xa10 sound/core/oss/mixer_oss.c:1355 snd_mixer_oss_notify sound/core/init.c:92 [inline] snd_card_register+0x2bd/0x780 sound/core/init.c:929 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:1663 page last free pid 5792 tgid 5792 ts 97066933484 stack trace: reset_page_owner include/linux/page_owner.h:26 [inline] __free_pages_prepare mm/page_alloc.c:1403 [inline] __free_frozen_pages+0x7b4/0x1110 mm/page_alloc.c:2957 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:4720 [inline] slab_alloc_node mm/slub.c:5033 [inline] kmem_cache_alloc_noprof+0x269/0x6a0 mm/slub.c:5047 ptlock_alloc+0x1f/0x70 mm/memory.c:7814 ptlock_init include/linux/mm.h:4043 [inline] pagetable_pte_ctor include/linux/mm.h:4092 [inline] __pte_alloc_one_noprof include/asm-generic/pgalloc.h:79 [inline] pte_alloc_one+0x82/0x3d0 arch/x86/mm/pgtable.c:18 __pte_alloc+0x6d/0x3e0 mm/memory.c:453 copy_pte_range mm/memory.c:1298 [inline] copy_pmd_range mm/memory.c:1453 [inline] copy_pud_range mm/memory.c:1488 [inline] copy_p4d_range mm/memory.c:1512 [inline] copy_page_range+0x3cad/0x5a00 mm/memory.c:1598 dup_mmap+0x1515/0x2180 mm/mmap.c:1813 dup_mm kernel/fork.c:1549 [inline] copy_mm kernel/fork.c:1602 [inline] copy_process+0x7c5c/0x88e0 kernel/fork.c:2328 kernel_clone+0x176/0x9d0 kernel/fork.c:2798 __do_compat_sys_ia32_clone+0xd4/0x120 arch/x86/kernel/sys_ia32.c:255 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x14b/0x8c0 arch/x86/entry/syscall_32.c:282 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:307 entry_SYSENTER_compat_after_hwframe+0x84/0x8e Memory state around the buggy address: ffff88804dbd0380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88804dbd0400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88804dbd0480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88804dbd0500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88804dbd0580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== ---------------- Code disassembly (best guess), 1 bytes skipped: 0: e8 12 52 23 f6 call 0xf6235217 5: 41 80 fc 04 cmp $0x4,%r12b 9: 0f 84 f3 05 00 00 je 0x602 f: 0f 87 3e 01 00 00 ja 0x153 15: 41 80 fc 02 cmp $0x2,%r12b 19: 0f 84 02 09 00 00 je 0x921 1f: 41 80 fc 03 cmp $0x3,%r12b 23: 0f 84 d7 07 00 00 je 0x800 * 29: 45 84 e4 test %r12b,%r12b <-- trapping instruction 2c: 0f 84 2e 05 00 00 je 0x560 32: e8 10 57 23 f6 call 0xf6235747 37: 48 8b 54 24 38 mov 0x38(%rsp),%rdx 3c: 48 rex.W 3d: b8 .byte 0xb8