BUG: KASAN: slab-use-after-free in string_nocheck lib/vsprintf.c:645 [inline] BUG: KASAN: slab-use-after-free in string+0x394/0x3d0 lib/vsprintf.c:727 Read of size 1 at addr ffff888045fa4ec0 by task udevd/4494 CPU: 0 PID: 4494 Comm: udevd Not tainted 6.5.0-syzkaller-11812-g7733171926cc #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023 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:364 [inline] print_report+0xc4/0x620 mm/kasan/report.c:475 kasan_report+0xda/0x110 mm/kasan/report.c:588 string_nocheck lib/vsprintf.c:645 [inline] string+0x394/0x3d0 lib/vsprintf.c:727 vsnprintf+0xc5f/0x1870 lib/vsprintf.c:2818 add_uevent_var+0x17c/0x390 lib/kobject_uevent.c:665 dev_uevent+0x18b/0x760 drivers/base/core.c:2575 uevent_show+0x1bf/0x380 drivers/base/core.c:2646 dev_attr_show+0x4f/0xd0 drivers/base/core.c:2349 sysfs_kf_seq_show+0x23e/0x400 fs/sysfs/file.c:59 seq_read_iter+0x4e5/0x1280 fs/seq_file.c:230 kernfs_fop_read_iter+0x4c8/0x680 fs/kernfs/file.c:279 call_read_iter include/linux/fs.h:1979 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x4e0/0x930 fs/read_write.c:470 ksys_read+0x12f/0x250 fs/read_write.c:613 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f9c16b16b6a 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:00007ffcf03ada88 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 0000560f61604630 RCX: 00007f9c16b16b6a RDX: 0000000000001000 RSI: 0000560f61641750 RDI: 000000000000000c RBP: 0000560f61604630 R08: 000000000000000c R09: 0000000000040000 R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000003fff R14: 00007ffcf03adf68 R15: 000000000000000a Allocated by task 5599: kasan_save_stack+0x33/0x50 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+0xa2/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:599 [inline] raw_ioctl_init+0x163/0x840 drivers/usb/gadget/legacy/raw_gadget.c:462 raw_ioctl+0x9d9/0x2b80 drivers/usb/gadget/legacy/raw_gadget.c:1252 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+0x18f/0x210 fs/ioctl.c:857 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 5599: kasan_save_stack+0x33/0x50 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:522 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x15b/0x1b0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:162 [inline] slab_free_hook mm/slub.c:1800 [inline] slab_free_freelist_hook+0x114/0x1e0 mm/slub.c:1826 slab_free mm/slub.c:3809 [inline] __kmem_cache_free+0xb8/0x2f0 mm/slub.c:3822 dev_free+0x9a/0x700 drivers/usb/gadget/legacy/raw_gadget.c:210 kref_put include/linux/kref.h:65 [inline] raw_release+0x184/0x2e0 drivers/usb/gadget/legacy/raw_gadget.c:426 __fput+0x3f7/0xa70 fs/file_table.c:384 task_work_run+0x14d/0x240 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xa99/0x2a20 kernel/exit.c:874 do_group_exit+0xd4/0x2a0 kernel/exit.c:1024 get_signal+0x23d1/0x27b0 kernel/signal.c:2892 arch_do_signal_or_restart+0x90/0x7f0 arch/x86/kernel/signal.c:309 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:285 [inline] syscall_exit_to_user_mode+0x1d/0x60 kernel/entry/common.c:296 do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff888045fa4ec0 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of freed 32-byte region [ffff888045fa4ec0, ffff888045fa4ee0) The buggy address belongs to the physical page: page:ffffea000117e900 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888045fa4c40 pfn:0x45fa4 ksm flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000800 ffff888012c41500 ffffea0001d58a00 dead000000000003 raw: ffff888045fa4c40 0000000080400035 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 28646, tgid 28644 (syz-executor.3), ts 1796952132395, free_ts 1796773050554 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x2cf/0x340 mm/page_alloc.c:1536 prep_new_page mm/page_alloc.c:1543 [inline] get_page_from_freelist+0xee0/0x2f20 mm/page_alloc.c:3170 __alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4426 alloc_pages+0x1a9/0x270 mm/mempolicy.c:2298 alloc_slab_page mm/slub.c:1870 [inline] allocate_slab+0x251/0x380 mm/slub.c:2017 new_slab mm/slub.c:2070 [inline] ___slab_alloc+0x8be/0x1570 mm/slub.c:3223 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3322 __slab_alloc_node mm/slub.c:3375 [inline] slab_alloc_node mm/slub.c:3468 [inline] __kmem_cache_alloc_node+0x137/0x350 mm/slub.c:3517 __do_kmalloc_node mm/slab_common.c:1022 [inline] __kmalloc+0x4f/0x100 mm/slab_common.c:1036 kmalloc include/linux/slab.h:603 [inline] kzalloc include/linux/slab.h:720 [inline] tomoyo_encode2+0x100/0x3d0 security/tomoyo/realpath.c:45 tomoyo_encode+0x29/0x50 security/tomoyo/realpath.c:80 tomoyo_realpath_from_path+0x196/0x710 security/tomoyo/realpath.c:283 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_check_open_permission+0x2aa/0x3b0 security/tomoyo/file.c:771 tomoyo_file_open security/tomoyo/tomoyo.c:332 [inline] tomoyo_file_open+0xa8/0xd0 security/tomoyo/tomoyo.c:327 security_file_open+0x6a/0xe0 security/security.c:2836 do_dentry_open+0x538/0x1730 fs/open.c:916 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1136 [inline] free_unref_page_prepare+0x476/0xa40 mm/page_alloc.c:2312 free_unref_page_list+0xe6/0xb30 mm/page_alloc.c:2451 release_pages+0x32a/0x14e0 mm/swap.c:1042 tlb_batch_pages_flush+0x9a/0x190 mm/mmu_gather.c:98 tlb_flush_mmu_free mm/mmu_gather.c:293 [inline] tlb_flush_mmu mm/mmu_gather.c:300 [inline] tlb_finish_mmu+0x14b/0x6f0 mm/mmu_gather.c:392 exit_mmap+0x38b/0xa60 mm/mmap.c:3223 __mmput+0x12a/0x4d0 kernel/fork.c:1349 mmput+0x62/0x70 kernel/fork.c:1371 exit_mm kernel/exit.c:567 [inline] do_exit+0x9b4/0x2a20 kernel/exit.c:861 do_group_exit+0xd4/0x2a0 kernel/exit.c:1024 __do_sys_exit_group kernel/exit.c:1035 [inline] __se_sys_exit_group kernel/exit.c:1033 [inline] __x64_sys_exit_group+0x3e/0x50 kernel/exit.c:1033 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Memory state around the buggy address: ffff888045fa4d80: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ffff888045fa4e00: 00 00 00 00 fc fc fc fc fb fb fb fb fc fc fc fc >ffff888045fa4e80: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc ^ ffff888045fa4f00: fb fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc ffff888045fa4f80: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ==================================================================