================================================================== BUG: KASAN: slab-use-after-free in string_nocheck lib/vsprintf.c:644 [inline] BUG: KASAN: slab-use-after-free in string+0x394/0x3d0 lib/vsprintf.c:726 Read of size 1 at addr ffff888077b0fd40 by task udevd/4480 CPU: 1 PID: 4480 Comm: udevd Not tainted 6.5.0-syzkaller-00453-g727dbda16b83 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:364 [inline] print_report+0xc4/0x620 mm/kasan/report.c:475 kasan_report+0xda/0x110 mm/kasan/report.c:588 string_nocheck lib/vsprintf.c:644 [inline] string+0x394/0x3d0 lib/vsprintf.c:726 vsnprintf+0xc5f/0x1870 lib/vsprintf.c:2817 add_uevent_var+0x17c/0x390 lib/kobject_uevent.c:665 dev_uevent+0x18b/0x760 drivers/base/core.c:2575 uevent_show+0x1bf/0x380 drivers/base/core.c:2646 dev_attr_show+0x4f/0xd0 drivers/base/core.c:2349 sysfs_kf_seq_show+0x23e/0x400 fs/sysfs/file.c:59 seq_read_iter+0x4e5/0x1280 fs/seq_file.c:230 kernfs_fop_read_iter+0x4c8/0x680 fs/kernfs/file.c:279 call_read_iter include/linux/fs.h:1979 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x4e0/0x930 fs/read_write.c:470 ksys_read+0x12f/0x250 fs/read_write.c:613 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f1c86d16b6a Code: 00 3d 00 00 41 00 75 0d 50 48 8d 3d 2d 08 0a 00 e8 ea 7d 01 00 31 c0 e9 07 ff ff ff 64 8b 04 25 18 00 00 00 85 c0 75 1b 0f 05 <48> 3d 00 f0 ff ff 76 6c 48 8b 15 8f a2 0d 00 f7 d8 64 89 02 48 83 RSP: 002b:00007ffd18adf868 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 00005599b7386c10 RCX: 00007f1c86d16b6a RDX: 0000000000001000 RSI: 00005599b7382820 RDI: 000000000000000c RBP: 00005599b7386c10 R08: 000000000000000c R09: 0000000000000008 R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000003fff R14: 00007ffd18adfd48 R15: 000000000000000a Allocated by task 19149: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:374 [inline] __kasan_kmalloc+0xa2/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:582 [inline] raw_ioctl_init+0x163/0x840 drivers/usb/gadget/legacy/raw_gadget.c:462 raw_ioctl+0x9d9/0x2b80 drivers/usb/gadget/legacy/raw_gadget.c:1252 __do_compat_sys_ioctl+0x2bf/0x330 fs/ioctl.c:972 do_syscall_32_irqs_on arch/x86/entry/common.c:112 [inline] __do_fast_syscall_32+0x61/0xe0 arch/x86/entry/common.c:178 do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:203 entry_SYSENTER_compat_after_hwframe+0x70/0x82 Freed by task 19156: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:522 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x15e/0x1b0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:162 [inline] slab_free_hook mm/slub.c:1792 [inline] slab_free_freelist_hook+0x10b/0x1e0 mm/slub.c:1818 slab_free mm/slub.c:3801 [inline] __kmem_cache_free+0xb8/0x2f0 mm/slub.c:3814 dev_free+0x9a/0x700 drivers/usb/gadget/legacy/raw_gadget.c:210 kref_put include/linux/kref.h:65 [inline] raw_release+0x184/0x2e0 drivers/usb/gadget/legacy/raw_gadget.c:426 __fput+0x3f7/0xa70 fs/file_table.c:384 task_work_run+0x14d/0x240 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xa99/0x2a20 kernel/exit.c:874 do_group_exit+0xd4/0x2a0 kernel/exit.c:1024 get_signal+0x23ea/0x2770 kernel/signal.c:2881 arch_do_signal_or_restart+0x89/0x5f0 arch/x86/kernel/signal.c:308 exit_to_user_mode_loop kernel/entry/common.c:168 [inline] exit_to_user_mode_prepare+0x11f/0x240 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline] syscall_exit_to_user_mode+0x1d/0x60 kernel/entry/common.c:297 __do_fast_syscall_32+0x6d/0xe0 arch/x86/entry/common.c:181 do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:203 entry_SYSENTER_compat_after_hwframe+0x70/0x82 The buggy address belongs to the object at ffff888077b0fd40 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of freed 32-byte region [ffff888077b0fd40, ffff888077b0fd60) The buggy address belongs to the physical page: page:ffffea0001dec3c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x77b0f flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000200 ffff888012841500 dead000000000100 dead000000000122 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 9297, tgid 9288 (syz-executor.1), ts 262128071063, free_ts 261970178836 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x2d2/0x350 mm/page_alloc.c:1570 prep_new_page mm/page_alloc.c:1577 [inline] get_page_from_freelist+0x10a9/0x31e0 mm/page_alloc.c:3221 __alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4477 alloc_pages+0x1a9/0x270 mm/mempolicy.c:2298 alloc_slab_page mm/slub.c:1862 [inline] allocate_slab+0x24e/0x380 mm/slub.c:2009 new_slab mm/slub.c:2062 [inline] ___slab_alloc+0x8bc/0x1570 mm/slub.c:3215 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3314 __slab_alloc_node mm/slub.c:3367 [inline] slab_alloc_node mm/slub.c:3460 [inline] __kmem_cache_alloc_node+0x137/0x350 mm/slub.c:3509 kmalloc_trace+0x25/0xe0 mm/slab_common.c:1076 kmalloc include/linux/slab.h:582 [inline] kzalloc include/linux/slab.h:703 [inline] ref_tracker_alloc+0x17c/0x5a0 lib/ref_tracker.c:203 __netdev_tracker_alloc include/linux/netdevice.h:4077 [inline] netdev_hold include/linux/netdevice.h:4106 [inline] dst_init+0xdf/0x580 net/core/dst.c:52 dst_alloc+0xc3/0x1b0 net/core/dst.c:93 rt_dst_alloc+0x3c/0x3a0 net/ipv4/route.c:1633 __mkroute_output net/ipv4/route.c:2590 [inline] ip_route_output_key_hash_rcu+0x870/0x2ad0 net/ipv4/route.c:2812 ip_route_output_key_hash+0x190/0x340 net/ipv4/route.c:2641 __ip_route_output_key include/net/route.h:134 [inline] ip_route_output_flow+0x27/0x150 net/ipv4/route.c:2869 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1161 [inline] free_unref_page_prepare+0x508/0xb90 mm/page_alloc.c:2348 free_unref_page_list+0xe6/0xb30 mm/page_alloc.c:2489 release_pages+0x32a/0x14e0 mm/swap.c:1042 tlb_batch_pages_flush+0x9a/0x190 mm/mmu_gather.c:97 tlb_flush_mmu_free mm/mmu_gather.c:292 [inline] tlb_flush_mmu mm/mmu_gather.c:299 [inline] tlb_finish_mmu+0x14b/0x7e0 mm/mmu_gather.c:391 exit_mmap+0x2db/0x960 mm/mmap.c:3215 __mmput+0x12a/0x4d0 kernel/fork.c:1348 mmput+0x62/0x70 kernel/fork.c:1370 exit_mm kernel/exit.c:567 [inline] do_exit+0x9b4/0x2a20 kernel/exit.c:861 do_group_exit+0xd4/0x2a0 kernel/exit.c:1024 get_signal+0x23ea/0x2770 kernel/signal.c:2881 arch_do_signal_or_restart+0x89/0x5f0 arch/x86/kernel/signal.c:308 exit_to_user_mode_loop kernel/entry/common.c:168 [inline] exit_to_user_mode_prepare+0x11f/0x240 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline] syscall_exit_to_user_mode+0x1d/0x60 kernel/entry/common.c:297 __do_fast_syscall_32+0x6d/0xe0 arch/x86/entry/common.c:181 do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:203 Memory state around the buggy address: ffff888077b0fc00: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc ffff888077b0fc80: 00 00 00 00 fc fc fc fc 00 00 04 fc fc fc fc fc >ffff888077b0fd00: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc ^ ffff888077b0fd80: 00 00 00 00 fc fc fc fc 00 00 00 fc fc fc fc fc ffff888077b0fe00: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc ==================================================================