================================================================== 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 ffff88807dbc8500 by task udevd/2972 CPU: 0 PID: 2972 Comm: udevd Not tainted 6.0.0-rc6-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:317 [inline] print_report.cold+0x2ba/0x719 mm/kasan/report.c:433 kasan_report+0xb1/0x1e0 mm/kasan/report.c:495 string_nocheck lib/vsprintf.c:643 [inline] string+0x39c/0x3d0 lib/vsprintf.c:725 vsnprintf+0x71b/0x14f0 lib/vsprintf.c:2782 add_uevent_var+0x15d/0x380 lib/kobject_uevent.c:665 dev_uevent+0x18d/0x770 drivers/base/core.c:2421 uevent_show+0x1b8/0x380 drivers/base/core.c:2492 dev_attr_show+0x4b/0x90 drivers/base/core.c:2195 sysfs_kf_seq_show+0x219/0x3d0 fs/sysfs/file.c:59 kernfs_seq_show+0x169/0x1e0 fs/kernfs/file.c:217 seq_read_iter+0x4f5/0x1280 fs/seq_file.c:230 kernfs_fop_read_iter+0x523/0x710 fs/kernfs/file.c:299 call_read_iter include/linux/fs.h:2181 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x67d/0x930 fs/read_write.c:470 ksys_read+0x127/0x250 fs/read_write.c:607 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fbf65b258fe 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:00007ffe7dce4928 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 0000560b5d91fe20 RCX: 00007fbf65b258fe RDX: 0000000000001000 RSI: 0000560b5d93e820 RDI: 000000000000000c RBP: 00007fbf65bf2380 R08: 000000000000000c R09: 00007fbf65bf5a60 R10: 0000000001000000 R11: 0000000000000246 R12: 0000560b5d91fe20 R13: 0000000000000d68 R14: 00007fbf65bf1780 R15: 0000000000000d68 Allocated by task 7384: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:45 [inline] set_alloc_info mm/kasan/common.c:437 [inline] ____kasan_kmalloc mm/kasan/common.c:516 [inline] ____kasan_kmalloc mm/kasan/common.c:475 [inline] __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:525 kmalloc include/linux/slab.h:600 [inline] raw_ioctl_init+0x152/0x820 drivers/usb/gadget/legacy/raw_gadget.c:460 raw_ioctl+0x8ef/0x2740 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+0x193/0x200 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 7386: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track+0x21/0x30 mm/kasan/common.c:45 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370 ____kasan_slab_free mm/kasan/common.c:367 [inline] ____kasan_slab_free+0x166/0x1c0 mm/kasan/common.c:329 kasan_slab_free include/linux/kasan.h:200 [inline] slab_free_hook mm/slub.c:1754 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1780 slab_free mm/slub.c:3534 [inline] kfree+0xe2/0x580 mm/slub.c:4562 dev_free+0x9a/0x700 drivers/usb/gadget/legacy/raw_gadget.c:210 kref_put include/linux/kref.h:65 [inline] raw_release+0x219/0x290 drivers/usb/gadget/legacy/raw_gadget.c:424 __fput+0x277/0x9d0 fs/file_table.c:320 task_work_run+0xdd/0x1a0 kernel/task_work.c:177 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xad5/0x29b0 kernel/exit.c:795 do_group_exit+0xd2/0x2f0 kernel/exit.c:925 get_signal+0x238c/0x2610 kernel/signal.c:2857 arch_do_signal_or_restart+0x82/0x2300 arch/x86/kernel/signal.c:869 exit_to_user_mode_loop kernel/entry/common.c:166 [inline] exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:201 __syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline] syscall_exit_to_user_mode+0x19/0x50 kernel/entry/common.c:294 ret_from_fork+0x15/0x30 arch/x86/entry/entry_64.S:299 The buggy address belongs to the object at ffff88807dbc8500 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of 32-byte region [ffff88807dbc8500, ffff88807dbc8520) The buggy address belongs to the physical page: page:ffffea0001f6f200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7dbc8 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 dead000000000100 dead000000000122 ffff888011841500 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 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 3659, tgid 3659 (syz-executor.5), ts 221108801976, free_ts 221077333793 prep_new_page mm/page_alloc.c:2532 [inline] get_page_from_freelist+0x109b/0x2ce0 mm/page_alloc.c:4283 __alloc_pages+0x1c7/0x510 mm/page_alloc.c:5515 alloc_pages+0x1a6/0x270 mm/mempolicy.c:2270 alloc_slab_page mm/slub.c:1824 [inline] allocate_slab+0x27e/0x3d0 mm/slub.c:1969 new_slab mm/slub.c:2029 [inline] ___slab_alloc+0x7f1/0xe10 mm/slub.c:3031 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3118 slab_alloc_node mm/slub.c:3209 [inline] slab_alloc mm/slub.c:3251 [inline] kmem_cache_alloc_trace+0x323/0x3e0 mm/slub.c:3282 kmalloc include/linux/slab.h:600 [inline] kzalloc include/linux/slab.h:733 [inline] ref_tracker_alloc+0x14c/0x550 lib/ref_tracker.c:85 __netdev_tracker_alloc include/linux/netdevice.h:3974 [inline] netdev_tracker_alloc include/linux/netdevice.h:3986 [inline] fib6_nh_init+0x5c6/0x1be0 net/ipv6/route.c:3621 ip6_route_info_create+0x125b/0x1aa0 net/ipv6/route.c:3799 addrconf_f6i_alloc+0x37d/0x620 net/ipv6/route.c:4571 ipv6_add_addr+0x395/0x1de0 net/ipv6/addrconf.c:1105 inet6_addr_add+0x412/0xae0 net/ipv6/addrconf.c:2969 inet6_rtm_newaddr+0xfa4/0x1a60 net/ipv6/addrconf.c:4927 rtnetlink_rcv_msg+0x43a/0xca0 net/core/rtnetlink.c:6090 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2501 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1449 [inline] free_pcp_prepare+0x5e4/0xd20 mm/page_alloc.c:1499 free_unref_page_prepare mm/page_alloc.c:3380 [inline] free_unref_page+0x19/0x4d0 mm/page_alloc.c:3476 __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2548 qlink_free mm/kasan/quarantine.c:168 [inline] qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0xa2/0xc0 mm/kasan/common.c:447 kasan_slab_alloc include/linux/kasan.h:224 [inline] slab_post_alloc_hook mm/slab.h:727 [inline] slab_alloc_node mm/slub.c:3243 [inline] slab_alloc mm/slub.c:3251 [inline] __kmem_cache_alloc_lru mm/slub.c:3258 [inline] kmem_cache_alloc_lru+0x255/0x720 mm/slub.c:3275 alloc_inode_sb include/linux/fs.h:3103 [inline] sock_alloc_inode+0x23/0x1d0 net/socket.c:304 alloc_inode+0x61/0x230 fs/inode.c:260 new_inode_pseudo+0x13/0x80 fs/inode.c:1019 sock_alloc+0x3c/0x260 net/socket.c:627 __sock_create+0xb9/0x790 net/socket.c:1479 sock_create net/socket.c:1566 [inline] __sys_socket_create net/socket.c:1603 [inline] __sys_socket_create net/socket.c:1588 [inline] __sys_socket+0x12f/0x240 net/socket.c:1636 __do_sys_socket net/socket.c:1649 [inline] __se_sys_socket net/socket.c:1647 [inline] __x64_sys_socket+0x6f/0xb0 net/socket.c:1647 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Memory state around the buggy address: ffff88807dbc8400: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ffff88807dbc8480: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc >ffff88807dbc8500: fa fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc ^ ffff88807dbc8580: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ffff88807dbc8600: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ==================================================================