================================================================== 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 ffff88807e84ad00 by task udevd/6635 CPU: 1 PID: 6635 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:0x7f591ab258fe 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:00007ffea88bfa98 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 000055abc37c0360 RCX: 00007f591ab258fe RDX: 0000000000001000 RSI: 000055abc37ce0b0 RDI: 0000000000000008 RBP: 00007f591abf2380 R08: 0000000000000008 R09: 00007f591abf5a60 R10: 0000000000000400 R11: 0000000000000246 R12: 000055abc37c0360 R13: 0000000000000d68 R14: 00007f591abf1780 R15: 0000000000000d68 Allocated by task 7009: 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 7009: 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 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd Last potentially related work creation: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348 kvfree_call_rcu+0x74/0x940 kernel/rcu/tree.c:3322 dropmon_net_event+0xbd/0x310 net/core/drop_monitor.c:1580 notifier_call_chain+0xb5/0x200 kernel/notifier.c:87 call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1945 call_netdevice_notifiers_extack net/core/dev.c:1983 [inline] call_netdevice_notifiers net/core/dev.c:1997 [inline] unregister_netdevice_many+0xa62/0x1980 net/core/dev.c:10862 vti6_exit_batch_net+0x3a0/0x670 net/ipv6/ip6_vti.c:1190 ops_exit_list+0x125/0x170 net/core/net_namespace.c:168 cleanup_net+0x4ea/0xb00 net/core/net_namespace.c:595 process_one_work+0x991/0x1610 kernel/workqueue.c:2289 worker_thread+0x665/0x1080 kernel/workqueue.c:2436 kthread+0x2e4/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306 The buggy address belongs to the object at ffff88807e84ad00 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of 32-byte region [ffff88807e84ad00, ffff88807e84ad20) The buggy address belongs to the physical page: page:ffffea0001fa1280 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7e84a flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffffea0001d0bc80 dead000000000004 ffff888011841500 raw: 0000000000000000 0000000080400040 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 3643, tgid 3643 (syz-executor.1), ts 402398161821, free_ts 402393151799 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 netns_tracker_alloc include/net/net_namespace.h:327 [inline] get_net_track include/net/net_namespace.h:343 [inline] sk_alloc+0x1fe/0x770 net/core/sock.c:2041 inet_create net/ipv4/af_inet.c:319 [inline] inet_create+0x395/0xea0 net/ipv4/af_inet.c:245 __sock_create+0x355/0x790 net/socket.c:1515 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 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 __vunmap+0x85d/0xd30 mm/vmalloc.c:2696 __vfree+0x3c/0xd0 mm/vmalloc.c:2744 vfree+0x5a/0x90 mm/vmalloc.c:2775 copy_entries_to_user net/ipv4/netfilter/ip_tables.c:868 [inline] get_entries net/ipv4/netfilter/ip_tables.c:1024 [inline] do_ipt_get_ctl+0x7fe/0x9d0 net/ipv4/netfilter/ip_tables.c:1663 nf_getsockopt+0x72/0xd0 net/netfilter/nf_sockopt.c:116 ip_getsockopt net/ipv4/ip_sockglue.c:1786 [inline] ip_getsockopt+0x164/0x1c0 net/ipv4/ip_sockglue.c:1765 tcp_getsockopt+0x86/0xd0 net/ipv4/tcp.c:4388 __sys_getsockopt+0x216/0x690 net/socket.c:2296 __do_sys_getsockopt net/socket.c:2311 [inline] __se_sys_getsockopt net/socket.c:2308 [inline] __x64_sys_getsockopt+0xba/0x150 net/socket.c:2308 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: ffff88807e84ac00: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc ffff88807e84ac80: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc >ffff88807e84ad00: fa fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc ^ ffff88807e84ad80: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ffff88807e84ae00: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ==================================================================