================================================================== 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 ffff88804e4ccce8 by task kworker/0:4/5903 CPU: 0 UID: 0 PID: 5903 Comm: kworker/0:4 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:lock_acquire+0x5e/0x380 kernel/locking/lockdep.c:5947 Code: 05 cf c1 d2 13 83 f8 07 0f 87 da 00 00 00 48 0f a3 05 de 60 82 10 0f 82 c9 02 00 00 8b 35 be 90 82 10 85 f6 0f 85 c7 00 00 00 <48> 8b 44 24 30 65 48 2b 05 6d c1 d2 13 0f 85 09 03 00 00 48 83 c4 RSP: 0018:ffffc90004f4e7c0 EFLAGS: 00000206 RAX: 0000000000000046 RBX: 0000000000000000 RCX: 0000000000000100 RDX: 0000000000000000 RSI: ffffffff8e602a62 RDI: ffffffff8c836280 RBP: ffff88801eacf210 R08: 00000000000489c3 R09: 0000000000000090 R10: 0000000000000200 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000000 down_write+0x86/0x1f0 kernel/locking/rwsem.c:1631 kernfs_link_sibling+0x379/0x6f0 fs/kernfs/dir.c:413 kernfs_add_one+0x1e6/0xb40 fs/kernfs/dir.c:852 kernfs_create_dir_ns+0x155/0x2b0 fs/kernfs/dir.c:1143 sysfs_create_dir_ns+0x13a/0x2b0 fs/sysfs/dir.c:59 create_dir lib/kobject.c:73 [inline] kobject_add_internal+0x2c8/0x930 lib/kobject.c:240 kobject_add_varg lib/kobject.c:374 [inline] kobject_add+0x16a/0x1e0 lib/kobject.c:426 class_dir_create_and_add drivers/base/core.c:3306 [inline] get_device_parent+0x382/0x4c0 drivers/base/core.c:3357 device_add+0x1ad/0x1970 drivers/base/core.c:3687 device_create_groups_vargs+0x1f8/0x270 drivers/base/core.c:4460 device_create+0xed/0x130 drivers/base/core.c:4499 usb_register_dev+0x2f0/0x570 drivers/usb/core/file.c:150 yurex_probe+0xb03/0xfb0 drivers/usb/misc/yurex.c:286 usb_probe_interface+0x386/0x980 drivers/usb/core/driver.c:399 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_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 5190: kasan_save_stack+0x30/0x50 mm/kasan/common.c:57 kasan_save_track+0x14/0x40 mm/kasan/common.c:79 poison_kmalloc_redzone mm/kasan/common.c:412 [inline] __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:429 kasan_kmalloc include/linux/kasan.h:267 [inline] __do_kmalloc_node mm/slub.c:5531 [inline] __kmalloc_node_track_caller_noprof+0x33d/0x870 mm/slub.c:5662 kmalloc_reserve+0xe8/0x350 net/core/skbuff.c:638 __alloc_skb+0x185/0x710 net/core/skbuff.c:716 alloc_skb include/linux/skbuff.h:1391 [inline] alloc_skb_with_frags+0xdb/0x750 net/core/skbuff.c:6940 sock_alloc_send_pskb+0x86a/0x9e0 net/core/sock.c:3093 unix_dgram_sendmsg+0x3f4/0x1a80 net/unix/af_unix.c:2160 sock_sendmsg_nosec net/socket.c:800 [inline] __sock_sendmsg net/socket.c:818 [inline] __sys_sendto+0x492/0x4e0 net/socket.c:2283 __do_sys_sendto net/socket.c:2290 [inline] __se_sys_sendto net/socket.c:2286 [inline] __x64_sys_sendto+0xe0/0x1c0 net/socket.c:2286 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x123/0x780 arch/x86/entry/syscall_64.c:89 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 5183: kasan_save_stack+0x30/0x50 mm/kasan/common.c:57 kasan_save_track+0x14/0x40 mm/kasan/common.c:79 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:599 poison_slab_object mm/kasan/common.c:267 [inline] __kasan_slab_free+0x73/0x90 mm/kasan/common.c:299 kasan_slab_free include/linux/kasan.h:239 [inline] slab_free_hook mm/slub.c:2780 [inline] slab_free mm/slub.c:6637 [inline] kfree+0x22d/0x6d0 mm/slub.c:6930 skb_kfree_head net/core/skbuff.c:1085 [inline] skb_free_head+0xb9/0x160 net/core/skbuff.c:1097 skb_release_data+0x698/0x860 net/core/skbuff.c:1125 skb_release_all net/core/skbuff.c:1189 [inline] __kfree_skb net/core/skbuff.c:1203 [inline] consume_skb net/core/skbuff.c:1440 [inline] consume_skb+0xc4/0x110 net/core/skbuff.c:1434 __unix_dgram_recvmsg+0x814/0xd40 net/unix/af_unix.c:2688 unix_dgram_recvmsg+0xcd/0x100 net/unix/af_unix.c:2705 sock_recvmsg_nosec net/socket.c:1154 [inline] sock_recvmsg+0x1d5/0x220 net/socket.c:1176 sock_read_iter+0x2b0/0x3a0 net/socket.c:1245 new_sync_read fs/read_write.c:473 [inline] vfs_read+0x957/0xb30 fs/read_write.c:554 ksys_read+0x1f8/0x250 fs/read_write.c:696 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x123/0x780 arch/x86/entry/syscall_64.c:89 entry_SYSCALL_64_after_hwframe+0x77/0x7f The buggy address belongs to the object at ffff88804e4ccc00 which belongs to the cache kmalloc-cg-512 of size 512 The buggy address is located 232 bytes inside of freed 512-byte region [ffff88804e4ccc00, ffff88804e4cce00) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x4e4cc head: order:2 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 memcg:ffff88804e4cc211 flags: 0x4fff00000000040(head|node=1|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 04fff00000000040 ffff88801d449e00 dead000000000100 dead000000000122 raw: 0000000000000000 0000000300100010 00000000f5000000 ffff88804e4cc211 head: 04fff00000000040 ffff88801d449e00 dead000000000100 dead000000000122 head: 0000000000000000 0000000300100010 00000000f5000000 ffff88804e4cc211 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 5190, tgid 5190 (klogd), ts 106625928030 set_page_owner include/linux/page_owner.h:33 [inline] post_alloc_hook+0xfd/0x120 mm/page_alloc.c:1873 prep_new_page mm/page_alloc.c:1881 [inline] get_page_from_freelist+0xdae/0x2c80 mm/page_alloc.c:3963 __alloc_frozen_pages_noprof+0x2ad/0x31e0 mm/page_alloc.c:5505 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:7546 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] __do_kmalloc_node mm/slub.c:5530 [inline] __kmalloc_node_track_caller_noprof+0x6a3/0x870 mm/slub.c:5662 kmalloc_reserve+0xe8/0x350 net/core/skbuff.c:638 __alloc_skb+0x185/0x710 net/core/skbuff.c:716 alloc_skb include/linux/skbuff.h:1391 [inline] alloc_skb_with_frags+0xdb/0x750 net/core/skbuff.c:6940 sock_alloc_send_pskb+0x86a/0x9e0 net/core/sock.c:3093 unix_dgram_sendmsg+0x3f4/0x1a80 net/unix/af_unix.c:2160 sock_sendmsg_nosec net/socket.c:800 [inline] __sock_sendmsg net/socket.c:818 [inline] __sys_sendto+0x492/0x4e0 net/socket.c:2283 __do_sys_sendto net/socket.c:2290 [inline] __se_sys_sendto net/socket.c:2286 [inline] __x64_sys_sendto+0xe0/0x1c0 net/socket.c:2286 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x123/0x780 arch/x86/entry/syscall_64.c:89 entry_SYSCALL_64_after_hwframe+0x77/0x7f page last free pid 6378 tgid 6376 ts 106622104743 stack trace: reset_page_owner include/linux/page_owner.h:26 [inline] __free_pages_prepare mm/page_alloc.c:1415 [inline] __free_frozen_pages+0x7b1/0x10f0 mm/page_alloc.c:2971 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:364 kasan_slab_alloc include/linux/kasan.h:257 [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 taskstats_tgid_alloc kernel/taskstats.c:539 [inline] taskstats_exit+0x6dc/0xcb0 kernel/taskstats.c:578 do_exit+0x62d/0x2a00 kernel/exit.c:949 do_group_exit+0xd5/0x2a0 kernel/exit.c:1123 get_signal+0x1f58/0x22e0 kernel/signal.c:3113 arch_do_signal_or_restart+0x91/0x7a0 arch/x86/kernel/signal.c:337 __exit_to_user_mode_loop kernel/entry/common.c:66 [inline] exit_to_user_mode_loop+0x139/0x700 kernel/entry/common.c:101 __exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline] syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:230 [inline] syscall_exit_to_user_mode include/linux/entry-common.h:343 [inline] __do_fast_syscall_32+0x651/0x8e0 arch/x86/entry/syscall_32.c:289 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:311 entry_SYSENTER_compat_after_hwframe+0x84/0x8e Memory state around the buggy address: ffff88804e4ccb80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88804e4ccc00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88804e4ccc80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88804e4ccd00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88804e4ccd80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== ---------------- Code disassembly (best guess): 0: 05 cf c1 d2 13 add $0x13d2c1cf,%eax 5: 83 f8 07 cmp $0x7,%eax 8: 0f 87 da 00 00 00 ja 0xe8 e: 48 0f a3 05 de 60 82 bt %rax,0x108260de(%rip) # 0x108260f4 15: 10 16: 0f 82 c9 02 00 00 jb 0x2e5 1c: 8b 35 be 90 82 10 mov 0x108290be(%rip),%esi # 0x108290e0 22: 85 f6 test %esi,%esi 24: 0f 85 c7 00 00 00 jne 0xf1 * 2a: 48 8b 44 24 30 mov 0x30(%rsp),%rax <-- trapping instruction 2f: 65 48 2b 05 6d c1 d2 sub %gs:0x13d2c16d(%rip),%rax # 0x13d2c1a4 36: 13 37: 0f 85 09 03 00 00 jne 0x346 3d: 48 rex.W 3e: 83 .byte 0x83 3f: c4 .byte 0xc4