================================================================== 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 ffff888021364780 by task udevd/2997 CPU: 1 PID: 2997 Comm: udevd Not tainted 6.1.15-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:2421 uevent_show+0x196/0x300 drivers/base/core.c:2492 dev_attr_show+0x50/0xb0 drivers/base/core.c:2195 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:0x7f2e627258fe 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:00007fff44810a38 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 0000558416ad29a0 RCX: 00007f2e627258fe RDX: 0000000000001000 RSI: 0000558416b0d5d0 RDI: 000000000000000c RBP: 00007f2e627f2380 R08: 000000000000000c R09: 00007f2e627f5a60 R10: 0000000000000002 R11: 0000000000000246 R12: 0000558416ad29a0 R13: 0000000000000d68 R14: 00007f2e627f1780 R15: 0000000000000d68 Allocated by task 21558: 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 21547: 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/0x2c0 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 ffff888021364780 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of 32-byte region [ffff888021364780, ffff8880213647a0) The buggy address belongs to the physical page: page:ffffea000084d900 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x21364 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffffea000078a140 dead000000000004 ffff888012041500 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 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 3641, tgid 3641 (udevd), ts 104954169643, free_ts 104864374825 prep_new_page mm/page_alloc.c:2539 [inline] get_page_from_freelist+0x3542/0x36d0 mm/page_alloc.c:4291 __alloc_pages+0x28d/0x7e0 mm/page_alloc.c:5558 __alloc_pages_node include/linux/gfp.h:237 [inline] alloc_slab_page+0x59/0x150 mm/slub.c:1796 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 __do_kmalloc_node mm/slab_common.c:954 [inline] __kmalloc_node+0x9e/0x190 mm/slab_common.c:962 kmalloc_array_node include/linux/slab.h:666 [inline] kcalloc_node include/linux/slab.h:671 [inline] memcg_alloc_slab_cgroups+0x7d/0x120 mm/memcontrol.c:2885 account_slab mm/slab.h:635 [inline] allocate_slab mm/slub.c:1957 [inline] new_slab+0xc0/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 __do_kmalloc_node mm/slab_common.c:954 [inline] __kmalloc_node+0x9e/0x190 mm/slab_common.c:962 kmalloc_node include/linux/slab.h:579 [inline] kvmalloc_node+0x6e/0x180 mm/util.c:581 kvmalloc include/linux/slab.h:706 [inline] seq_buf_alloc fs/seq_file.c:38 [inline] seq_read_iter+0x1fe/0xd10 fs/seq_file.c:210 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 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+0xfdc/0x1190 mm/page_alloc.c:3387 free_unref_page_list+0x107/0x890 mm/page_alloc.c:3529 release_pages+0x2836/0x2b40 mm/swap.c:1055 tlb_batch_pages_flush mm/mmu_gather.c:59 [inline] tlb_flush_mmu_free mm/mmu_gather.c:254 [inline] tlb_flush_mmu+0xfc/0x210 mm/mmu_gather.c:261 tlb_finish_mmu+0xce/0x1f0 mm/mmu_gather.c:361 exit_mmap+0x2c2/0x950 mm/mmap.c:3100 __mmput+0x115/0x3c0 kernel/fork.c:1188 exit_mm+0x226/0x300 kernel/exit.c:563 do_exit+0x5f4/0x2280 kernel/exit.c:854 do_group_exit+0x202/0x2b0 kernel/exit.c:1012 get_signal+0x16f7/0x17d0 kernel/signal.c:2858 arch_do_signal_or_restart+0xb0/0x1a10 arch/x86/kernel/signal.c:869 exit_to_user_mode_loop+0x6a/0x100 kernel/entry/common.c:168 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/0x2c0 kernel/entry/common.c:296 do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86 Memory state around the buggy address: ffff888021364680: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc ffff888021364700: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc >ffff888021364780: fa fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc ^ ffff888021364800: 00 00 00 fc fc fc fc fc fa fb fb fb fc fc fc fc ffff888021364880: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc ==================================================================