================================================================== BUG: KASAN: use-after-free in string_nocheck lib/vsprintf.c:643 [inline] BUG: KASAN: use-after-free in string+0x218/0x2a0 lib/vsprintf.c:725 Read of size 1 at addr ffff888129ede000 by task udevd/3334 CPU: 1 PID: 3334 Comm: udevd Not tainted 6.1.25-syzkaller-00045-g52824b718cd0 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/04/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:316 [inline] print_report+0x158/0x4e0 mm/kasan/report.c:427 kasan_report+0x13c/0x170 mm/kasan/report.c:531 __asan_report_load1_noabort+0x14/0x20 mm/kasan/report_generic.c:348 string_nocheck lib/vsprintf.c:643 [inline] string+0x218/0x2a0 lib/vsprintf.c:725 vsnprintf+0x11fc/0x1c70 lib/vsprintf.c:2800 add_uevent_var+0x1c0/0x440 lib/kobject_uevent.c:665 dev_uevent+0x3ee/0x6f0 drivers/base/core.c:2568 uevent_show+0x192/0x310 drivers/base/core.c:2639 dev_attr_show+0x56/0xd0 drivers/base/core.c:2342 sysfs_kf_seq_show+0x27c/0x3a0 fs/sysfs/file.c:59 kernfs_seq_show+0x119/0x160 fs/kernfs/file.c:201 seq_read_iter+0x430/0xd00 fs/seq_file.c:230 kernfs_fop_read_iter+0x145/0x470 fs/kernfs/file.c:275 call_read_iter include/linux/fs.h:2209 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x771/0xad0 fs/read_write.c:470 ksys_read+0x199/0x2c0 fs/read_write.c:613 __do_sys_read fs/read_write.c:623 [inline] __se_sys_read fs/read_write.c:621 [inline] __x64_sys_read+0x7b/0x90 fs/read_write.c:621 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fc4acd16b6a 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:00007ffd2870b098 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 0000562274b12770 RCX: 00007fc4acd16b6a RDX: 0000000000001000 RSI: 0000562274b25550 RDI: 0000000000000008 RBP: 0000562274b12770 R08: 0000000000000008 R09: 0000000000000010 R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000003fff R14: 00007ffd2870b578 R15: 000000000000000a Allocated by task 12035: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:52 kasan_save_alloc_info+0x1f/0x30 mm/kasan/generic.c:505 ____kasan_kmalloc mm/kasan/common.c:379 [inline] __kasan_kmalloc+0x9c/0xb0 mm/kasan/common.c:388 kasan_kmalloc include/linux/kasan.h:212 [inline] kmalloc_trace+0x44/0xa0 mm/slab_common.c:1052 kmalloc include/linux/slab.h:553 [inline] raw_ioctl_init drivers/usb/gadget/legacy/raw_gadget.c:460 [inline] raw_ioctl+0x1a2d/0x3620 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+0x114/0x190 fs/ioctl.c:856 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 12026: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:516 ____kasan_slab_free+0x131/0x180 mm/kasan/common.c:241 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:249 kasan_slab_free include/linux/kasan.h:178 [inline] slab_free_hook mm/slub.c:1744 [inline] slab_free_freelist_hook mm/slub.c:1770 [inline] slab_free mm/slub.c:3681 [inline] __kmem_cache_free+0x218/0x3b0 mm/slub.c:3694 kfree+0x7a/0xf0 mm/slab_common.c:1009 dev_free drivers/usb/gadget/legacy/raw_gadget.c:210 [inline] kref_put+0xb6/0x7c0 include/linux/kref.h:65 raw_release+0x145/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:424 __fput+0x3ab/0x870 fs/file_table.c:320 ____fput+0x15/0x20 fs/file_table.c:348 task_work_run+0x24d/0x2e0 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xbd5/0x2b80 kernel/exit.c:875 do_group_exit+0x21a/0x2d0 kernel/exit.c:1025 get_signal+0x169d/0x1820 kernel/signal.c:2875 arch_do_signal_or_restart+0xb0/0x16f0 arch/x86/kernel/signal.c:869 exit_to_user_mode_loop+0x6b/0xa0 kernel/entry/common.c:168 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline] syscall_exit_to_user_mode+0x26/0x130 kernel/entry/common.c:297 do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff888129ede000 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of 32-byte region [ffff888129ede000, ffff888129ede020) The buggy address belongs to the physical page: page:ffffea0004a7b780 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x129ede flags: 0x4000000000000200(slab|zone=1) raw: 4000000000000200 ffffea0004ad4c00 dead000000000002 ffff888100042600 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 438, tgid 438 (syz-executor.5), ts 319826047723, free_ts 319824943000 set_page_owner include/linux/page_owner.h:33 [inline] post_alloc_hook+0x213/0x220 mm/page_alloc.c:2582 prep_new_page+0x1b/0x110 mm/page_alloc.c:2589 get_page_from_freelist+0x2762/0x27f0 mm/page_alloc.c:4387 __alloc_pages+0x3a1/0x780 mm/page_alloc.c:5664 allocate_slab mm/slub.c:1959 [inline] new_slab+0xce/0x4c0 mm/slub.c:2012 ___slab_alloc+0x6f9/0xb80 mm/slub.c:3200 __slab_alloc+0x5d/0xa0 mm/slub.c:3299 slab_alloc_node mm/slub.c:3384 [inline] __kmem_cache_alloc_node+0x1af/0x250 mm/slub.c:3457 kmalloc_trace+0x2a/0xa0 mm/slab_common.c:1047 kmalloc include/linux/slab.h:553 [inline] kzalloc include/linux/slab.h:689 [inline] ref_tracker_alloc+0x138/0x450 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+0x1c2/0x440 net/core/sock.c:2103 inet6_create+0x6b6/0x10c0 net/ipv6/af_inet6.c:192 __sock_create+0x3a6/0x760 net/socket.c:1520 sock_create net/socket.c:1571 [inline] __sys_socket_create net/socket.c:1608 [inline] __sys_socket+0x136/0x3a0 net/socket.c:1636 __do_sys_socket net/socket.c:1649 [inline] __se_sys_socket net/socket.c:1647 [inline] __x64_sys_socket+0x7a/0x90 net/socket.c:1647 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 page last free stack trace: reset_page_owner include/linux/page_owner.h:26 [inline] free_pages_prepare mm/page_alloc.c:1494 [inline] free_pcp_prepare mm/page_alloc.c:1568 [inline] free_unref_page_prepare+0x83d/0x850 mm/page_alloc.c:3486 free_unref_page+0x8d/0x480 mm/page_alloc.c:3582 free_the_page mm/page_alloc.c:794 [inline] __free_pages+0x61/0xf0 mm/page_alloc.c:5753 __vunmap+0x9f3/0xb60 mm/vmalloc.c:2728 __vfree mm/vmalloc.c:2776 [inline] vfree+0x5c/0x80 mm/vmalloc.c:2807 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+0x11dc/0x1840 net/ipv4/netfilter/ip_tables.c:1662 nf_getsockopt+0x26c/0x290 net/netfilter/nf_sockopt.c:116 ip_getsockopt+0x1dd/0x290 net/ipv4/ip_sockglue.c:1824 tcp_getsockopt+0x15c/0x1c0 net/ipv4/tcp.c:4400 sock_common_getsockopt+0x99/0xb0 net/core/sock.c:3641 __sys_getsockopt+0x290/0x560 net/socket.c:2296 __do_sys_getsockopt net/socket.c:2311 [inline] __se_sys_getsockopt net/socket.c:2308 [inline] __x64_sys_getsockopt+0xbf/0xd0 net/socket.c:2308 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Memory state around the buggy address: ffff888129eddf00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff888129eddf80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff888129ede000: fa fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc ^ ffff888129ede080: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ffff888129ede100: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc ==================================================================