================================================================== BUG: KASAN: use-after-free in string_nocheck lib/vsprintf.c:643 [inline] BUG: KASAN: use-after-free in string+0x39c/0x3d0 lib/vsprintf.c:725 Read of size 1 at addr ffff8880265be840 by task udevd/2995 CPU: 0 PID: 2995 Comm: udevd Not tainted 6.1.0-rc7-syzkaller-00123-ga4412fdd49dc #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 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:284 [inline] print_report+0x15e/0x461 mm/kasan/report.c:395 kasan_report+0xbf/0x1f0 mm/kasan/report.c:495 string_nocheck lib/vsprintf.c:643 [inline] string+0x39c/0x3d0 lib/vsprintf.c:725 vsnprintf+0xa11/0x16b0 lib/vsprintf.c:2800 add_uevent_var+0x161/0x390 lib/kobject_uevent.c:665 dev_uevent+0x191/0x780 drivers/base/core.c:2421 uevent_show+0x1bc/0x380 drivers/base/core.c:2492 dev_attr_show+0x4f/0x90 drivers/base/core.c:2195 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+0x546/0x7a0 fs/kernfs/file.c:275 call_read_iter include/linux/fs.h:2193 [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:0x7fb59af258fe 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:00007fffcd5f2c08 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 0000558da9f14070 RCX: 00007fb59af258fe RDX: 0000000000001000 RSI: 0000558da9f41c70 RDI: 000000000000000c RBP: 00007fb59aff2380 R08: 000000000000000c R09: 00007fb59aff5a60 R10: 0000000000000008 R11: 0000000000000246 R12: 0000558da9f14070 R13: 0000000000000d68 R14: 00007fb59aff1780 R15: 0000000000000d68 Allocated by task 15315: 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:371 [inline] ____kasan_kmalloc mm/kasan/common.c:330 [inline] __kasan_kmalloc+0xa3/0xb0 mm/kasan/common.c:380 kmalloc include/linux/slab.h:553 [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 15315: 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:511 ____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:3389 [inline] __do_kmem_cache_free mm/slab.c:3585 [inline] __kmem_cache_free+0xcd/0x3b0 mm/slab.c:3592 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+0xb3d/0x2a30 kernel/exit.c:820 do_group_exit+0xd4/0x2a0 kernel/exit.c:950 get_signal+0x21b1/0x2440 kernel/signal.c:2858 arch_do_signal_or_restart+0x86/0x2300 arch/x86/kernel/signal.c:869 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 ffff8880265be840 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of 32-byte region [ffff8880265be840, ffff8880265be860) The buggy address belongs to the physical page: page:ffffea0000996f80 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880265befc1 pfn:0x265be flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffffea0001f977c8 ffffea0001d227c8 ffff888012040100 raw: ffff8880265befc1 ffff8880265be000 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 0x3420c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE), pid 9970, tgid 9962 (syz-executor.2), ts 809030412072, free_ts 808890572749 prep_new_page mm/page_alloc.c:2539 [inline] get_page_from_freelist+0x10b5/0x2d50 mm/page_alloc.c:4291 __alloc_pages+0x1cb/0x5b0 mm/page_alloc.c:5558 __alloc_pages_node include/linux/gfp.h:223 [inline] kmem_getpages mm/slab.c:1363 [inline] cache_grow_begin+0x75/0x360 mm/slab.c:2570 cache_alloc_refill+0x27f/0x380 mm/slab.c:2943 ____cache_alloc mm/slab.c:3019 [inline] ____cache_alloc mm/slab.c:3002 [inline] __do_cache_alloc mm/slab.c:3202 [inline] slab_alloc_node mm/slab.c:3250 [inline] __kmem_cache_alloc_node+0x44a/0x510 mm/slab.c:3549 __do_kmalloc_node mm/slab_common.c:954 [inline] __kmalloc_node_track_caller+0x4b/0xc0 mm/slab_common.c:975 kmemdup+0x2c/0x60 mm/util.c:129 kmemdup include/linux/fortify-string.h:585 [inline] ip6_rthdr_dup net/ipv6/ip6_output.c:1345 [inline] ip6_setup_cork+0x734/0x1490 net/ipv6/ip6_output.c:1412 ip6_make_skb+0x1f0/0x510 net/ipv6/ip6_output.c:2037 udpv6_sendmsg+0x2099/0x2c80 net/ipv6/udp.c:1572 inet6_sendmsg+0x9d/0xe0 net/ipv6/af_inet6.c:665 sock_sendmsg_nosec net/socket.c:714 [inline] sock_sendmsg+0xd3/0x120 net/socket.c:734 ____sys_sendmsg+0x334/0x8c0 net/socket.c:2482 ___sys_sendmsg+0x110/0x1b0 net/socket.c:2536 __sys_sendmmsg+0x18f/0x460 net/socket.c:2622 __do_sys_sendmmsg net/socket.c:2651 [inline] __se_sys_sendmmsg net/socket.c:2648 [inline] __x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2648 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1459 [inline] free_pcp_prepare+0x65c/0xd90 mm/page_alloc.c:1509 free_unref_page_prepare mm/page_alloc.c:3387 [inline] free_unref_page+0x1d/0x4d0 mm/page_alloc.c:3483 tlb_batch_list_free mm/mmu_gather.c:75 [inline] tlb_finish_mmu+0x1a7/0x7e0 mm/mmu_gather.c:366 exit_mmap+0x202/0x7b0 mm/mmap.c:3105 __mmput+0x128/0x4c0 kernel/fork.c:1185 mmput+0x60/0x70 kernel/fork.c:1207 copy_process+0x3161/0x7190 kernel/fork.c:2518 kernel_clone+0xeb/0x980 kernel/fork.c:2671 __do_sys_clone+0xba/0x100 kernel/fork.c:2812 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 Memory state around the buggy address: ffff8880265be700: 00 00 00 00 fc fc fc fc 00 fc fc fc fc fc fc fc ffff8880265be780: 00 00 00 00 fc fc fc fc 00 00 00 fc fc fc fc fc >ffff8880265be800: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc ^ ffff8880265be880: fa fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc ffff8880265be900: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc ==================================================================