gadgetfs: bound to dummy_udc driver ================================================================== BUG: KASAN: use-after-free in __mutex_lock_common kernel/locking/mutex.c:582 [inline] BUG: KASAN: use-after-free in __mutex_lock+0xf4/0xae0 kernel/locking/mutex.c:747 Read of size 8 at addr ffff888054be3460 by task syz.4.975/8502 CPU: 1 PID: 8502 Comm: syz.4.975 Not tainted syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026 Call Trace: dump_stack_lvl+0x188/0x24e lib/dump_stack.c:106 print_address_description mm/kasan/report.c:316 [inline] print_report+0xa8/0x210 mm/kasan/report.c:420 kasan_report+0x10b/0x140 mm/kasan/report.c:524 __mutex_lock_common kernel/locking/mutex.c:582 [inline] __mutex_lock+0xf4/0xae0 kernel/locking/mutex.c:747 ep_open+0x4a/0x260 drivers/usb/gadget/legacy/inode.c:819 do_dentry_open+0x7dd/0x10b0 fs/open.c:882 do_open fs/namei.c:3634 [inline] path_openat+0x2674/0x2f10 fs/namei.c:3791 do_filp_open+0x1ee/0x420 fs/namei.c:3818 do_sys_openat2+0x14b/0x4f0 fs/open.c:1320 do_sys_open fs/open.c:1336 [inline] __do_sys_openat fs/open.c:1352 [inline] __se_sys_openat fs/open.c:1347 [inline] __x64_sys_openat+0x135/0x160 fs/open.c:1347 do_syscall_x64 arch/x86/entry/common.c:46 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:76 entry_SYSCALL_64_after_hwframe+0x68/0xd2 RIP: 0033:0x7f4c2e19e0d9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f4c2f0e3028 EFLAGS: 00000246 ORIG_RAX: 0000000000000101 RAX: ffffffffffffffda RBX: 00007f4c2e426270 RCX: 00007f4c2e19e0d9 RDX: 0000000000000002 RSI: 0000200000000600 RDI: ffffffffffffff9c RBP: 00007f4c2e235024 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f4c2e426308 R14: 00007f4c2e426270 R15: 00007ffd1b6d6828 Allocated by task 8502: kasan_save_stack mm/kasan/common.c:46 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:53 ____kasan_kmalloc mm/kasan/common.c:375 [inline] __kasan_kmalloc+0x8e/0xa0 mm/kasan/common.c:384 kmalloc include/linux/slab.h:563 [inline] kzalloc include/linux/slab.h:699 [inline] activate_ep_files drivers/usb/gadget/legacy/inode.c:1596 [inline] gadgetfs_bind+0x25b/0x820 drivers/usb/gadget/legacy/inode.c:1687 gadget_bind_driver+0x2af/0x760 drivers/usb/gadget/udc/core.c:1651 call_driver_probe drivers/base/dd.c:-1 [inline] really_probe+0x24a/0xb40 drivers/base/dd.c:638 __driver_probe_device+0x1f5/0x390 drivers/base/dd.c:804 driver_probe_device+0x4f/0x420 drivers/base/dd.c:834 __driver_attach+0x43d/0x6c0 drivers/base/dd.c:1220 bus_for_each_dev+0x182/0x1f0 drivers/base/bus.c:303 bus_add_driver+0x324/0x5d0 drivers/base/bus.c:620 driver_register+0x32d/0x430 drivers/base/driver.c:246 usb_gadget_register_driver_owner+0xf5/0x260 drivers/usb/gadget/udc/core.c:1730 dev_config+0xe45/0x1260 drivers/usb/gadget/legacy/inode.c:1878 vfs_write+0x2dc/0x9a0 fs/read_write.c:582 ksys_write+0x14d/0x260 fs/read_write.c:637 do_syscall_x64 arch/x86/entry/common.c:46 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:76 entry_SYSCALL_64_after_hwframe+0x68/0xd2 Freed by task 8498: kasan_save_stack mm/kasan/common.c:46 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:53 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:516 ____kasan_slab_free+0x126/0x1f0 mm/kasan/common.c:237 kasan_slab_free include/linux/kasan.h:177 [inline] slab_free_hook mm/slub.c:1729 [inline] slab_free_freelist_hook+0x133/0x1b0 mm/slub.c:1755 slab_free mm/slub.c:3687 [inline] __kmem_cache_free+0xb6/0x200 mm/slub.c:3700 destroy_ep_files+0x280/0x340 drivers/usb/gadget/legacy/inode.c:1571 gadgetfs_unbind+0x105/0x2a0 drivers/usb/gadget/legacy/inode.c:1650 gadget_unbind_driver+0x1bb/0x3d0 drivers/usb/gadget/udc/core.c:1702 device_remove drivers/base/dd.c:547 [inline] __device_release_driver drivers/base/dd.c:1279 [inline] device_release_driver_internal+0x47d/0x7c0 drivers/base/dd.c:1305 driver_detach+0x1ef/0x2d0 drivers/base/dd.c:1368 bus_remove_driver+0x11c/0x230 drivers/base/bus.c:679 usb_gadget_unregister_driver+0x4a/0x70 drivers/usb/gadget/udc/core.c:1762 dev_release+0x82/0x1f0 drivers/usb/gadget/legacy/inode.c:1194 __fput+0x20a/0x8b0 fs/file_table.c:320 task_work_run+0x1d0/0x260 kernel/task_work.c:203 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop+0xe6/0x110 kernel/entry/common.c:177 exit_to_user_mode_prepare+0xee/0x180 kernel/entry/common.c:210 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline] syscall_exit_to_user_mode+0x16/0x40 kernel/entry/common.c:303 do_syscall_64+0x58/0xa0 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x68/0xd2 The buggy address belongs to the object at ffff888054be3400 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 96 bytes inside of 512-byte region [ffff888054be3400, ffff888054be3600) The buggy address belongs to the physical page: page:ffffea000152f800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x54be0 head:ffffea000152f800 order:2 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888017441c80 raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd28c0(GFP_NOWAIT|__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 4272, tgid 4272 (syz-executor), ts 74711631843, free_ts 23278782755 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x173/0x1a0 mm/page_alloc.c:2560 prep_new_page mm/page_alloc.c:2567 [inline] get_page_from_freelist+0x206b/0x2180 mm/page_alloc.c:4358 __alloc_pages+0x1ec/0x4f0 mm/page_alloc.c:5658 alloc_slab_page+0x5d/0x180 mm/slub.c:1799 allocate_slab mm/slub.c:1944 [inline] new_slab+0x87/0x2d0 mm/slub.c:1997 ___slab_alloc+0xbc5/0x1240 mm/slub.c:3154 __slab_alloc mm/slub.c:3240 [inline] slab_alloc_node mm/slub.c:3325 [inline] __kmem_cache_alloc_node+0x126/0x270 mm/slub.c:3398 __do_kmalloc_node mm/slab_common.c:935 [inline] __kmalloc_node_track_caller+0xa0/0x240 mm/slab_common.c:956 kmalloc_reserve net/core/skbuff.c:446 [inline] pskb_expand_head+0x1c0/0x13a0 net/core/skbuff.c:1849 netlink_trim+0x180/0x220 net/netlink/af_netlink.c:1299 netlink_broadcast+0x66/0x10f0 net/netlink/af_netlink.c:1505 nlmsg_multicast include/net/netlink.h:1078 [inline] nlmsg_notify+0xe3/0x1a0 net/netlink/af_netlink.c:2559 fib_table_insert+0xd4e/0x1af0 net/ipv4/fib_trie.c:1385 fib_magic+0x2ca/0x3b0 net/ipv4/fib_frontend.c:1118 fib_add_ifaddr+0x135/0x5c0 net/ipv4/fib_frontend.c:1140 fib_inetaddr_event+0x13c/0x1c0 net/ipv4/fib_frontend.c:1454 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1487 [inline] free_pcp_prepare mm/page_alloc.c:1537 [inline] free_unref_page_prepare+0x8e5/0x9e0 mm/page_alloc.c:3414 free_unref_page+0x2e/0x3f0 mm/page_alloc.c:3509 free_contig_range+0x9d/0x150 mm/page_alloc.c:9626 destroy_args+0xef/0xa0e mm/debug_vm_pgtable.c:1031 debug_vm_pgtable+0x33c/0x38e mm/debug_vm_pgtable.c:1359 do_one_initcall+0x257/0x800 init/main.c:1309 do_initcall_level+0x13d/0x1ed init/main.c:1382 do_initcalls+0x4b/0x8a init/main.c:1398 kernel_init_freeable+0x401/0x5ab init/main.c:1637 kernel_init+0x19/0x1b0 init/main.c:1525 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 Memory state around the buggy address: ffff888054be3300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888054be3380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff888054be3400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888054be3480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888054be3500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================