================================================================== BUG: KASAN: slab-use-after-free in string_nocheck lib/vsprintf.c:644 [inline] BUG: KASAN: slab-use-after-free in string+0x218/0x2b0 lib/vsprintf.c:726 Read of size 1 at addr ffff888026bde1c0 by task udevd/4443 CPU: 0 PID: 4443 Comm: udevd Not tainted 6.3.0-syzkaller-13027-g1a5304fecee5 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/14/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:351 [inline] print_report+0x15f/0x540 mm/kasan/report.c:462 kasan_report+0x172/0x1a0 mm/kasan/report.c:572 string_nocheck lib/vsprintf.c:644 [inline] string+0x218/0x2b0 lib/vsprintf.c:726 vsnprintf+0x11a4/0x1c70 lib/vsprintf.c:2817 add_uevent_var+0x1c0/0x440 lib/kobject_uevent.c:665 dev_uevent+0x3e8/0x8e0 drivers/base/core.c:2575 uevent_show+0x196/0x300 drivers/base/core.c:2646 dev_attr_show+0x50/0xb0 drivers/base/core.c:2349 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:1862 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x79c/0xb80 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:0x7f8af7116b6a 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:00007ffea3b51648 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 000055fcd9e9c590 RCX: 00007f8af7116b6a RDX: 0000000000001000 RSI: 000055fcd9e8b960 RDI: 000000000000000c RBP: 000055fcd9e9c590 R08: 000000000000000c R09: 0000000000000000 R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000003fff R14: 00007ffea3b51b28 R15: 000000000000000a Allocated by task 18911: 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+0x94/0xa0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:559 [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 18911: 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:521 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236 kasan_slab_free include/linux/kasan.h:162 [inline] slab_free_hook mm/slub.c:1781 [inline] slab_free_freelist_hook mm/slub.c:1807 [inline] slab_free mm/slub.c:3786 [inline] __kmem_cache_free+0x25c/0x3c0 mm/slub.c:3799 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:321 task_work_run+0x246/0x300 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0x68b/0x2280 kernel/exit.c:871 do_group_exit+0x202/0x2b0 kernel/exit.c:1021 get_signal+0x1709/0x17e0 kernel/signal.c:2874 arch_do_signal_or_restart+0x8d/0x610 arch/x86/kernel/signal.c:306 exit_to_user_mode_loop+0x6a/0x100 kernel/entry/common.c:168 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline] syscall_exit_to_user_mode+0x60/0x260 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 ffff888026bde1c0 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of freed 32-byte region [ffff888026bde1c0, ffff888026bde1e0) The buggy address belongs to the physical page: page:ffffea00009af780 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x26bde ksm flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000200 ffff888012441500 ffffea0000854f80 dead000000000003 raw: 0000000000000000 0000000080400040 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 1, tgid 1 (swapper/0), ts 10554181943, free_ts 10548124282 prep_new_page mm/page_alloc.c:1729 [inline] get_page_from_freelist+0x31f8/0x3370 mm/page_alloc.c:3493 __alloc_pages+0x251/0x660 mm/page_alloc.c:4759 alloc_page_interleave+0x22/0x1c0 mm/mempolicy.c:2110 alloc_slab_page+0x6a/0x150 mm/slub.c:1851 allocate_slab mm/slub.c:1998 [inline] new_slab+0x84/0x2d0 mm/slub.c:2051 ___slab_alloc+0xa71/0x1080 mm/slub.c:3192 __slab_alloc mm/slub.c:3291 [inline] __slab_alloc_node mm/slub.c:3344 [inline] slab_alloc_node mm/slub.c:3441 [inline] __kmem_cache_alloc_node+0x1b4/0x280 mm/slub.c:3490 __do_kmalloc_node mm/slab_common.c:965 [inline] __kmalloc+0xa4/0x220 mm/slab_common.c:979 kmalloc include/linux/slab.h:563 [inline] kzalloc include/linux/slab.h:680 [inline] kobject_get_path+0xb4/0x220 lib/kobject.c:154 kobject_uevent_env+0x29b/0x8c0 lib/kobject_uevent.c:529 kernel_add_sysfs_param+0x106/0x130 kernel/params.c:817 param_sysfs_builtin+0x16a/0x1f0 kernel/params.c:852 param_sysfs_builtin_init+0x29/0x30 kernel/params.c:986 do_one_initcall+0x239/0x7c0 init/main.c:1246 do_initcall_level+0x157/0x210 init/main.c:1319 do_initcalls+0x3f/0x80 init/main.c:1335 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1302 [inline] free_unref_page_prepare+0x8e9/0x9f0 mm/page_alloc.c:2555 free_unref_page_list+0x58e/0x830 mm/page_alloc.c:2696 release_pages+0x275c/0x2a70 mm/swap.c:1042 tlb_batch_pages_flush mm/mmu_gather.c:97 [inline] tlb_flush_mmu_free mm/mmu_gather.c:292 [inline] tlb_flush_mmu+0xfc/0x210 mm/mmu_gather.c:299 tlb_finish_mmu+0xd0/0x1f0 mm/mmu_gather.c:391 exit_mmap+0x3d6/0xac0 mm/mmap.c:3123 __mmput+0x115/0x3c0 kernel/fork.c:1351 free_bprm+0x144/0x320 fs/exec.c:1490 kernel_execve+0x8f1/0xa10 fs/exec.c:2024 call_usermodehelper_exec_async+0x22f/0x370 kernel/umh.c:110 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 Memory state around the buggy address: ffff888026bde080: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc ffff888026bde100: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc >ffff888026bde180: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc ^ ffff888026bde200: 00 00 00 00 fc fc fc fc 00 00 00 fc fc fc fc fc ffff888026bde280: 00 00 00 fc fc fc fc fc 00 00 00 00 fc fc fc fc ==================================================================