================================================================== BUG: KASAN: slab-use-after-free in string_nocheck lib/vsprintf.c:646 [inline] BUG: KASAN: slab-use-after-free in string+0x398/0x3d0 lib/vsprintf.c:728 Read of size 1 at addr ffff88801c302300 by task udevd/5249 CPU: 1 PID: 5249 Comm: udevd Not tainted 6.8.0-rc2-syzkaller-00419-gb555d191561a #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:377 [inline] print_report+0xc4/0x620 mm/kasan/report.c:488 kasan_report+0xda/0x110 mm/kasan/report.c:601 string_nocheck lib/vsprintf.c:646 [inline] string+0x398/0x3d0 lib/vsprintf.c:728 vsnprintf+0xc63/0x1870 lib/vsprintf.c:2824 add_uevent_var+0x17c/0x3a0 lib/kobject_uevent.c:665 dev_uevent+0x18b/0x770 drivers/base/core.c:2576 uevent_show+0x1c7/0x390 drivers/base/core.c:2647 dev_attr_show+0x53/0xe0 drivers/base/core.c:2350 sysfs_kf_seq_show+0x23e/0x410 fs/sysfs/file.c:59 seq_read_iter+0x4fa/0x12c0 fs/seq_file.c:230 kernfs_fop_read_iter+0x417/0x580 fs/kernfs/file.c:279 call_read_iter include/linux/fs.h:2079 [inline] new_sync_read fs/read_write.c:395 [inline] vfs_read+0x6c4/0xb80 fs/read_write.c:476 ksys_read+0x12f/0x260 fs/read_write.c:619 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xd5/0x270 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x6f/0x77 RIP: 0033:0x7fa99eb16b6a 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:00007ffebb56ea28 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 0000558c725d8c30 RCX: 00007fa99eb16b6a RDX: 0000000000001000 RSI: 0000558c725dd090 RDI: 0000000000000008 RBP: 0000558c725d8c30 R08: 0000000000000008 R09: 0000000000000040 R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000003fff R14: 00007ffebb56ef08 R15: 000000000000000a Allocated by task 32587: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:372 [inline] __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:389 kmalloc include/linux/slab.h:590 [inline] raw_ioctl_init+0x163/0x840 drivers/usb/gadget/legacy/raw_gadget.c:509 raw_ioctl+0x9dd/0x2b90 drivers/usb/gadget/legacy/raw_gadget.c:1303 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:871 [inline] __se_sys_ioctl fs/ioctl.c:857 [inline] __x64_sys_ioctl+0x193/0x220 fs/ioctl.c:857 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xd5/0x270 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x6f/0x77 Freed by task 32587: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 kasan_save_free_info+0x3f/0x60 mm/kasan/generic.c:640 poison_slab_object mm/kasan/common.c:241 [inline] __kasan_slab_free+0x121/0x1c0 mm/kasan/common.c:257 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2121 [inline] slab_free mm/slub.c:4299 [inline] kfree+0x124/0x370 mm/slub.c:4409 dev_free+0x9a/0x700 drivers/usb/gadget/legacy/raw_gadget.c:211 kref_put include/linux/kref.h:65 [inline] raw_release+0x188/0x2f0 drivers/usb/gadget/legacy/raw_gadget.c:473 __fput+0x270/0xb80 fs/file_table.c:376 task_work_run+0x14f/0x250 kernel/task_work.c:180 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xa8a/0x2ad0 kernel/exit.c:871 do_group_exit+0xd4/0x2a0 kernel/exit.c:1020 get_signal+0x23b9/0x2790 kernel/signal.c:2893 arch_do_signal_or_restart+0x90/0x7f0 arch/x86/kernel/signal.c:310 exit_to_user_mode_loop kernel/entry/common.c:105 [inline] exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline] __syscall_exit_to_user_mode_work kernel/entry/common.c:201 [inline] syscall_exit_to_user_mode+0x156/0x2b0 kernel/entry/common.c:212 do_syscall_64+0xe5/0x270 arch/x86/entry/common.c:89 entry_SYSCALL_64_after_hwframe+0x6f/0x77 The buggy address belongs to the object at ffff88801c302300 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of freed 32-byte region [ffff88801c302300, ffff88801c302320) The buggy address belongs to the physical page: page:ffffea000070c080 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1c302 flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000800 ffff888014c41500 ffffea0000b53a00 dead000000000006 raw: 0000000000000000 0000000000200020 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 0x112820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL), pid 5249, tgid 5249 (udevd), ts 571681674216, free_ts 571678120699 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x2d4/0x350 mm/page_alloc.c:1533 prep_new_page mm/page_alloc.c:1540 [inline] get_page_from_freelist+0xa28/0x3780 mm/page_alloc.c:3311 __alloc_pages+0x22f/0x2440 mm/page_alloc.c:4567 __alloc_pages_node include/linux/gfp.h:238 [inline] alloc_pages_node include/linux/gfp.h:261 [inline] alloc_slab_page mm/slub.c:2190 [inline] allocate_slab mm/slub.c:2354 [inline] new_slab+0xcc/0x3a0 mm/slub.c:2407 ___slab_alloc+0x4af/0x19a0 mm/slub.c:3540 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3625 __slab_alloc_node mm/slub.c:3678 [inline] slab_alloc_node mm/slub.c:3850 [inline] kmalloc_trace+0x30b/0x340 mm/slub.c:4007 kmalloc include/linux/slab.h:590 [inline] proc_thread_self_get_link+0x1c7/0x240 fs/proc/thread_self.c:22 pick_link fs/namei.c:1801 [inline] step_into+0x19b7/0x2230 fs/namei.c:1871 walk_component+0xfc/0x5b0 fs/namei.c:2007 link_path_walk.part.0.constprop.0+0x728/0xcf0 fs/namei.c:2328 link_path_walk fs/namei.c:2253 [inline] path_openat+0x231/0x29a0 fs/namei.c:3794 do_filp_open+0x1de/0x440 fs/namei.c:3825 do_sys_openat2+0x17a/0x1e0 fs/open.c:1404 do_sys_open fs/open.c:1419 [inline] __do_sys_openat fs/open.c:1435 [inline] __se_sys_openat fs/open.c:1430 [inline] __x64_sys_openat+0x175/0x210 fs/open.c:1430 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xd5/0x270 arch/x86/entry/common.c:83 page last free pid 4508 tgid 4508 stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1140 [inline] free_unref_page_prepare+0x527/0xb10 mm/page_alloc.c:2346 free_unref_page+0x33/0x3c0 mm/page_alloc.c:2486 selinux_genfs_get_sid security/selinux/hooks.c:1343 [inline] inode_doinit_with_dentry+0xac4/0x12c0 security/selinux/hooks.c:1541 selinux_d_instantiate+0x26/0x30 security/selinux/hooks.c:6342 security_d_instantiate+0x57/0xf0 security/security.c:3895 d_splice_alias+0x94/0xdf0 fs/dcache.c:2973 kernfs_iop_lookup+0x283/0x330 fs/kernfs/dir.c:1220 lookup_open.isra.0+0x92a/0x13c0 fs/namei.c:3474 open_last_lookups fs/namei.c:3565 [inline] path_openat+0x931/0x29a0 fs/namei.c:3795 do_filp_open+0x1de/0x440 fs/namei.c:3825 do_sys_openat2+0x17a/0x1e0 fs/open.c:1404 do_sys_open fs/open.c:1419 [inline] __do_sys_openat fs/open.c:1435 [inline] __se_sys_openat fs/open.c:1430 [inline] __x64_sys_openat+0x175/0x210 fs/open.c:1430 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xd5/0x270 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x6f/0x77 Memory state around the buggy address: ffff88801c302200: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc ffff88801c302280: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc >ffff88801c302300: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc ^ ffff88801c302380: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc ffff88801c302400: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================