================================================================== 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 ffff88811ca4a88a by task udevd/21273 CPU: 1 PID: 21273 Comm: udevd Not tainted 6.1.25-syzkaller-00010-g0a2e9dd65c6b #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/03/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:284 [inline] print_report+0x158/0x4e0 mm/kasan/report.c:395 kasan_report+0x13c/0x170 mm/kasan/report.c:495 __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:0x7f2784916b6a 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:00007fff6e1d5158 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 0000562b2ec81d50 RCX: 00007f2784916b6a RDX: 0000000000001000 RSI: 0000562b2ec9a6c0 RDI: 0000000000000008 RBP: 0000562b2ec81d50 R08: 0000000000000008 R09: 0000000000000010 R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000003fff R14: 00007fff6e1d5638 R15: 000000000000000a Allocated by task 1445: 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 1445: 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+0xbc5/0x2a40 kernel/exit.c:872 do_group_exit+0x21a/0x2d0 kernel/exit.c:1022 get_signal+0x169d/0x1820 kernel/signal.c:2861 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 ffff88811ca4a880 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 10 bytes inside of 32-byte region [ffff88811ca4a880, ffff88811ca4a8a0) The buggy address belongs to the physical page: page:ffffea0004729280 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11ca4a flags: 0x4000000000000200(slab|zone=1) raw: 4000000000000200 0000000000000000 dead000000000001 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 677, tgid 667 (syz-executor.2), ts 356175852069, free_ts 326401161883 set_page_owner include/linux/page_owner.h:33 [inline] post_alloc_hook+0x213/0x220 mm/page_alloc.c:2581 prep_new_page mm/page_alloc.c:2588 [inline] get_page_from_freelist+0x276c/0x2850 mm/page_alloc.c:4385 __alloc_pages+0x3a1/0x780 mm/page_alloc.c:5662 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] tty_alloc_file drivers/tty/tty_io.c:185 [inline] tty_open+0xba2/0x11a0 drivers/tty/tty_io.c:2122 chrdev_open+0x4f7/0x620 fs/char_dev.c:414 do_dentry_open+0x891/0x1250 fs/open.c:884 vfs_open+0x73/0x80 fs/open.c:1015 do_open fs/namei.c:3557 [inline] path_openat+0x2532/0x2d60 fs/namei.c:3714 do_filp_open+0x230/0x480 fs/namei.c:3741 do_sys_openat2+0x13f/0x850 fs/open.c:1333 do_sys_open fs/open.c:1349 [inline] __do_sys_openat fs/open.c:1365 [inline] __se_sys_openat fs/open.c:1360 [inline] __x64_sys_openat+0x243/0x290 fs/open.c:1360 page last free stack trace: reset_page_owner include/linux/page_owner.h:26 [inline] free_pages_prepare mm/page_alloc.c:1493 [inline] free_pcp_prepare mm/page_alloc.c:1567 [inline] free_unref_page_prepare+0x83d/0x850 mm/page_alloc.c:3484 free_unref_page+0x8d/0x480 mm/page_alloc.c:3580 free_the_page mm/page_alloc.c:793 [inline] __free_pages+0x61/0xf0 mm/page_alloc.c:5751 __free_slab+0xce/0x1a0 mm/slub.c:2036 free_slab mm/slub.c:2051 [inline] discard_slab mm/slub.c:2057 [inline] __unfreeze_partials+0x165/0x1a0 mm/slub.c:2606 put_cpu_partial+0xa9/0x100 mm/slub.c:2682 __slab_free+0x1c8/0x280 mm/slub.c:3558 do_slab_free mm/slub.c:3635 [inline] ___cache_free+0xc6/0xd0 mm/slub.c:3688 qlink_free+0x4d/0x90 mm/kasan/quarantine.c:168 qlist_free_all+0x52/0xc0 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x15a/0x180 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0x24/0x80 mm/kasan/common.c:310 kasan_slab_alloc include/linux/kasan.h:202 [inline] slab_post_alloc_hook+0x53/0x2c0 mm/slab.h:768 slab_alloc_node mm/slub.c:3418 [inline] kmem_cache_alloc_node+0x18a/0x2d0 mm/slub.c:3463 __alloc_skb+0xcc/0x2c0 net/core/skbuff.c:497 alloc_skb include/linux/skbuff.h:1275 [inline] netlink_alloc_large_skb net/netlink/af_netlink.c:1200 [inline] netlink_sendmsg+0x7a6/0xd30 net/netlink/af_netlink.c:1906 Memory state around the buggy address: ffff88811ca4a780: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc ffff88811ca4a800: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc >ffff88811ca4a880: fa fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc ^ ffff88811ca4a900: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc ffff88811ca4a980: fa fb fb fb fc fc fc fc 00 00 00 fc fc fc fc fc ==================================================================