================================================================== BUG: KASAN: use-after-free in usb_udc_uevent+0xb1/0x130 drivers/usb/gadget/udc/core.c:1749 Read of size 8 at addr ffff88807895e050 by task systemd-udevd/30448 CPU: 0 PID: 30448 Comm: systemd-udevd Not tainted 5.16.0-rc3-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+0x1dc/0x2d8 lib/dump_stack.c:106 print_address_description+0x65/0x380 mm/kasan/report.c:247 __kasan_report mm/kasan/report.c:433 [inline] kasan_report+0x19a/0x1f0 mm/kasan/report.c:450 usb_udc_uevent+0xb1/0x130 drivers/usb/gadget/udc/core.c:1749 dev_uevent+0x4d8/0x8d0 drivers/base/core.c:2337 uevent_show+0x1ae/0x320 drivers/base/core.c:2393 dev_attr_show+0x50/0xc0 drivers/base/core.c:2095 sysfs_kf_seq_show+0x32a/0x4e0 fs/sysfs/file.c:59 seq_read_iter+0x47e/0xdc0 fs/seq_file.c:230 call_read_iter include/linux/fs.h:2156 [inline] new_sync_read fs/read_write.c:400 [inline] vfs_read+0xaf9/0xe60 fs/read_write.c:481 ksys_read+0x18f/0x2c0 fs/read_write.c:619 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7fea34ebe910 Code: b6 fe ff ff 48 8d 3d 0f be 08 00 48 83 ec 08 e8 06 db 01 00 66 0f 1f 44 00 00 83 3d f9 2d 2c 00 00 75 10 b8 00 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 de 9b 01 00 48 89 04 24 RSP: 002b:00007fff75f0e318 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 0000555e437a1260 RCX: 00007fea34ebe910 RDX: 0000000000001000 RSI: 0000555e437ae270 RDI: 0000000000000007 RBP: 00007fea35179440 R08: 00007fea3517d228 R09: 0000000000001010 R10: 0000555e437a1260 R11: 0000000000000246 R12: 0000000000001000 R13: 0000000000000d68 R14: 0000555e437ae270 R15: 00007fea35178900 Allocated by task 30322: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track mm/kasan/common.c:46 [inline] set_alloc_info mm/kasan/common.c:434 [inline] ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:513 kasan_kmalloc include/linux/kasan.h:269 [inline] kmem_cache_alloc_trace+0x9d/0x330 mm/slub.c:3261 kmalloc include/linux/slab.h:590 [inline] kzalloc include/linux/slab.h:724 [inline] dev_new drivers/usb/gadget/legacy/raw_gadget.c:183 [inline] raw_open+0x87/0x480 drivers/usb/gadget/legacy/raw_gadget.c:373 misc_open+0x346/0x3c0 drivers/char/misc.c:141 chrdev_open+0x5fb/0x680 fs/char_dev.c:414 do_dentry_open+0x78b/0x1020 fs/open.c:822 do_open fs/namei.c:3426 [inline] path_openat+0x2896/0x3660 fs/namei.c:3559 do_filp_open+0x277/0x4f0 fs/namei.c:3586 do_sys_openat2+0x13b/0x500 fs/open.c:1212 do_sys_open fs/open.c:1228 [inline] __do_sys_openat fs/open.c:1244 [inline] __se_sys_openat fs/open.c:1239 [inline] __x64_sys_openat+0x243/0x290 fs/open.c:1239 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae Freed by task 30389: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track+0x4c/0x80 mm/kasan/common.c:46 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:370 ____kasan_slab_free+0x10d/0x150 mm/kasan/common.c:366 kasan_slab_free include/linux/kasan.h:235 [inline] slab_free_hook mm/slub.c:1723 [inline] slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1749 slab_free mm/slub.c:3513 [inline] kfree+0xe1/0x330 mm/slub.c:4561 raw_release+0x130/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:412 __fput+0x3fc/0x870 fs/file_table.c:280 task_work_run+0x146/0x1c0 kernel/task_work.c:164 exit_task_work include/linux/task_work.h:32 [inline] do_exit+0x705/0x24f0 kernel/exit.c:832 do_group_exit+0x168/0x2d0 kernel/exit.c:929 get_signal+0x1740/0x2120 kernel/signal.c:2852 arch_do_signal_or_restart+0x9c/0x730 arch/x86/kernel/signal.c:868 handle_signal_work kernel/entry/common.c:148 [inline] exit_to_user_mode_loop kernel/entry/common.c:172 [inline] exit_to_user_mode_prepare+0x191/0x220 kernel/entry/common.c:207 __syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline] syscall_exit_to_user_mode+0x2e/0x70 kernel/entry/common.c:300 do_syscall_64+0x53/0xd0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x44/0xae Last potentially related work creation: kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38 __kasan_record_aux_stack+0xfa/0x130 mm/kasan/generic.c:348 insert_work+0x54/0x400 kernel/workqueue.c:1354 __queue_work+0x928/0xc60 kernel/workqueue.c:1520 rcu_work_rcufn+0xf8/0x140 kernel/workqueue.c:1756 rcu_do_batch kernel/rcu/tree.c:2506 [inline] rcu_core+0x9b8/0x1610 kernel/rcu/tree.c:2741 __do_softirq+0x392/0x7a3 kernel/softirq.c:558 Second to last potentially related work creation: kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38 __kasan_record_aux_stack+0xfa/0x130 mm/kasan/generic.c:348 __call_rcu kernel/rcu/tree.c:2985 [inline] call_rcu+0x1c4/0xa70 kernel/rcu/tree.c:3065 queue_rcu_work+0x74/0x90 kernel/workqueue.c:1776 process_one_work+0x853/0x1140 kernel/workqueue.c:2298 worker_thread+0xac1/0x1320 kernel/workqueue.c:2445 kthread+0x468/0x490 kernel/kthread.c:327 ret_from_fork+0x1f/0x30 The buggy address belongs to the object at ffff88807895e000 which belongs to the cache kmalloc-4k of size 4096 The buggy address is located 80 bytes inside of 4096-byte region [ffff88807895e000, ffff88807895f000) The buggy address belongs to the page: page:ffffea0001e25600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x78958 head:ffffea0001e25600 order:3 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888011442140 raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, ts 36771862490, free_ts 36736944342 prep_new_page mm/page_alloc.c:2418 [inline] get_page_from_freelist+0x729/0x9e0 mm/page_alloc.c:4149 __alloc_pages+0x255/0x580 mm/page_alloc.c:5369 alloc_slab_page mm/slub.c:1793 [inline] allocate_slab+0xcc/0x4d0 mm/slub.c:1930 new_slab mm/slub.c:1993 [inline] ___slab_alloc+0x41e/0xc40 mm/slub.c:3022 __slab_alloc mm/slub.c:3109 [inline] slab_alloc_node mm/slub.c:3200 [inline] slab_alloc mm/slub.c:3242 [inline] __kmalloc+0x2eb/0x380 mm/slub.c:4419 kmalloc include/linux/slab.h:595 [inline] tomoyo_realpath_from_path+0xd8/0x610 security/tomoyo/realpath.c:254 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_perm+0x238/0x660 security/tomoyo/file.c:822 security_inode_getattr+0xc0/0x140 security/security.c:1334 vfs_getattr fs/stat.c:157 [inline] vfs_statx+0x168/0x3f0 fs/stat.c:225 vfs_fstatat fs/stat.c:243 [inline] __do_sys_newfstatat fs/stat.c:412 [inline] __se_sys_newfstatat+0xc8/0x760 fs/stat.c:406 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1338 [inline] free_pcp_prepare+0xd1c/0xe00 mm/page_alloc.c:1389 free_unref_page_prepare mm/page_alloc.c:3309 [inline] free_unref_page+0x7d/0x580 mm/page_alloc.c:3388 do_slab_free mm/slub.c:3501 [inline] ___cache_free+0xe6/0x120 mm/slub.c:3520 qlist_free_all mm/kasan/quarantine.c:165 [inline] kasan_quarantine_reduce+0x151/0x1c0 mm/kasan/quarantine.c:272 __kasan_slab_alloc+0x2f/0xf0 mm/kasan/common.c:444 kasan_slab_alloc include/linux/kasan.h:259 [inline] slab_post_alloc_hook mm/slab.h:519 [inline] slab_alloc_node mm/slub.c:3234 [inline] slab_alloc mm/slub.c:3242 [inline] __kmalloc+0x1ed/0x380 mm/slub.c:4419 kmalloc include/linux/slab.h:595 [inline] tomoyo_realpath_from_path+0xd8/0x610 security/tomoyo/realpath.c:254 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_perm+0x238/0x660 security/tomoyo/file.c:822 security_inode_getattr+0xc0/0x140 security/security.c:1334 vfs_getattr fs/stat.c:157 [inline] vfs_fstat fs/stat.c:182 [inline] __do_sys_newfstat fs/stat.c:422 [inline] __se_sys_newfstat+0xd1/0x820 fs/stat.c:419 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae Memory state around the buggy address: ffff88807895df00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88807895df80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88807895e000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88807895e080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88807895e100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================