================================================================== BUG: KASAN: use-after-free in string_nocheck lib/vsprintf.c:643 [inline] BUG: KASAN: use-after-free in string+0x218/0x2a0 lib/vsprintf.c:725 Read of size 1 at addr ffff88810a352d02 by task udevd/101 CPU: 0 PID: 101 Comm: udevd Not tainted 6.1.25-syzkaller-00098-g960d9828eee1 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:316 [inline] print_report+0x158/0x4e0 mm/kasan/report.c:427 kasan_report+0x13c/0x170 mm/kasan/report.c:531 __asan_report_load1_noabort+0x14/0x20 mm/kasan/report_generic.c:348 string_nocheck lib/vsprintf.c:643 [inline] string+0x218/0x2a0 lib/vsprintf.c:725 vsnprintf+0x11fc/0x1c70 lib/vsprintf.c:2800 add_uevent_var+0x1c0/0x440 lib/kobject_uevent.c:665 dev_uevent+0x3ee/0x6f0 drivers/base/core.c:2568 uevent_show+0x192/0x310 drivers/base/core.c:2639 dev_attr_show+0x56/0xd0 drivers/base/core.c:2342 sysfs_kf_seq_show+0x27c/0x3a0 fs/sysfs/file.c:59 kernfs_seq_show+0x119/0x160 fs/kernfs/file.c:201 seq_read_iter+0x430/0xd00 fs/seq_file.c:230 kernfs_fop_read_iter+0x145/0x470 fs/kernfs/file.c:275 call_read_iter include/linux/fs.h:2209 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x771/0xad0 fs/read_write.c:470 ksys_read+0x199/0x2c0 fs/read_write.c:613 __do_sys_read fs/read_write.c:623 [inline] __se_sys_read fs/read_write.c:621 [inline] __x64_sys_read+0x7b/0x90 fs/read_write.c:621 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:0x7fdc30d16b6a 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:00007fff08720778 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 0000564b7d34edb0 RCX: 00007fdc30d16b6a RDX: 0000000000001000 RSI: 0000564b7d34ffe0 RDI: 000000000000000c RBP: 0000564b7d34edb0 R08: 000000000000000c R09: 0000000000000010 R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000003fff R14: 00007fff08720c58 R15: 000000000000000a Allocated by task 12799: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:52 kasan_save_alloc_info+0x1f/0x30 mm/kasan/generic.c:505 ____kasan_kmalloc mm/kasan/common.c:379 [inline] __kasan_kmalloc+0x9c/0xb0 mm/kasan/common.c:388 kasan_kmalloc include/linux/kasan.h:212 [inline] kmalloc_trace+0x44/0xa0 mm/slab_common.c:1052 kmalloc include/linux/slab.h:553 [inline] raw_ioctl_init drivers/usb/gadget/legacy/raw_gadget.c:460 [inline] raw_ioctl+0x1a2d/0x3620 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+0x114/0x190 fs/ioctl.c:856 __x64_sys_ioctl+0x7b/0x90 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 12799: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:516 ____kasan_slab_free+0x131/0x180 mm/kasan/common.c:241 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:249 kasan_slab_free include/linux/kasan.h:178 [inline] slab_free_hook mm/slub.c:1744 [inline] slab_free_freelist_hook mm/slub.c:1770 [inline] slab_free mm/slub.c:3681 [inline] __kmem_cache_free+0x218/0x3b0 mm/slub.c:3694 kfree+0x7a/0xf0 mm/slab_common.c:1009 dev_free drivers/usb/gadget/legacy/raw_gadget.c:210 [inline] kref_put+0xb6/0x7c0 include/linux/kref.h:65 raw_release+0x145/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:424 __fput+0x3ab/0x870 fs/file_table.c:320 ____fput+0x15/0x20 fs/file_table.c:348 task_work_run+0x24d/0x2e0 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xbc5/0x2a40 kernel/exit.c:872 do_group_exit+0x21a/0x2d0 kernel/exit.c:1022 get_signal+0x169d/0x1820 kernel/signal.c:2861 arch_do_signal_or_restart+0xb0/0x16f0 arch/x86/kernel/signal.c:869 exit_to_user_mode_loop+0x6b/0xa0 kernel/entry/common.c:168 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline] syscall_exit_to_user_mode+0x26/0x130 kernel/entry/common.c:297 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 ffff88810a352d00 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 2 bytes inside of 32-byte region [ffff88810a352d00, ffff88810a352d20) The buggy address belongs to the physical page: page:ffffea000428d480 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10a352 flags: 0x4000000000000200(slab|zone=1) raw: 4000000000000200 ffffea000464fbc0 dead000000000003 ffff888100042600 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 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 21, tgid 21 (cpuhp/1), ts 2708321678, free_ts 0 set_page_owner include/linux/page_owner.h:33 [inline] post_alloc_hook+0x213/0x220 mm/page_alloc.c:2582 prep_new_page+0x1b/0x110 mm/page_alloc.c:2589 get_page_from_freelist+0x2762/0x27f0 mm/page_alloc.c:4387 __alloc_pages+0x3a1/0x780 mm/page_alloc.c:5664 allocate_slab mm/slub.c:1959 [inline] new_slab+0xce/0x4c0 mm/slub.c:2012 ___slab_alloc+0x6f9/0xb80 mm/slub.c:3200 __slab_alloc+0x5d/0xa0 mm/slub.c:3299 slab_alloc_node mm/slub.c:3384 [inline] __kmem_cache_alloc_node+0x1af/0x250 mm/slub.c:3457 __do_kmalloc_node mm/slab_common.c:956 [inline] __kmalloc+0xa3/0x1e0 mm/slab_common.c:970 kmalloc include/linux/slab.h:558 [inline] kzalloc include/linux/slab.h:689 [inline] kobject_get_path+0xbf/0x210 lib/kobject.c:152 kobject_uevent_env+0x27c/0x720 lib/kobject_uevent.c:529 kobject_uevent+0x1f/0x30 lib/kobject_uevent.c:642 device_add+0xa6e/0xf10 drivers/base/core.c:3645 device_create_groups_vargs drivers/base/core.c:4342 [inline] device_create+0x259/0x2e0 drivers/base/core.c:4384 msr_device_create+0x2a/0x40 arch/x86/kernel/msr.c:242 cpuhp_invoke_callback+0x684/0x1020 kernel/cpu.c:192 page_owner free stack trace missing Memory state around the buggy address: ffff88810a352c00: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ffff88810a352c80: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc >ffff88810a352d00: fa fb fb fb fc fc fc fc 00 00 00 fc fc fc fc fc ^ ffff88810a352d80: 00 00 00 fc fc fc fc fc 00 00 00 fc fc fc fc fc ffff88810a352e00: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc ==================================================================