================================================================== BUG: KASAN: slab-use-after-free in string_nocheck lib/vsprintf.c:646 [inline] BUG: KASAN: slab-use-after-free in string+0x394/0x3d0 lib/vsprintf.c:728 Read of size 1 at addr ffff88811149cb80 by task udevd/14053 CPU: 1 PID: 14053 Comm: udevd Not tainted 6.8.0-rc6-syzkaller-00173-gdfea18989aa7 #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+0x394/0x3d0 lib/vsprintf.c:728 vsnprintf+0xc5f/0x1870 lib/vsprintf.c:2824 add_uevent_var+0x17c/0x3a0 lib/kobject_uevent.c:665 dev_uevent+0x18b/0x760 drivers/base/core.c:2590 uevent_show+0x1bf/0x380 drivers/base/core.c:2661 dev_attr_show+0x4f/0xd0 drivers/base/core.c:2364 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+0x410/0x580 fs/kernfs/file.c:279 call_read_iter include/linux/fs.h:2081 [inline] new_sync_read fs/read_write.c:395 [inline] vfs_read+0x6bb/0xb70 fs/read_write.c:476 ksys_read+0x12f/0x250 fs/read_write.c:619 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xd3/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x63/0x6b RIP: 0033:0x7fc2cef62b6a 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:00007ffdf4c24e68 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 000055a93e661fa0 RCX: 00007fc2cef62b6a RDX: 0000000000001000 RSI: 000055a93e674310 RDI: 0000000000000008 RBP: 000055a93e661fa0 R08: 0000000000000008 R09: 0000000000000001 R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000003fff R14: 00007ffdf4c25348 R15: 000000000000000a Allocated by task 21179: kasan_save_stack+0x33/0x50 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+0x87/0x90 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+0x9d9/0x2b80 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+0x18f/0x210 fs/ioctl.c:857 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xd3/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x63/0x6b Freed by task 21180: kasan_save_stack+0x33/0x50 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:643 poison_slab_object mm/kasan/common.c:241 [inline] __kasan_slab_free+0x106/0x1b0 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+0x105/0x340 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+0x184/0x2e0 drivers/usb/gadget/legacy/raw_gadget.c:473 __fput+0x270/0xb70 fs/file_table.c:376 task_work_run+0x14d/0x240 kernel/task_work.c:180 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xa8a/0x2a50 kernel/exit.c:871 do_group_exit+0xd4/0x2a0 kernel/exit.c:1020 get_signal+0x23b5/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+0x144/0x250 kernel/entry/common.c:212 do_syscall_64+0xe0/0x250 arch/x86/entry/common.c:89 entry_SYSCALL_64_after_hwframe+0x63/0x6b The buggy address belongs to the object at ffff88811149cb80 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of freed 32-byte region [ffff88811149cb80, ffff88811149cba0) The buggy address belongs to the physical page: page:ffffea0004452700 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11149c flags: 0x200000000000800(slab|node=0|zone=2) page_type: 0xffffffff() raw: 0200000000000800 ffff888100041500 ffffea000457ae00 dead000000000004 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 0x12c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY), pid 2389, tgid 2389 (udevd), ts 14663197797, free_ts 10789908959 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x2d0/0x350 mm/page_alloc.c:1533 prep_new_page mm/page_alloc.c:1540 [inline] get_page_from_freelist+0x139c/0x3470 mm/page_alloc.c:3311 __alloc_pages+0x228/0x2250 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+0x4b0/0x1860 mm/slub.c:3540 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3625 __slab_alloc_node mm/slub.c:3678 [inline] slab_alloc_node mm/slub.c:3850 [inline] __do_kmalloc_node mm/slub.c:3980 [inline] __kmalloc+0x371/0x400 mm/slub.c:3994 kmalloc include/linux/slab.h:594 [inline] kzalloc include/linux/slab.h:711 [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+0x2a3/0x3b0 security/tomoyo/file.c:771 tomoyo_file_open+0x71/0x90 security/tomoyo/tomoyo.c:334 security_file_open+0x62/0xa0 security/security.c:2933 do_dentry_open+0x5b7/0x1720 fs/open.c:940 do_open fs/namei.c:3645 [inline] path_openat+0x1df6/0x2990 fs/namei.c:3802 do_filp_open+0x1de/0x430 fs/namei.c:3829 page last free pid 1 tgid 1 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+0x504/0xae0 mm/page_alloc.c:2346 free_unref_page+0x33/0x2d0 mm/page_alloc.c:2486 kasan_depopulate_vmalloc_pte+0x63/0x80 mm/kasan/shadow.c:415 apply_to_pte_range mm/memory.c:2619 [inline] apply_to_pmd_range mm/memory.c:2663 [inline] apply_to_pud_range mm/memory.c:2699 [inline] apply_to_p4d_range mm/memory.c:2735 [inline] __apply_to_page_range+0x57e/0xdb0 mm/memory.c:2769 kasan_release_vmalloc+0xa8/0xc0 mm/kasan/shadow.c:532 __purge_vmap_area_lazy+0x8b9/0x2170 mm/vmalloc.c:1770 _vm_unmap_aliases+0x693/0x9b0 mm/vmalloc.c:2306 change_page_attr_set_clr+0x24c/0x490 arch/x86/mm/pat/set_memory.c:1838 change_page_attr_set arch/x86/mm/pat/set_memory.c:1879 [inline] set_memory_nx+0xb6/0x110 arch/x86/mm/pat/set_memory.c:2072 free_init_pages+0x79/0xd0 arch/x86/mm/init.c:927 kernel_init+0x30/0x2a0 init/main.c:1450 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:243 Memory state around the buggy address: ffff88811149ca80: 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc fc ffff88811149cb00: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc >ffff88811149cb80: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc ^ ffff88811149cc00: 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc fc ffff88811149cc80: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================