================================================================== BUG: KASAN: use-after-free in string_nocheck lib/vsprintf.c:643 [inline] BUG: KASAN: use-after-free in string+0x218/0x2b0 lib/vsprintf.c:725 Read of size 1 at addr ffff888087a8ad00 by task udevd/9465 CPU: 0 PID: 9465 Comm: udevd Not tainted 6.1.20-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106 print_address_description mm/kasan/report.c:284 [inline] print_report+0x15f/0x4f0 mm/kasan/report.c:395 kasan_report+0x136/0x160 mm/kasan/report.c:495 string_nocheck lib/vsprintf.c:643 [inline] string+0x218/0x2b0 lib/vsprintf.c:725 vsnprintf+0x11fc/0x1c70 lib/vsprintf.c:2800 add_uevent_var+0x1c0/0x440 lib/kobject_uevent.c:665 dev_uevent+0x3e8/0x8e0 drivers/base/core.c:2568 uevent_show+0x196/0x300 drivers/base/core.c:2639 dev_attr_show+0x50/0xb0 drivers/base/core.c:2342 sysfs_kf_seq_show+0x32d/0x4b0 fs/sysfs/file.c:59 seq_read_iter+0x43a/0xd10 fs/seq_file.c:230 call_read_iter include/linux/fs.h:2199 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x7de/0xbe0 fs/read_write.c:470 ksys_read+0x19c/0x2c0 fs/read_write.c:613 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f4e433258fe 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:00007fff0f498c18 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 000055c326c535d0 RCX: 00007f4e433258fe RDX: 0000000000001000 RSI: 000055c326c2e9f0 RDI: 0000000000000008 RBP: 00007f4e433f2380 R08: 0000000000000008 R09: 00007f4e433f5a60 R10: 0000000000000008 R11: 0000000000000246 R12: 000055c326c535d0 R13: 0000000000000d68 R14: 00007f4e433f1780 R15: 0000000000000d68 Allocated by task 10844: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:374 [inline] __kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:553 [inline] raw_ioctl_init drivers/usb/gadget/legacy/raw_gadget.c:460 [inline] raw_ioctl+0x1ab1/0x3bf0 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+0xf1/0x160 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 10843: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:52 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:516 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236 kasan_slab_free include/linux/kasan.h:177 [inline] slab_free_hook mm/slub.c:1724 [inline] slab_free_freelist_hook mm/slub.c:1750 [inline] slab_free mm/slub.c:3661 [inline] __kmem_cache_free+0x25c/0x3c0 mm/slub.c:3674 dev_free drivers/usb/gadget/legacy/raw_gadget.c:210 [inline] kref_put+0xb5/0x7c0 include/linux/kref.h:65 raw_release+0x134/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:424 __fput+0x3b7/0x890 fs/file_table.c:320 task_work_run+0x246/0x300 kernel/task_work.c:179 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop+0xd9/0x100 kernel/entry/common.c:171 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x60/0x2d0 kernel/entry/common.c:296 do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff888087a8ad00 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of 32-byte region [ffff888087a8ad00, ffff888087a8ad20) The buggy address belongs to the physical page: page:ffffea00021ea280 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x87a8a flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffffea0001d126c0 dead000000000003 ffff888012441500 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 0x112a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL), pid 0, tgid 0 (swapper/0), ts 664965700496, free_ts 612761253176 prep_new_page mm/page_alloc.c:2539 [inline] get_page_from_freelist+0x3573/0x3700 mm/page_alloc.c:4291 __alloc_pages+0x28d/0x7e0 mm/page_alloc.c:5558 alloc_slab_page+0x6a/0x150 mm/slub.c:1794 allocate_slab mm/slub.c:1939 [inline] new_slab+0x84/0x2d0 mm/slub.c:1992 ___slab_alloc+0xa71/0x1080 mm/slub.c:3180 __slab_alloc mm/slub.c:3279 [inline] slab_alloc_node mm/slub.c:3364 [inline] __kmem_cache_alloc_node+0x19f/0x260 mm/slub.c:3437 kmalloc_trace+0x26/0x60 mm/slab_common.c:1045 kmalloc include/linux/slab.h:553 [inline] kzalloc include/linux/slab.h:689 [inline] ref_tracker_alloc+0x13c/0x470 lib/ref_tracker.c:85 __netdev_tracker_alloc include/linux/netdevice.h:4002 [inline] netdev_hold include/linux/netdevice.h:4031 [inline] dst_init+0xee/0x440 net/core/dst.c:52 dst_alloc+0x1a2/0x1f0 net/core/dst.c:96 ip6_dst_alloc net/ipv6/route.c:344 [inline] icmp6_dst_alloc+0x7b/0x470 net/ipv6/route.c:3261 ndisc_send_skb+0x30b/0x1380 net/ipv6/ndisc.c:488 addrconf_rs_timer+0x357/0x610 net/ipv6/addrconf.c:3936 call_timer_fn+0x200/0x840 kernel/time/timer.c:1474 expire_timers kernel/time/timer.c:1519 [inline] __run_timers+0x67c/0x890 kernel/time/timer.c:1790 run_timer_softirq+0x63/0xf0 kernel/time/timer.c:1803 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1459 [inline] free_pcp_prepare mm/page_alloc.c:1509 [inline] free_unref_page_prepare+0xfe1/0x1190 mm/page_alloc.c:3387 free_unref_page+0x98/0x570 mm/page_alloc.c:3483 free_slab mm/slub.c:2031 [inline] discard_slab mm/slub.c:2037 [inline] __unfreeze_partials+0x1b7/0x210 mm/slub.c:2586 put_cpu_partial+0x116/0x180 mm/slub.c:2662 qlist_free_all+0x22/0x60 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0x1f/0x70 mm/kasan/common.c:305 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook+0x50/0x370 mm/slab.h:737 slab_alloc_node mm/slub.c:3398 [inline] slab_alloc mm/slub.c:3406 [inline] __kmem_cache_alloc_lru mm/slub.c:3413 [inline] kmem_cache_alloc+0x119/0x260 mm/slub.c:3422 anon_vma_chain_alloc mm/rmap.c:141 [inline] anon_vma_fork+0x1f6/0x580 mm/rmap.c:363 dup_mmap kernel/fork.c:660 [inline] dup_mm+0x9f8/0x1410 kernel/fork.c:1529 copy_mm+0xca/0x160 kernel/fork.c:1578 copy_process+0x19a2/0x4020 kernel/fork.c:2256 kernel_clone+0x222/0x9f0 kernel/fork.c:2676 __do_sys_clone kernel/fork.c:2817 [inline] __se_sys_clone kernel/fork.c:2801 [inline] __x64_sys_clone+0x231/0x280 kernel/fork.c:2801 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 Memory state around the buggy address: ffff888087a8ac00: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc ffff888087a8ac80: fa fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc >ffff888087a8ad00: fa fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc ^ ffff888087a8ad80: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ffff888087a8ae00: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ==================================================================