UDC core: USB Raw Gadget: driver registration failed: -16 misc raw-gadget: fail, usb_gadget_register_driver returned -16 Error: Driver 'raw-gadget' is already registered, aborting... UDC core: USB Raw Gadget: driver registration failed: -16 misc raw-gadget: fail, usb_gadget_register_driver returned -16 ================================================================== BUG: KASAN: use-after-free in driver_find drivers/base/driver.c:293 [inline] BUG: KASAN: use-after-free in driver_register+0x352/0x3a0 drivers/base/driver.c:233 Read of size 8 at addr ffff888078f508c8 by task syz-executor.3/17773 CPU: 1 PID: 17773 Comm: syz-executor.3 Not tainted 5.19.0-rc1-next-20220610-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description.constprop.0.cold+0xeb/0x495 mm/kasan/report.c:313 print_report mm/kasan/report.c:429 [inline] kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491 driver_find drivers/base/driver.c:293 [inline] driver_register+0x352/0x3a0 drivers/base/driver.c:233 usb_gadget_register_driver_owner+0xfb/0x1e0 drivers/usb/gadget/udc/core.c:1558 raw_ioctl_run drivers/usb/gadget/legacy/raw_gadget.c:515 [inline] raw_ioctl+0x188d/0x2730 drivers/usb/gadget/legacy/raw_gadget.c:1222 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 RIP: 0033:0x7f8713688ec7 Code: 3c 1c 48 f7 d8 49 39 c4 72 b8 e8 34 54 02 00 85 c0 78 bd 48 83 c4 08 4c 89 e0 5b 41 5c c3 0f 1f 44 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f87148c3098 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f87148c4110 RCX: 00007f8713688ec7 RDX: 0000000000000000 RSI: 0000000000005501 RDI: 0000000000000005 RBP: 0000000000000005 R08: 000000000000ffff R09: 000000000000000b R10: 00007f87148c3140 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000020000600 R14: 00000000200008c0 R15: 00000000000010d0 Allocated by task 17748: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:45 [inline] set_alloc_info mm/kasan/common.c:436 [inline] ____kasan_kmalloc mm/kasan/common.c:515 [inline] ____kasan_kmalloc mm/kasan/common.c:474 [inline] __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:524 kmalloc include/linux/slab.h:600 [inline] kzalloc include/linux/slab.h:733 [inline] bus_add_driver+0xd4/0x640 drivers/base/bus.c:602 driver_register+0x220/0x3a0 drivers/base/driver.c:240 usb_gadget_register_driver_owner+0xfb/0x1e0 drivers/usb/gadget/udc/core.c:1558 raw_ioctl_run drivers/usb/gadget/legacy/raw_gadget.c:515 [inline] raw_ioctl+0x188d/0x2730 drivers/usb/gadget/legacy/raw_gadget.c:1222 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 Freed by task 17773: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track+0x21/0x30 mm/kasan/common.c:45 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370 ____kasan_slab_free mm/kasan/common.c:366 [inline] ____kasan_slab_free+0x166/0x1a0 mm/kasan/common.c:328 kasan_slab_free include/linux/kasan.h:200 [inline] slab_free_hook mm/slub.c:1727 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1753 slab_free mm/slub.c:3507 [inline] kfree+0xd6/0x4d0 mm/slub.c:4555 kobject_cleanup lib/kobject.c:673 [inline] kobject_release lib/kobject.c:704 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x1c8/0x540 lib/kobject.c:721 driver_find drivers/base/driver.c:291 [inline] driver_register+0x1e3/0x3a0 drivers/base/driver.c:233 usb_gadget_register_driver_owner+0xfb/0x1e0 drivers/usb/gadget/udc/core.c:1558 raw_ioctl_run drivers/usb/gadget/legacy/raw_gadget.c:515 [inline] raw_ioctl+0x188d/0x2730 drivers/usb/gadget/legacy/raw_gadget.c:1222 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 Last potentially related work creation: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348 kvfree_call_rcu+0x74/0x940 kernel/rcu/tree.c:3739 subflow_ulp_release+0x225/0x2b0 net/mptcp/subflow.c:1770 tcp_cleanup_ulp+0x78/0x130 net/ipv4/tcp_ulp.c:124 tcp_v4_destroy_sock+0xea/0x760 net/ipv4/tcp_ipv4.c:2228 tcp_v6_destroy_sock+0x11/0x20 net/ipv6/tcp_ipv6.c:1944 inet_csk_destroy_sock+0x196/0x440 net/ipv4/inet_connection_sock.c:1130 __tcp_close+0xd5b/0x12b0 net/ipv4/tcp.c:2897 __mptcp_close_ssk+0x332/0x700 net/mptcp/protocol.c:2349 __mptcp_destroy_sock+0x2d7/0x6b0 net/mptcp/protocol.c:2808 mptcp_close+0x5f8/0x7f0 net/mptcp/protocol.c:2858 inet_release+0x12e/0x280 net/ipv4/af_inet.c:428 inet6_release+0x4c/0x70 net/ipv6/af_inet6.c:481 __sock_release+0xcd/0x280 net/socket.c:650 sock_close+0x18/0x20 net/socket.c:1365 __fput+0x277/0x9d0 fs/file_table.c:317 task_work_run+0xdd/0x1a0 kernel/task_work.c:177 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xb05/0x2a00 kernel/exit.c:795 do_group_exit+0xd2/0x2f0 kernel/exit.c:925 get_signal+0x2542/0x2600 kernel/signal.c:2857 arch_do_signal_or_restart+0x82/0x2300 arch/x86/kernel/signal.c:869 exit_to_user_mode_loop kernel/entry/common.c:166 [inline] exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:201 __syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline] syscall_exit_to_user_mode+0x19/0x50 kernel/entry/common.c:294 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x46/0xb0 Second to last potentially related work creation: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348 kvfree_call_rcu+0x74/0x940 kernel/rcu/tree.c:3739 drop_sysctl_table+0x3c0/0x4e0 fs/proc/proc_sysctl.c:1716 unregister_sysctl_table fs/proc/proc_sysctl.c:1754 [inline] unregister_sysctl_table+0xc0/0x190 fs/proc/proc_sysctl.c:1729 __devinet_sysctl_unregister net/ipv4/devinet.c:2609 [inline] devinet_exit_net+0x186/0x280 net/ipv4/devinet.c:2750 ops_exit_list+0xb0/0x170 net/core/net_namespace.c:162 cleanup_net+0x4ea/0xb00 net/core/net_namespace.c:594 process_one_work+0x996/0x1610 kernel/workqueue.c:2289 worker_thread+0x665/0x1080 kernel/workqueue.c:2436 kthread+0x2e9/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:302 The buggy address belongs to the object at ffff888078f50800 which belongs to the cache kmalloc-256 of size 256 The buggy address is located 200 bytes inside of 256-byte region [ffff888078f50800, ffff888078f50900) The buggy address belongs to the physical page: page:ffffea0001e3d400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x78f50 head:ffffea0001e3d400 order:1 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888011841b40 raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 1, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 32471, tgid 32471 (kworker/0:5), ts 1997625210407, free_ts 1997022697316 prep_new_page mm/page_alloc.c:2460 [inline] get_page_from_freelist+0xa64/0x3d10 mm/page_alloc.c:4279 __alloc_pages+0x1c7/0x510 mm/page_alloc.c:5500 alloc_pages+0x1aa/0x310 mm/mempolicy.c:2279 alloc_slab_page mm/slub.c:1797 [inline] allocate_slab+0x26c/0x3c0 mm/slub.c:1942 new_slab mm/slub.c:2002 [inline] ___slab_alloc+0x985/0xd90 mm/slub.c:3002 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3089 slab_alloc_node mm/slub.c:3180 [inline] slab_alloc mm/slub.c:3222 [inline] __kmalloc+0x318/0x350 mm/slub.c:4413 kmalloc include/linux/slab.h:605 [inline] kzalloc include/linux/slab.h:733 [inline] hid_register_field drivers/hid/hid-core.c:103 [inline] hid_add_field+0x47d/0x12d0 drivers/hid/hid-core.c:306 hid_parser_main+0x59a/0xaf0 drivers/hid/hid-core.c:624 hid_open_report+0x37f/0x650 drivers/hid/hid-core.c:1265 hid_parse include/linux/hid.h:1100 [inline] kye_probe+0x1d/0x4c0 drivers/hid/hid-kye.c:707 hid_device_probe+0x2bd/0x3f0 drivers/hid/hid-core.c:2598 call_driver_probe drivers/base/dd.c:555 [inline] really_probe+0x23e/0xb90 drivers/base/dd.c:634 __driver_probe_device+0x338/0x4d0 drivers/base/dd.c:764 driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:794 __device_attach_driver+0x20b/0x2f0 drivers/base/dd.c:917 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1375 [inline] free_pcp_prepare+0x549/0xd20 mm/page_alloc.c:1425 free_unref_page_prepare mm/page_alloc.c:3311 [inline] free_unref_page+0x19/0x7b0 mm/page_alloc.c:3426 __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2521 qlink_free mm/kasan/quarantine.c:168 [inline] qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0xa2/0xc0 mm/kasan/common.c:446 kasan_slab_alloc include/linux/kasan.h:224 [inline] slab_post_alloc_hook mm/slab.h:750 [inline] slab_alloc_node mm/slub.c:3214 [inline] slab_alloc mm/slub.c:3222 [inline] __kmalloc+0x200/0x350 mm/slub.c:4413 kmalloc include/linux/slab.h:605 [inline] tomoyo_realpath_from_path+0xc3/0x620 security/tomoyo/realpath.c:254 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_perm+0x21b/0x400 security/tomoyo/file.c:822 security_inode_getattr+0xcf/0x140 security/security.c:1344 vfs_getattr fs/stat.c:157 [inline] vfs_statx+0x16a/0x390 fs/stat.c:232 vfs_fstatat+0x8c/0xb0 fs/stat.c:255 __do_sys_newfstatat+0x91/0x110 fs/stat.c:425 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 Memory state around the buggy address: ffff888078f50780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888078f50800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888078f50880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888078f50900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888078f50980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================