================================================================== 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 ffff8880916a2340 by task udevd/4447 CPU: 1 PID: 4447 Comm: udevd Not tainted 6.4.0-rc5-syzkaller-00305-g022ce8862dff #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/25/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:351 [inline] print_report+0x163/0x540 mm/kasan/report.c:462 kasan_report+0x176/0x1b0 mm/kasan/report.c:572 string_nocheck lib/vsprintf.c:644 [inline] string+0x218/0x2b0 lib/vsprintf.c:726 vsnprintf+0x10fc/0x1d80 lib/vsprintf.c:2817 add_uevent_var+0x1c4/0x440 lib/kobject_uevent.c:665 dev_uevent+0x3ec/0x8f0 drivers/base/core.c:2575 uevent_show+0x19a/0x310 drivers/base/core.c:2646 dev_attr_show+0x54/0xc0 drivers/base/core.c:2349 sysfs_kf_seq_show+0x331/0x4b0 fs/sysfs/file.c:59 seq_read_iter+0x43e/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+0x788/0xb00 fs/read_write.c:470 ksys_read+0x1a0/0x2c0 fs/read_write.c:613 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fb598316b6a 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:00007ffc9f82eca8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 000055afbe413150 RCX: 00007fb598316b6a RDX: 0000000000001000 RSI: 000055afbe410620 RDI: 000000000000000c RBP: 000055afbe413150 R08: 000000000000000c R09: 0000000000008000 R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000003fff R14: 00007ffc9f82f188 R15: 000000000000000a Allocated by task 17465: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4f/0x70 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:374 [inline] __kasan_kmalloc+0x98/0xb0 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+0x1aad/0x3cd0 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+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 17463: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4f/0x70 mm/kasan/common.c:52 kasan_save_free_info+0x2b/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+0x264/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+0x138/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:424 __fput+0x3b7/0x890 fs/file_table.c:321 task_work_run+0x24a/0x300 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0x68f/0x2290 kernel/exit.c:874 do_group_exit+0x206/0x2c0 kernel/exit.c:1024 get_signal+0x1709/0x17e0 kernel/signal.c:2876 arch_do_signal_or_restart+0x91/0x670 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 irqentry_exit_to_user_mode+0x9/0x40 kernel/entry/common.c:310 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:645 The buggy address belongs to the object at ffff8880916a2340 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of freed 32-byte region [ffff8880916a2340, ffff8880916a2360) The buggy address belongs to the physical page: page:ffffea000245a880 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880916a2740 pfn:0x916a2 ksm flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000200 ffff888012441500 ffffea0001e82c80 dead000000000003 raw: ffff8880916a2740 000000008040003b 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 0x112c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL), pid 14696, tgid 14696 (udevd), ts 1916798804511, free_ts 1916769409205 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x1e6/0x210 mm/page_alloc.c:1731 prep_new_page mm/page_alloc.c:1738 [inline] get_page_from_freelist+0x321c/0x33a0 mm/page_alloc.c:3502 __alloc_pages+0x255/0x670 mm/page_alloc.c:4768 alloc_slab_page+0x6a/0x160 mm/slub.c:1851 allocate_slab mm/slub.c:1998 [inline] new_slab+0x84/0x2f0 mm/slub.c:2051 ___slab_alloc+0xa85/0x10a0 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+0x1b8/0x290 mm/slub.c:3490 __do_kmalloc_node mm/slab_common.c:965 [inline] __kmalloc+0xa8/0x230 mm/slab_common.c:979 kmalloc include/linux/slab.h:563 [inline] kzalloc include/linux/slab.h:680 [inline] tomoyo_encode2 security/tomoyo/realpath.c:45 [inline] tomoyo_encode+0x26f/0x530 security/tomoyo/realpath.c:80 tomoyo_realpath_from_path+0x598/0x5e0 security/tomoyo/realpath.c:283 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_perm+0x28d/0x700 security/tomoyo/file.c:822 security_inode_getattr+0xd3/0x120 security/security.c:2114 vfs_getattr fs/stat.c:167 [inline] vfs_statx+0x18f/0x480 fs/stat.c:242 vfs_fstatat fs/stat.c:276 [inline] __do_sys_newfstatat fs/stat.c:446 [inline] __se_sys_newfstatat fs/stat.c:440 [inline] __x64_sys_newfstatat+0x14f/0x1d0 fs/stat.c:440 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd 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+0x903/0xa30 mm/page_alloc.c:2564 free_unref_page+0x37/0x3f0 mm/page_alloc.c:2659 mm_free_pgd kernel/fork.c:806 [inline] __mmdrop+0xbe/0x420 kernel/fork.c:924 mmdrop include/linux/sched/mm.h:54 [inline] mmdrop_sched include/linux/sched/mm.h:82 [inline] mmdrop_lazy_tlb_sched include/linux/sched/mm.h:109 [inline] finish_task_switch+0x225/0x650 kernel/sched/core.c:5240 context_switch kernel/sched/core.c:5346 [inline] __schedule+0x1883/0x4900 kernel/sched/core.c:6669 schedule+0xc3/0x180 kernel/sched/core.c:6745 do_nanosleep+0x18a/0x610 kernel/time/hrtimer.c:2044 hrtimer_nanosleep+0x226/0x460 kernel/time/hrtimer.c:2097 __do_sys_clock_nanosleep kernel/time/posix-timers.c:1281 [inline] __se_sys_clock_nanosleep+0x327/0x3b0 kernel/time/posix-timers.c:1258 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Memory state around the buggy address: ffff8880916a2200: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ffff8880916a2280: fa fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc >ffff8880916a2300: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc ^ ffff8880916a2380: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ffff8880916a2400: fa fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc ==================================================================