================================================================== BUG: KASAN: use-after-free in string_nocheck lib/vsprintf.c:643 [inline] BUG: KASAN: use-after-free in string+0x39c/0x3d0 lib/vsprintf.c:725 Read of size 1 at addr ffff8880259330c3 by task udevd/20118 CPU: 1 PID: 20118 Comm: udevd Not tainted 6.1.0-rc3-next-20221104-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:253 [inline] print_report+0x15e/0x45d mm/kasan/report.c:364 kasan_report+0xbb/0x1f0 mm/kasan/report.c:464 string_nocheck lib/vsprintf.c:643 [inline] string+0x39c/0x3d0 lib/vsprintf.c:725 vsnprintf+0x71b/0x14f0 lib/vsprintf.c:2800 add_uevent_var+0x15d/0x380 lib/kobject_uevent.c:665 dev_uevent+0x18d/0x770 drivers/base/core.c:2421 uevent_show+0x1b8/0x380 drivers/base/core.c:2492 dev_attr_show+0x4b/0x90 drivers/base/core.c:2195 sysfs_kf_seq_show+0x219/0x3d0 fs/sysfs/file.c:59 seq_read_iter+0x4f5/0x1280 fs/seq_file.c:230 kernfs_fop_read_iter+0x542/0x7a0 fs/kernfs/file.c:275 call_read_iter include/linux/fs.h:2153 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x67d/0x930 fs/read_write.c:470 ksys_read+0x127/0x250 fs/read_write.c:613 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+0x63/0xcd RIP: 0033:0x7f20a23958fe Code: c0 e9 e6 fe ff ff 50 48 8d 3d 0e c7 09 00 e8 c9 cf 01 00 66 0f 1f 84 00 00 00 00 00 64 8b 04 25 18 00 00 00 85 c0 75 14 0f 05 <48> 3d 00 f0 ff ff 77 5a c3 66 0f 1f 84 00 00 00 00 00 48 83 ec 28 RSP: 002b:00007ffd6d000f58 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 000056170763d640 RCX: 00007f20a23958fe RDX: 0000000000001000 RSI: 00005617076458b0 RDI: 0000000000000008 RBP: 00007f20a2462380 R08: 0000000000000008 R09: 00007f20a2465a60 R10: 0000000000000010 R11: 0000000000000246 R12: 000056170763d640 R13: 0000000000000d68 R14: 00007f20a2461780 R15: 0000000000000d68 Allocated by task 21675: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:45 kasan_set_track+0x21/0x30 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:376 [inline] ____kasan_kmalloc mm/kasan/common.c:335 [inline] __kasan_kmalloc+0xa1/0xb0 mm/kasan/common.c:385 kmalloc include/linux/slab.h:587 [inline] raw_ioctl_init+0x152/0x820 drivers/usb/gadget/legacy/raw_gadget.c:460 raw_ioctl+0x8ef/0x27c0 drivers/usb/gadget/legacy/raw_gadget.c:1250 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+0x63/0xcd Freed by task 21675: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:45 kasan_set_track+0x21/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x2a/0x40 mm/kasan/generic.c:511 ____kasan_slab_free mm/kasan/common.c:241 [inline] ____kasan_slab_free+0x160/0x1c0 mm/kasan/common.c:205 kasan_slab_free include/linux/kasan.h:178 [inline] slab_free_hook mm/slub.c:1724 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1750 slab_free mm/slub.c:3653 [inline] __kmem_cache_free+0xab/0x3b0 mm/slub.c:3666 dev_free+0x9a/0x700 drivers/usb/gadget/legacy/raw_gadget.c:210 kref_put include/linux/kref.h:65 [inline] raw_release+0x219/0x290 drivers/usb/gadget/legacy/raw_gadget.c:424 __fput+0x27c/0xa90 fs/file_table.c:320 task_work_run+0x16b/0x270 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xaa0/0x28c0 kernel/exit.c:820 do_group_exit+0xd0/0x2a0 kernel/exit.c:950 get_signal+0x21a1/0x2430 kernel/signal.c:2858 arch_do_signal_or_restart+0x75/0x5b0 arch/x86/kernel/signal.c:306 exit_to_user_mode_loop kernel/entry/common.c:168 [inline] exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x19/0x50 kernel/entry/common.c:296 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff8880259330c0 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 3 bytes inside of 32-byte region [ffff8880259330c0, ffff8880259330e0) The buggy address belongs to the physical page: page:ffffea0000964cc0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x25933 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffff888011841500 ffffea0000785380 dead000000000002 raw: 0000000000000000 0000000000400040 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL), pid 5853, tgid 5844 (syz-executor.3), ts 174449462884, free_ts 174280082659 prep_new_page mm/page_alloc.c:2554 [inline] get_page_from_freelist+0x10b5/0x2d50 mm/page_alloc.c:4303 __alloc_pages+0x1c7/0x5a0 mm/page_alloc.c:5562 alloc_pages+0x1a6/0x270 mm/mempolicy.c:2285 alloc_slab_page mm/slub.c:1794 [inline] allocate_slab+0x207/0x2c0 mm/slub.c:1941 new_slab mm/slub.c:1994 [inline] ___slab_alloc+0xa91/0x1400 mm/slub.c:3172 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3271 slab_alloc_node mm/slub.c:3356 [inline] __kmem_cache_alloc_node+0x191/0x3e0 mm/slub.c:3429 kmalloc_trace+0x22/0x60 mm/slab_common.c:1046 kmalloc include/linux/slab.h:587 [inline] kzalloc include/linux/slab.h:723 [inline] ref_tracker_alloc+0x14c/0x550 lib/ref_tracker.c:85 __netdev_tracker_alloc include/linux/netdevice.h:3993 [inline] netdev_hold include/linux/netdevice.h:4022 [inline] dst_init+0xe0/0x520 net/core/dst.c:52 dst_alloc+0x16b/0x1f0 net/core/dst.c:96 rt_dst_alloc+0x51/0x430 net/ipv4/route.c:1633 __mkroute_output net/ipv4/route.c:2592 [inline] ip_route_output_key_hash_rcu+0x895/0x2bc0 net/ipv4/route.c:2814 ip_route_output_key_hash+0x18b/0x300 net/ipv4/route.c:2643 __ip_route_output_key include/net/route.h:140 [inline] ip_route_output_flow+0x23/0x150 net/ipv4/route.c:2873 udp_sendmsg+0x1963/0x2740 net/ipv4/udp.c:1224 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1461 [inline] free_pcp_prepare+0x65c/0xd90 mm/page_alloc.c:1511 free_unref_page_prepare mm/page_alloc.c:3402 [inline] free_unref_page_list+0x172/0xc40 mm/page_alloc.c:3544 release_pages+0x35b/0x12d0 mm/swap.c:1066 tlb_batch_pages_flush+0xa8/0x1a0 mm/mmu_gather.c:59 tlb_flush_mmu_free mm/mmu_gather.c:256 [inline] tlb_flush_mmu mm/mmu_gather.c:263 [inline] tlb_finish_mmu+0x147/0x7e0 mm/mmu_gather.c:363 exit_mmap+0x1fe/0x7a0 mm/mmap.c:3105 __mmput+0x128/0x4c0 kernel/fork.c:1202 mmput+0x5c/0x70 kernel/fork.c:1224 exit_mm kernel/exit.c:516 [inline] do_exit+0x9a4/0x28c0 kernel/exit.c:807 do_group_exit+0xd0/0x2a0 kernel/exit.c:950 __do_sys_exit_group kernel/exit.c:961 [inline] __se_sys_exit_group kernel/exit.c:959 [inline] __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:959 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+0x63/0xcd Memory state around the buggy address: ffff888025932f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888025933000: fa fb fb fb fc fc fc fc 00 00 02 fc fc fc fc fc >ffff888025933080: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc ^ ffff888025933100: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc ffff888025933180: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ==================================================================