================================================================== BUG: KASAN: slab-use-after-free in string_nocheck lib/vsprintf.c:644 [inline] BUG: KASAN: slab-use-after-free in string+0x39c/0x3d0 lib/vsprintf.c:726 Read of size 1 at addr ffff88802af9b340 by task udevd/4444 CPU: 1 PID: 4444 Comm: udevd Not tainted 6.4.0-rc2-syzkaller-00015-g1b66c114d161 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106 print_address_description.constprop.0+0x2c/0x3c0 mm/kasan/report.c:351 print_report mm/kasan/report.c:462 [inline] kasan_report+0x11c/0x130 mm/kasan/report.c:572 string_nocheck lib/vsprintf.c:644 [inline] string+0x39c/0x3d0 lib/vsprintf.c:726 vsnprintf+0xa36/0x1710 lib/vsprintf.c:2817 add_uevent_var+0x161/0x390 lib/kobject_uevent.c:665 dev_uevent+0x191/0x780 drivers/base/core.c:2575 uevent_show+0x1bc/0x380 drivers/base/core.c:2646 dev_attr_show+0x4f/0xd0 drivers/base/core.c:2349 sysfs_kf_seq_show+0x21d/0x430 fs/sysfs/file.c:59 seq_read_iter+0x4f9/0x12d0 fs/seq_file.c:230 kernfs_fop_read_iter+0x4ce/0x690 fs/kernfs/file.c:279 call_read_iter include/linux/fs.h:1862 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x4b1/0x8a0 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:0x7fac30516b6a 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:00007ffdfb9fd8b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 00005580f5914f30 RCX: 00007fac30516b6a RDX: 0000000000001000 RSI: 00005580f5904a00 RDI: 000000000000000c RBP: 00005580f5914f30 R08: 000000000000000c R09: 0000000000400000 R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000003fff R14: 00007ffdfb9fdd98 R15: 000000000000000a Allocated by task 24675: 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:374 [inline] ____kasan_kmalloc mm/kasan/common.c:333 [inline] __kasan_kmalloc+0xa3/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:559 [inline] raw_ioctl_init+0x152/0x830 drivers/usb/gadget/legacy/raw_gadget.c:460 raw_ioctl+0xbf5/0x2a60 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 24675: 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:521 ____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:162 [inline] __cache_free mm/slab.c:3389 [inline] __do_kmem_cache_free mm/slab.c:3576 [inline] __kmem_cache_free+0xcd/0x2c0 mm/slab.c:3583 dev_free+0x9a/0x700 drivers/usb/gadget/legacy/raw_gadget.c:210 kref_put include/linux/kref.h:65 [inline] raw_release+0x21d/0x2d0 drivers/usb/gadget/legacy/raw_gadget.c:424 __fput+0x27c/0xa90 fs/file_table.c:321 task_work_run+0x16f/0x270 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xad3/0x2960 kernel/exit.c:871 do_group_exit+0xd4/0x2a0 kernel/exit.c:1021 get_signal+0x2315/0x25b0 kernel/signal.c:2874 arch_do_signal_or_restart+0x79/0x5c0 arch/x86/kernel/signal.c:306 exit_to_user_mode_loop kernel/entry/common.c:168 [inline] exit_to_user_mode_prepare+0x11f/0x240 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline] syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:297 do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd Last potentially related work creation: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 __kasan_record_aux_stack+0x7b/0x90 mm/kasan/generic.c:491 kvfree_call_rcu+0x70/0xad0 kernel/rcu/tree.c:3332 key_put_tag security/keys/keyring.c:241 [inline] key_put_tag+0x8a/0xc0 security/keys/keyring.c:238 key_remove_domain+0x40/0x70 security/keys/keyring.c:259 copy_net_ns+0x708/0x8e0 net/core/net_namespace.c:498 create_new_namespaces+0x3f6/0xb20 kernel/nsproxy.c:110 copy_namespaces+0x410/0x500 kernel/nsproxy.c:179 copy_process+0x322a/0x7600 kernel/fork.c:2510 kernel_clone+0xeb/0x890 kernel/fork.c:2918 __do_sys_clone+0xba/0x100 kernel/fork.c:3061 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 The buggy address belongs to the object at ffff88802af9b340 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of freed 32-byte region [ffff88802af9b340, ffff88802af9b360) The buggy address belongs to the physical page: page:ffffea0000abe6c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88802af9bfc1 pfn:0x2af9b flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0x3f() raw: 00fff00000000200 ffff888012440100 ffffea0000906ad0 ffffea00009c9810 raw: ffff88802af9bfc1 ffff88802af9b000 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 0x342020(__GFP_HIGH|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE), pid 14881, tgid 14862 (syz-executor.4), ts 1283648561036, free_ts 1274097299539 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x2db/0x350 mm/page_alloc.c:1731 prep_new_page mm/page_alloc.c:1738 [inline] get_page_from_freelist+0xf41/0x2c00 mm/page_alloc.c:3502 __alloc_pages+0x1cb/0x4a0 mm/page_alloc.c:4768 __alloc_pages_node include/linux/gfp.h:237 [inline] kmem_getpages mm/slab.c:1360 [inline] cache_grow_begin+0x9b/0x3b0 mm/slab.c:2569 cache_alloc_refill+0x27f/0x380 mm/slab.c:2942 ____cache_alloc mm/slab.c:3018 [inline] ____cache_alloc mm/slab.c:3001 [inline] __do_cache_alloc mm/slab.c:3201 [inline] slab_alloc_node mm/slab.c:3249 [inline] __kmem_cache_alloc_node+0x360/0x3f0 mm/slab.c:3540 __do_kmalloc_node mm/slab_common.c:965 [inline] __kmalloc_node_track_caller+0x4f/0x1a0 mm/slab_common.c:986 kstrdup+0x3f/0x70 mm/util.c:62 security_netlbl_sid_to_secattr+0x1cc/0x4c0 security/selinux/ss/services.c:3903 selinux_netlbl_sock_genattr+0xe9/0x4a0 security/selinux/netlabel.c:80 selinux_netlbl_socket_post_create+0x77/0x160 security/selinux/netlabel.c:397 selinux_socket_post_create+0x2ec/0x7f0 security/selinux/hooks.c:4538 security_socket_post_create+0x68/0xc0 security/security.c:4107 __sock_create+0x6f6/0x850 net/socket.c:1563 sock_create net/socket.c:1598 [inline] __sys_socket_create net/socket.c:1635 [inline] __sys_socket_create net/socket.c:1620 [inline] __sys_socket+0x133/0x250 net/socket.c:1663 __do_sys_socket net/socket.c:1676 [inline] __se_sys_socket net/socket.c:1674 [inline] __x64_sys_socket+0x73/0xb0 net/socket.c:1674 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1302 [inline] free_unref_page_prepare+0x62e/0xcb0 mm/page_alloc.c:2564 free_unref_page+0x33/0x370 mm/page_alloc.c:2659 kasan_depopulate_vmalloc_pte+0x60/0x80 mm/kasan/shadow.c:427 apply_to_pte_range mm/memory.c:2584 [inline] apply_to_pmd_range mm/memory.c:2628 [inline] apply_to_pud_range mm/memory.c:2664 [inline] apply_to_p4d_range mm/memory.c:2700 [inline] __apply_to_page_range+0x68c/0x1030 mm/memory.c:2734 kasan_release_vmalloc+0xab/0xc0 mm/kasan/shadow.c:544 __purge_vmap_area_lazy+0x886/0x1e60 mm/vmalloc.c:1771 _vm_unmap_aliases.part.0+0x78/0x550 mm/vmalloc.c:2262 _vm_unmap_aliases mm/vmalloc.c:2236 [inline] vm_unmap_aliases+0x49/0x50 mm/vmalloc.c:2285 change_page_attr_set_clr+0x226/0x470 arch/x86/mm/pat/set_memory.c:1837 change_page_attr_clear arch/x86/mm/pat/set_memory.c:1885 [inline] set_memory_ro+0x7c/0xa0 arch/x86/mm/pat/set_memory.c:2076 bpf_prog_lock_ro include/linux/filter.h:855 [inline] bpf_prog_select_runtime+0x508/0x650 kernel/bpf/core.c:2217 bpf_prog_load+0x1707/0x21e0 kernel/bpf/syscall.c:2652 __sys_bpf+0x14a3/0x53d0 kernel/bpf/syscall.c:5058 __do_sys_bpf kernel/bpf/syscall.c:5162 [inline] __se_sys_bpf kernel/bpf/syscall.c:5160 [inline] __x64_sys_bpf+0x79/0xc0 kernel/bpf/syscall.c:5160 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: ffff88802af9b200: 00 00 00 fc fc fc fc fc fa fb fb fb fc fc fc fc ffff88802af9b280: 00 00 fc fc fc fc fc fc 00 00 00 00 fc fc fc fc >ffff88802af9b300: 00 00 00 fc fc fc fc fc fa fb fb fb fc fc fc fc ^ ffff88802af9b380: 00 00 00 00 fc fc fc fc 00 fc fc fc fc fc fc fc ffff88802af9b400: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc ==================================================================