================================================================== 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 ffff888165d2dd00 by task udevd/102 CPU: 0 PID: 102 Comm: udevd Not tainted 6.1.25-syzkaller-00070-gd3b37a712ab7 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/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:0x7f2c61d16b6a 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:00007ffd0dc89be8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 0000559edb2d1770 RCX: 00007f2c61d16b6a RDX: 0000000000001000 RSI: 0000559edb347e50 RDI: 000000000000000c RBP: 0000559edb2d1770 R08: 000000000000000c R09: 0000000000000000 R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000003fff R14: 00007ffd0dc8a0c8 R15: 000000000000000a Allocated by task 3868: 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 3867: 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 __do_sys_exit_group kernel/exit.c:1033 [inline] __se_sys_exit_group kernel/exit.c:1031 [inline] __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1031 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 The buggy address belongs to the object at ffff888165d2dd00 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of 32-byte region [ffff888165d2dd00, ffff888165d2dd20) The buggy address belongs to the physical page: page:ffffea0005974b40 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x165d2d flags: 0x4000000000000200(slab|zone=1) raw: 4000000000000200 ffffea0004d909c0 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 28295, tgid 28295 (udevd), ts 1428194873803, free_ts 1428194069245 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 __do_kmalloc_node mm/slab_common.c:956 [inline] __kmalloc_node_track_caller+0xa2/0x1e0 mm/slab_common.c:977 kstrdup+0x39/0x70 mm/util.c:65 simple_xattr_set+0x10a/0x580 fs/xattr.c:1076 shmem_xattr_handler_set+0x46/0xe0 mm/shmem.c:3320 __vfs_setxattr+0x3ed/0x440 fs/xattr.c:182 __vfs_setxattr_noperm+0x126/0x5e0 fs/xattr.c:216 __vfs_setxattr_locked+0x215/0x230 fs/xattr.c:277 vfs_setxattr+0x21d/0x420 fs/xattr.c:309 do_setxattr fs/xattr.c:594 [inline] setxattr+0x250/0x2b0 fs/xattr.c:617 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_pages+0x7c/0x90 mm/page_alloc.c:5762 _pgd_free arch/x86/mm/pgtable.c:420 [inline] pgd_free+0x17d/0x190 arch/x86/mm/pgtable.c:476 mm_free_pgd kernel/fork.c:814 [inline] __mmdrop+0xb0/0x3e0 kernel/fork.c:865 mmdrop include/linux/sched/mm.h:50 [inline] __mmput+0x304/0x310 kernel/fork.c:1283 mmput+0x56/0x170 kernel/fork.c:1295 exit_mm kernel/exit.c:565 [inline] do_exit+0xb19/0x2a40 kernel/exit.c:859 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 Memory state around the buggy address: ffff888165d2dc00: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc ffff888165d2dc80: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc >ffff888165d2dd00: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc ^ ffff888165d2dd80: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc ffff888165d2de00: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ==================================================================