================================================================== BUG: KASAN: use-after-free in string_nocheck lib/vsprintf.c:644 [inline] BUG: KASAN: use-after-free in string+0x39c/0x3d0 lib/vsprintf.c:726 Read of size 1 at addr ffff8880272d8a40 by task udevd/4424 CPU: 0 PID: 4424 Comm: udevd Not tainted 6.2.0-rc8-syzkaller-00021-ge1c04510f521 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/21/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:306 [inline] print_report+0x15e/0x461 mm/kasan/report.c:417 kasan_report+0xbf/0x1f0 mm/kasan/report.c:517 string_nocheck lib/vsprintf.c:644 [inline] string+0x39c/0x3d0 lib/vsprintf.c:726 vsnprintf+0xa11/0x16b0 lib/vsprintf.c:2796 add_uevent_var+0x161/0x390 lib/kobject_uevent.c:665 dev_uevent+0x191/0x780 drivers/base/core.c:2422 uevent_show+0x1bc/0x380 drivers/base/core.c:2493 dev_attr_show+0x4f/0x90 drivers/base/core.c:2196 sysfs_kf_seq_show+0x21d/0x3d0 fs/sysfs/file.c:59 seq_read_iter+0x4f9/0x1280 fs/seq_file.c:230 kernfs_fop_read_iter+0x53e/0x790 fs/kernfs/file.c:279 call_read_iter include/linux/fs.h:2183 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x681/0x930 fs/read_write.c:470 ksys_read+0x12b/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:0x7f5d4f7258fe Code: c0 e9 e6 fe ff ff 50 48 8d 3d 0e c7 09 00 e8 c9 cf 01 00 66 0f 1f 84 00 00 00 00 00 64 8b 04 25 18 00 00 00 85 c0 75 14 0f 05 <48> 3d 00 f0 ff ff 77 5a c3 66 0f 1f 84 00 00 00 00 00 48 83 ec 28 RSP: 002b:00007ffcc29b33d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 000055c1ebaf6110 RCX: 00007f5d4f7258fe RDX: 0000000000001000 RSI: 000055c1ebb6bdb0 RDI: 000000000000000c RBP: 00007f5d4f7f2380 R08: 000000000000000c R09: 00007f5d4f7f5a60 R10: 0000000000000100 R11: 0000000000000246 R12: 000055c1ebaf6110 R13: 0000000000000d68 R14: 00007f5d4f7f1780 R15: 0000000000000d68 Allocated by task 6511: 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+0xa3/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:580 [inline] raw_ioctl_init+0x152/0x820 drivers/usb/gadget/legacy/raw_gadget.c:460 raw_ioctl+0xbf5/0x27d0 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+0x197/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 6511: 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:523 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x13b/0x1a0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:177 [inline] __cache_free mm/slab.c:3396 [inline] __do_kmem_cache_free mm/slab.c:3582 [inline] __kmem_cache_free+0xcd/0x3b0 mm/slab.c:3589 dev_free+0x9a/0x700 drivers/usb/gadget/legacy/raw_gadget.c:210 kref_put include/linux/kref.h:65 [inline] raw_release+0x21d/0x290 drivers/usb/gadget/legacy/raw_gadget.c:424 __fput+0x27c/0xa90 fs/file_table.c:320 task_work_run+0x16f/0x270 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xaa8/0x2950 kernel/exit.c:867 do_group_exit+0xd4/0x2a0 kernel/exit.c:1012 get_signal+0x21c3/0x2450 kernel/signal.c:2859 arch_do_signal_or_restart+0x79/0x5c0 arch/x86/kernel/signal.c:306 exit_to_user_mode_loop kernel/entry/common.c:168 [inline] exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296 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 ffff8880272d8a40 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of 32-byte region [ffff8880272d8a40, ffff8880272d8a60) The buggy address belongs to the physical page: page:ffffea00009cb600 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880272d8fc1 pfn:0x272d8 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffff888012440100 ffffea0001ee2b10 ffffea0001f24990 raw: ffff8880272d8fc1 ffff8880272d8000 000000010000003f 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 0x2420c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_THISNODE), pid 1, tgid 1 (swapper/0), ts 21686073193, free_ts 21647106138 prep_new_page mm/page_alloc.c:2531 [inline] get_page_from_freelist+0x119c/0x2ce0 mm/page_alloc.c:4283 __alloc_pages+0x1cb/0x5b0 mm/page_alloc.c:5549 __alloc_pages_node include/linux/gfp.h:237 [inline] kmem_getpages mm/slab.c:1363 [inline] cache_grow_begin+0x94/0x390 mm/slab.c:2576 cache_alloc_refill+0x27f/0x380 mm/slab.c:2949 ____cache_alloc mm/slab.c:3025 [inline] ____cache_alloc mm/slab.c:3008 [inline] __do_cache_alloc mm/slab.c:3211 [inline] slab_alloc_node mm/slab.c:3256 [inline] __kmem_cache_alloc_node+0x478/0x510 mm/slab.c:3546 __do_kmalloc_node mm/slab_common.c:967 [inline] __kmalloc_node+0x4d/0xd0 mm/slab_common.c:975 kmalloc_array_node include/linux/slab.h:697 [inline] kcalloc_node include/linux/slab.h:702 [inline] alloc_alien_cache mm/slab.c:651 [inline] setup_kmem_cache_node+0x183/0x400 mm/slab.c:879 setup_kmem_cache_nodes mm/slab.c:3659 [inline] do_tune_cpucache+0x172/0x240 mm/slab.c:3729 enable_cpucache+0x48/0xc0 mm/slab.c:3786 __kmem_cache_create+0x1b5/0x240 mm/slab.c:2074 create_cache mm/slab_common.c:233 [inline] kmem_cache_create_usercopy+0x1bd/0x2c0 mm/slab_common.c:340 kmem_cache_create+0x11/0x20 mm/slab_common.c:395 dm_bio_prison_init_v1+0x26/0x43 drivers/md/dm-bio-prison-v1.c:398 dm_bio_prison_init+0x11/0x53 drivers/md/dm-bio-prison-v1.c:428 do_one_initcall+0x141/0x790 init/main.c:1306 do_initcall_level init/main.c:1379 [inline] do_initcalls init/main.c:1395 [inline] do_basic_setup init/main.c:1414 [inline] kernel_init_freeable+0x6f9/0x782 init/main.c:1634 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1446 [inline] free_pcp_prepare+0x65c/0xc00 mm/page_alloc.c:1496 free_unref_page_prepare mm/page_alloc.c:3369 [inline] free_unref_page_list+0x176/0xcd0 mm/page_alloc.c:3510 release_pages+0xcb1/0x1330 mm/swap.c:1076 tlb_batch_pages_flush+0xa8/0x1a0 mm/mmu_gather.c:97 tlb_flush_mmu_free mm/mmu_gather.c:292 [inline] tlb_flush_mmu mm/mmu_gather.c:299 [inline] tlb_finish_mmu+0x14b/0x7e0 mm/mmu_gather.c:391 exit_mmap+0x202/0x7b0 mm/mmap.c:3100 __mmput+0x128/0x4c0 kernel/fork.c:1207 mmput+0x60/0x70 kernel/fork.c:1229 free_bprm+0x144/0x3e0 fs/exec.c:1488 kernel_execve+0x3fe/0x500 fs/exec.c:2018 call_usermodehelper_exec_async+0x2e7/0x580 kernel/umh.c:113 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 Memory state around the buggy address: ffff8880272d8900: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ffff8880272d8980: 00 01 fc fc fc fc fc fc 00 00 01 fc fc fc fc fc >ffff8880272d8a00: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc ^ ffff8880272d8a80: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ffff8880272d8b00: fa fb fb fb fc fc fc fc 00 00 01 fc fc fc fc fc ==================================================================