================================================================== BUG: KASAN: slab-use-after-free in string_nocheck lib/vsprintf.c:644 [inline] BUG: KASAN: slab-use-after-free in string+0x39c/0x3d0 lib/vsprintf.c:726 Read of size 1 at addr ffff8880212a5980 by task udevd/4474 CPU: 1 PID: 4474 Comm: udevd Not tainted 6.4.0-syzkaller-12155-ga452483508d7 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106 print_address_description.constprop.0+0x2c/0x3c0 mm/kasan/report.c:364 print_report mm/kasan/report.c:475 [inline] kasan_report+0x11d/0x130 mm/kasan/report.c:588 string_nocheck lib/vsprintf.c:644 [inline] string+0x39c/0x3d0 lib/vsprintf.c:726 vsnprintf+0xa36/0x1710 lib/vsprintf.c:2817 add_uevent_var+0x161/0x390 lib/kobject_uevent.c:665 dev_uevent+0x191/0x780 drivers/base/core.c:2575 uevent_show+0x1bc/0x380 drivers/base/core.c:2646 dev_attr_show+0x4f/0xd0 drivers/base/core.c:2349 sysfs_kf_seq_show+0x21d/0x430 fs/sysfs/file.c:59 seq_read_iter+0x4f9/0x12d0 fs/seq_file.c:230 kernfs_fop_read_iter+0x4ce/0x690 fs/kernfs/file.c:279 call_read_iter include/linux/fs.h:1865 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x4a8/0x8d0 fs/read_write.c:470 ksys_read+0x122/0x250 fs/read_write.c:613 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fe9e3916b6a 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:00007ffcb74ac6b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 000055e0d0d27640 RCX: 00007fe9e3916b6a RDX: 0000000000001000 RSI: 000055e0d0d1f960 RDI: 000000000000000c RBP: 000055e0d0d27640 R08: 000000000000000c R09: 0000000000000000 R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000003fff R14: 00007ffcb74acb98 R15: 000000000000000a Allocated by task 16264: kasan_save_stack+0x22/0x40 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 mm/kasan/common.c:333 [inline] __kasan_kmalloc+0xa2/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:582 [inline] raw_ioctl_init+0x152/0x830 drivers/usb/gadget/legacy/raw_gadget.c:460 raw_ioctl+0xc21/0x2af0 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 fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x19d/0x210 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 16260: kasan_save_stack+0x22/0x40 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:521 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x160/0x1c0 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+0x8b/0x1c0 mm/slub.c:1818 slab_free mm/slub.c:3801 [inline] __kmem_cache_free+0xb8/0x2d0 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+0x21d/0x2d0 drivers/usb/gadget/legacy/raw_gadget.c:424 __fput+0x40c/0xad0 fs/file_table.c:384 task_work_run+0x16f/0x270 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xa9a/0x29a0 kernel/exit.c:874 do_group_exit+0xd4/0x2a0 kernel/exit.c:1024 get_signal+0x249b/0x25f0 kernel/signal.c:2877 arch_do_signal_or_restart+0x79/0x5c0 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/0x50 kernel/entry/common.c:297 do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff8880212a5980 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of freed 32-byte region [ffff8880212a5980, ffff8880212a59a0) The buggy address belongs to the physical page: page:ffffea000084a940 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880212a5ac0 pfn:0x212a5 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000200 ffff888012841500 ffffea00009f8c90 ffffea0001f57350 raw: ffff8880212a5ac0 000000000040003f 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 5943854854, free_ts 5942478134 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x2db/0x350 mm/page_alloc.c:1570 prep_new_page mm/page_alloc.c:1577 [inline] get_page_from_freelist+0xfed/0x2d30 mm/page_alloc.c:3221 __alloc_pages+0x1cb/0x4a0 mm/page_alloc.c:4477 alloc_page_interleave+0x1e/0x200 mm/mempolicy.c:2112 alloc_pages+0x233/0x270 mm/mempolicy.c:2274 alloc_slab_page mm/slub.c:1862 [inline] allocate_slab+0x25f/0x390 mm/slub.c:2009 new_slab mm/slub.c:2062 [inline] ___slab_alloc+0xbc3/0x15d0 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+0x143/0x350 mm/slub.c:3509 __do_kmalloc_node mm/slab_common.c:984 [inline] __kmalloc+0x4e/0x190 mm/slab_common.c:998 kmalloc include/linux/slab.h:586 [inline] kzalloc include/linux/slab.h:703 [inline] kobject_get_path+0xc5/0x260 lib/kobject.c:154 kobject_uevent_env+0x256/0x16c0 lib/kobject_uevent.c:529 driver_register+0x2df/0x4a0 drivers/base/driver.c:254 usb_register_driver+0x251/0x500 drivers/usb/core/driver.c:1062 do_one_initcall+0x105/0x630 init/main.c:1232 do_initcall_level init/main.c:1294 [inline] do_initcalls init/main.c:1310 [inline] do_basic_setup init/main.c:1329 [inline] kernel_init_freeable+0x64e/0xba0 init/main.c:1546 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+0x62e/0xcb0 mm/page_alloc.c:2348 free_unref_page+0x33/0x370 mm/page_alloc.c:2443 mm_free_pgd kernel/fork.c:802 [inline] __mmdrop+0xd7/0x490 kernel/fork.c:920 mmdrop include/linux/sched/mm.h:54 [inline] __mmput+0x404/0x4c0 kernel/fork.c:1358 mmput+0x60/0x70 kernel/fork.c:1369 free_bprm+0x144/0x3f0 fs/exec.c:1491 kernel_execve+0x3fe/0x500 fs/exec.c:2025 call_usermodehelper_exec_async+0x260/0x4e0 kernel/umh.c:110 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 Memory state around the buggy address: ffff8880212a5880: 00 00 06 fc fc fc fc fc 00 00 00 00 fc fc fc fc ffff8880212a5900: fa fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc >ffff8880212a5980: fa fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc ^ ffff8880212a5a00: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ffff8880212a5a80: 00 00 00 00 fc fc fc fc fb fb fb fb fc fc fc fc ==================================================================