================================================================== BUG: KASAN: slab-use-after-free in string_nocheck lib/vsprintf.c:646 [inline] BUG: KASAN: slab-use-after-free in string+0x218/0x2b0 lib/vsprintf.c:728 Read of size 1 at addr ffff8880236c1680 by task udevd/26486 CPU: 1 PID: 26486 Comm: udevd Not tainted 6.8.0-rc6-syzkaller-00194-g17ba56605bfd #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+0x1e7/0x2e0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:377 [inline] print_report+0x167/0x540 mm/kasan/report.c:488 kasan_report+0x142/0x180 mm/kasan/report.c:601 string_nocheck lib/vsprintf.c:646 [inline] string+0x218/0x2b0 lib/vsprintf.c:728 vsnprintf+0x1101/0x1da0 lib/vsprintf.c:2824 add_uevent_var+0x1c8/0x450 lib/kobject_uevent.c:665 dev_uevent+0x3ec/0x900 drivers/base/core.c:2590 uevent_show+0x1a1/0x310 drivers/base/core.c:2661 dev_attr_show+0x55/0xc0 drivers/base/core.c:2364 sysfs_kf_seq_show+0x334/0x4c0 fs/sysfs/file.c:59 seq_read_iter+0x445/0xd60 fs/seq_file.c:230 call_read_iter include/linux/fs.h:2081 [inline] new_sync_read fs/read_write.c:395 [inline] vfs_read+0x978/0xb70 fs/read_write.c:476 ksys_read+0x1a0/0x2c0 fs/read_write.c:619 do_syscall_64+0xf9/0x240 entry_SYSCALL_64_after_hwframe+0x6f/0x77 RIP: 0033:0x7febd1716b6a 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:00007fffe5b83518 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 000056268023cc10 RCX: 00007febd1716b6a RDX: 0000000000001000 RSI: 0000562680243a00 RDI: 0000000000000008 RBP: 000056268023cc10 R08: 0000000000000008 R09: 0000000000000000 R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000003fff R14: 00007fffe5b839f8 R15: 000000000000000a Allocated by task 7973: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:370 [inline] __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:387 kasan_kmalloc include/linux/kasan.h:211 [inline] kmalloc_trace+0x1d6/0x360 mm/slub.c:4012 kmalloc include/linux/slab.h:590 [inline] raw_ioctl_init drivers/usb/gadget/legacy/raw_gadget.c:509 [inline] raw_ioctl+0x1aad/0x3ce0 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+0xfc/0x170 fs/ioctl.c:857 do_syscall_64+0xf9/0x240 entry_SYSCALL_64_after_hwframe+0x6f/0x77 Freed by task 7973: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:589 poison_slab_object+0xa6/0xe0 mm/kasan/common.c:240 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256 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+0x14a/0x380 mm/slub.c:4409 dev_free drivers/usb/gadget/legacy/raw_gadget.c:211 [inline] kref_put+0xb5/0x7c0 include/linux/kref.h:65 raw_release+0x138/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:473 __fput+0x429/0x8a0 fs/file_table.c:376 task_work_run+0x24e/0x310 kernel/task_work.c:180 get_signal+0x1672/0x1850 kernel/signal.c:2669 arch_do_signal_or_restart+0x96/0x860 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+0xc8/0x360 kernel/entry/common.c:212 do_syscall_64+0x108/0x240 arch/x86/entry/common.c:89 entry_SYSCALL_64_after_hwframe+0x6f/0x77 The buggy address belongs to the object at ffff8880236c1680 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of freed 32-byte region [ffff8880236c1680, ffff8880236c16a0) The buggy address belongs to the physical page: page:ffffea00008db040 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x236c1 ksm flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000800 ffff888014c41500 ffffea0001ef7cc0 dead000000000003 raw: 0000000000000000 0000000000400040 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 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 15453, tgid 15450 (syz-executor.3), ts 482943704140, free_ts 482755175131 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x1ea/0x210 mm/page_alloc.c:1533 prep_new_page mm/page_alloc.c:1540 [inline] get_page_from_freelist+0x33ea/0x3580 mm/page_alloc.c:3311 __alloc_pages+0x255/0x680 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+0x5f/0x160 mm/slub.c:2190 allocate_slab mm/slub.c:2354 [inline] new_slab+0x84/0x2f0 mm/slub.c:2407 ___slab_alloc+0xd17/0x13e0 mm/slub.c:3540 __slab_alloc mm/slub.c:3625 [inline] __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_node_track_caller+0x2d1/0x4e0 mm/slub.c:4001 kvasprintf+0xdf/0x190 lib/kasprintf.c:25 kasprintf+0xd5/0x120 lib/kasprintf.c:59 wq_init_lockdep kernel/workqueue.c:3898 [inline] alloc_workqueue+0x560/0x1590 kernel/workqueue.c:4711 tipc_topsrv_work_start net/tipc/topsrv.c:641 [inline] tipc_topsrv_start net/tipc/topsrv.c:679 [inline] tipc_topsrv_init_net+0x345/0x9d0 net/tipc/topsrv.c:725 ops_init+0x352/0x610 net/core/net_namespace.c:136 setup_net+0x4d1/0xbc0 net/core/net_namespace.c:339 copy_net_ns+0x4e3/0x7b0 net/core/net_namespace.c:495 create_new_namespaces+0x425/0x7b0 kernel/nsproxy.c:110 copy_namespaces+0x41a/0x490 kernel/nsproxy.c:179 page last free pid 15456 tgid 15456 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+0x968/0xa90 mm/page_alloc.c:2346 free_unref_page_list+0x5a3/0x850 mm/page_alloc.c:2532 release_pages+0x2744/0x2a80 mm/swap.c:1042 tlb_batch_pages_flush mm/mmu_gather.c:98 [inline] tlb_flush_mmu_free mm/mmu_gather.c:293 [inline] tlb_flush_mmu+0x34c/0x4e0 mm/mmu_gather.c:300 tlb_finish_mmu+0xd4/0x200 mm/mmu_gather.c:392 exit_mmap+0x4b6/0xd40 mm/mmap.c:3292 __mmput+0x115/0x3c0 kernel/fork.c:1343 exit_mm+0x21f/0x310 kernel/exit.c:569 do_exit+0x9af/0x2740 kernel/exit.c:858 __do_sys_exit kernel/exit.c:987 [inline] __se_sys_exit kernel/exit.c:985 [inline] __pfx___ia32_sys_exit+0x0/0x10 kernel/exit.c:985 do_syscall_64+0xf9/0x240 entry_SYSCALL_64_after_hwframe+0x6f/0x77 Memory state around the buggy address: ffff8880236c1580: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc ffff8880236c1600: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc >ffff8880236c1680: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc ^ ffff8880236c1700: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc ffff8880236c1780: fa fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc ==================================================================