==================================================================
BUG: KASAN: slab-use-after-free in find_endpoint+0x2a3/0x2c0 drivers/usb/gadget/udc/dummy_hcd.c:1618
Read of size 1 at addr ffff888060c5e8e8 by task syz.0.696/9068
CPU: 1 UID: 0 PID: 9068 Comm: syz.0.696 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:1618
dummy_timer+0x500/0x3700 drivers/usb/gadget/udc/dummy_hcd.c:1890
__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+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:__sanitizer_cov_trace_pc+0xc/0x70 kernel/kcov.c:209
Code: 00 be 03 00 00 00 5b e9 42 13 1e 03 66 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa 65 48 8b 05 2c 1f 81 12 <48> 8b 34 24 65 48 8b 15 10 1f 81 12 48 63 c8 a9 00 01 00 ff 74 1e
RSP: 0000:ffffc90006cd7818 EFLAGS: 00000246
RAX: 8000000000000000 RBX: ffff8880266ea000 RCX: ffffffff82d3d733
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff888021fa4b00
RBP: 0000000000000001 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000001 R12: ffff88801389a630
R13: ffffffff8c0f3f20 R14: 0000000000000000 R15: 0000000000001972
__ext4_journal_get_write_access+0x170/0x380 fs/ext4/ext4_jbd2.c:257
ext4_reserve_inode_write+0x1b7/0x330 fs/ext4/inode.c:6514
__ext4_mark_inode_dirty+0x18f/0x910 fs/ext4/inode.c:6699
ext4_dirty_inode+0xd9/0x130 fs/ext4/inode.c:6736
__mark_inode_dirty+0x1f3/0x16e0 fs/fs-writeback.c:2744
generic_update_time fs/inode.c:2252 [inline]
file_update_time_flags+0x49c/0x520 fs/inode.c:2482
ext4_page_mkwrite+0x324/0x1860 fs/ext4/inode.c:6902
do_page_mkwrite+0x17a/0x440 mm/memory.c:3816
do_shared_fault mm/memory.c:6076 [inline]
do_fault+0x659/0x1830 mm/memory.c:6138
do_pte_missing mm/memory.c:4700 [inline]
handle_pte_fault mm/memory.c:6558 [inline]
__handle_mm_fault+0x150b/0x2f60 mm/memory.c:6707
handle_mm_fault+0x363/0xa20 mm/memory.c:6876
do_user_addr_fault+0x59c/0x12f0 arch/x86/mm/fault.c:1343
handle_page_fault arch/x86/mm/fault.c:1483 [inline]
exc_page_fault+0x6f/0xd0 arch/x86/mm/fault.c:1536
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:595
RIP: 0023:0xf704f262
Code: 1c 01 00 00 ba 08 00 00 00 89 e8 e8 78 a2 fe ff 8b 45 20 8b 4c 24 08 8b 5c 24 0c 83 44 24 14 01 8d 50 f8 83 45 18 08 89 55 20 <89> 48 f8 89 58 fc 83 c6 01 3b 77 04 0f 82 9c fe ff ff 80 7d 34 00
RSP: 002b:00000000ffcdd8e0 EFLAGS: 00010202
RAX: 000000003371d000 RBX: 00000000ffffffff RCX: 00000000829b8bb2
RDX: 000000003371cff8 RSI: 00000000000001d0 RDI: 00000000f7404fe8
RBP: 00000000f7f35610 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
Allocated by task 7967:
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 8535:
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:6508 [inline]
kfree+0x22b/0x6d0 mm/slub.c:6801
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 ffff888060c5e800
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 232 bytes inside of
freed 512-byte region [ffff888060c5e800, ffff888060c5ea00)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff888060c5c800 pfn:0x60c5c
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 ffff88801c042c80 ffffea00015b1110 ffffea000147f810
raw: ffff888060c5c800 0000000000100009 00000000f5000000 0000000000000000
head: 04fff00000000240 ffff88801c042c80 ffffea00015b1110 ffffea000147f810
head: ffff888060c5c800 0000000000100009 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 5737, tgid 5737 (syz-executor), ts 49966657088
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:7417
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]
__do_kmalloc_node mm/slub.c:5413 [inline]
__kmalloc_noprof+0x67c/0x840 mm/slub.c:5439
_kmalloc_noprof include/linux/slab.h:995 [inline]
_kzalloc_noprof include/linux/slab.h:1312 [inline]
fib6_info_alloc+0x40/0x160 net/ipv6/ip6_fib.c:155
ip6_route_info_create+0x14c/0xad0 net/ipv6/route.c:3839
addrconf_f6i_alloc+0x2d9/0x670 net/ipv6/route.c:4723
ipv6_add_addr+0x580/0x1fb0 net/ipv6/addrconf.c:1132
inet6_addr_add+0x26f/0x9a0 net/ipv6/addrconf.c:3074
inet6_rtm_newaddr+0x147a/0x1bb0 net/ipv6/addrconf.c:5095
rtnetlink_rcv_msg+0x95e/0xe90 net/core/rtnetlink.c:7137
netlink_rcv_skb+0x159/0x420 net/netlink/af_netlink.c:2575
netlink_unicast_kernel net/netlink/af_netlink.c:1338 [inline]
netlink_unicast+0x585/0x850 net/netlink/af_netlink.c:1364
page last free pid 5738 tgid 5738 ts 48754678092 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_noprof+0x278/0x6d0 mm/slub.c:5559
_kmalloc_noprof include/linux/slab.h:991 [inline]
__netdev_adjacent_dev_insert+0x22b/0xbf0 net/core/dev.c:8816
__netdev_adjacent_dev_link_lists net/core/dev.c:8908 [inline]
__netdev_adjacent_dev_link_neighbour net/core/dev.c:8937 [inline]
__netdev_upper_dev_link+0x3d8/0x7e0 net/core/dev.c:8997
netdev_master_upper_dev_link+0x9f/0xd0 net/core/dev.c:9072
team_upper_dev_link drivers/net/team/team_core.c:1194 [inline]
team_port_add drivers/net/team/team_core.c:1332 [inline]
team_add_slave+0x9a6/0x1ea0 drivers/net/team/team_core.c:2113
do_set_master+0x40f/0x730 net/core/rtnetlink.c:3076
do_setlink.isra.0+0xb2b/0x3e60 net/core/rtnetlink.c:3278
rtnl_changelink net/core/rtnetlink.c:3910 [inline]
__rtnl_newlink net/core/rtnetlink.c:4081 [inline]
rtnl_newlink+0x13c1/0x2620 net/core/rtnetlink.c:4220
rtnetlink_rcv_msg+0x95e/0xe90 net/core/rtnetlink.c:7137
netlink_rcv_skb+0x159/0x420 net/netlink/af_netlink.c:2575
netlink_unicast_kernel net/netlink/af_netlink.c:1338 [inline]
netlink_unicast+0x585/0x850 net/netlink/af_netlink.c:1364
netlink_sendmsg+0x8b0/0xda0 net/netlink/af_netlink.c:1919
Memory state around the buggy address:
ffff888060c5e780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888060c5e800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888060c5e880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888060c5e900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888060c5e980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess):
0: 00 be 03 00 00 00 add %bh,0x3(%rsi)
6: 5b pop %rbx
7: e9 42 13 1e 03 jmp 0x31e134e
c: 66 90 xchg %ax,%ax
e: 90 nop
f: 90 nop
10: 90 nop
11: 90 nop
12: 90 nop
13: 90 nop
14: 90 nop
15: 90 nop
16: 90 nop
17: 90 nop
18: 90 nop
19: 90 nop
1a: 90 nop
1b: 90 nop
1c: 90 nop
1d: 90 nop
1e: f3 0f 1e fa endbr64
22: 65 48 8b 05 2c 1f 81 mov %gs:0x12811f2c(%rip),%rax # 0x12811f56
29: 12
* 2a: 48 8b 34 24 mov (%rsp),%rsi <-- trapping instruction
2e: 65 48 8b 15 10 1f 81 mov %gs:0x12811f10(%rip),%rdx # 0x12811f46
35: 12
36: 48 63 c8 movslq %eax,%rcx
39: a9 00 01 00 ff test $0xff000100,%eax
3e: 74 1e je 0x5e