================================================================== BUG: KASAN: slab-use-after-free in string_nocheck lib/vsprintf.c:643 [inline] BUG: KASAN: slab-use-after-free in string+0x50/0xfc lib/vsprintf.c:726 Read at addr f0ff000007b16ec0 by task udevd/2532 Pointer tag: [f0], memory tag: [f8] CPU: 0 PID: 2532 Comm: udevd Not tainted 6.4.0-syzkaller-04247-g3a8a670eeeaa #0 Hardware name: linux,dummy-virt (DT) Call trace: dump_backtrace+0x94/0xec arch/arm64/kernel/stacktrace.c:233 show_stack+0x18/0x24 arch/arm64/kernel/stacktrace.c:240 __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x48/0x60 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:364 [inline] print_report+0xd8/0x5f4 mm/kasan/report.c:475 kasan_report+0x7c/0xa0 mm/kasan/report.c:588 __do_kernel_fault+0x174/0x1c0 arch/arm64/mm/fault.c:334 do_bad_area arch/arm64/mm/fault.c:493 [inline] do_tag_check_fault+0x78/0x8c arch/arm64/mm/fault.c:804 do_mem_abort+0x44/0x94 arch/arm64/mm/fault.c:880 el1_abort+0x40/0x60 arch/arm64/kernel/entry-common.c:369 el1h_64_sync_handler+0xd8/0xe4 arch/arm64/kernel/entry-common.c:429 el1h_64_sync+0x64/0x68 arch/arm64/kernel/entry.S:586 string_nocheck lib/vsprintf.c:643 [inline] string+0x50/0xfc lib/vsprintf.c:726 vsnprintf+0x170/0x748 lib/vsprintf.c:2817 add_uevent_var+0x84/0x120 lib/kobject_uevent.c:665 dev_uevent+0x70/0x1e4 drivers/base/core.c:2575 uevent_show+0x8c/0x118 drivers/base/core.c:2646 dev_attr_show+0x20/0x6c drivers/base/core.c:2349 sysfs_kf_seq_show+0xac/0x124 fs/sysfs/file.c:59 kernfs_seq_show+0x2c/0x38 fs/kernfs/file.c:205 seq_read_iter+0x1cc/0x4d0 fs/seq_file.c:230 kernfs_fop_read_iter+0x150/0x1c4 fs/kernfs/file.c:279 call_read_iter include/linux/fs.h:1866 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x1f8/0x298 fs/read_write.c:470 ksys_read+0x68/0xf4 fs/read_write.c:613 __do_sys_read fs/read_write.c:623 [inline] __se_sys_read fs/read_write.c:621 [inline] __arm64_sys_read+0x1c/0x28 fs/read_write.c:621 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x48/0x114 arch/arm64/kernel/syscall.c:52 el0_svc_common.constprop.0+0x44/0xe4 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x38/0xa4 arch/arm64/kernel/syscall.c:191 el0_svc+0x2c/0xb0 arch/arm64/kernel/entry-common.c:647 el0t_64_sync_handler+0xc0/0xc4 arch/arm64/kernel/entry-common.c:665 el0t_64_sync+0x19c/0x1a0 arch/arm64/kernel/entry.S:591 Allocated by task 2529: kasan_save_stack+0x2c/0x54 mm/kasan/common.c:45 save_stack_info+0x38/0x118 mm/kasan/tags.c:104 kasan_save_alloc_info+0x14/0x20 mm/kasan/tags.c:138 ____kasan_kmalloc mm/kasan/common.c:374 [inline] ____kasan_kmalloc mm/kasan/common.c:333 [inline] __kasan_kmalloc+0x9c/0xa8 mm/kasan/common.c:383 kasan_kmalloc include/linux/kasan.h:196 [inline] kmalloc_trace+0x4c/0x60 mm/slab_common.c:1083 kmalloc include/linux/slab.h:565 [inline] raw_ioctl_init+0xfc/0x2d8 drivers/usb/gadget/legacy/raw_gadget.c:460 raw_ioctl+0x4c8/0xcb0 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] __arm64_sys_ioctl+0xa8/0xec fs/ioctl.c:856 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x48/0x114 arch/arm64/kernel/syscall.c:52 el0_svc_common.constprop.0+0x44/0xe4 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x38/0xa4 arch/arm64/kernel/syscall.c:191 el0_svc+0x2c/0xb0 arch/arm64/kernel/entry-common.c:647 el0t_64_sync_handler+0xc0/0xc4 arch/arm64/kernel/entry-common.c:665 el0t_64_sync+0x19c/0x1a0 arch/arm64/kernel/entry.S:591 Freed by task 2527: kasan_save_stack+0x2c/0x54 mm/kasan/common.c:45 save_stack_info+0x38/0x118 mm/kasan/tags.c:104 kasan_save_free_info+0x18/0x24 mm/kasan/tags.c:143 ____kasan_slab_free.constprop.0+0x190/0x1f8 mm/kasan/common.c:236 __kasan_slab_free+0x10/0x1c mm/kasan/common.c:244 kasan_slab_free include/linux/kasan.h:162 [inline] slab_free_hook mm/slub.c:1802 [inline] slab_free_freelist_hook+0xb4/0x1e8 mm/slub.c:1828 slab_free mm/slub.c:3811 [inline] __kmem_cache_free+0x170/0x234 mm/slub.c:3824 kfree+0x5c/0x74 mm/slab_common.c:1036 dev_free+0x30/0x118 drivers/usb/gadget/legacy/raw_gadget.c:210 kref_put include/linux/kref.h:65 [inline] raw_release+0xe0/0x16c drivers/usb/gadget/legacy/raw_gadget.c:424 __fput+0xbc/0x278 fs/file_table.c:378 ____fput+0x10/0x1c fs/file_table.c:406 task_work_run+0x6c/0xc4 kernel/task_work.c:179 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] do_notify_resume+0x214/0x144c arch/arm64/kernel/signal.c:1305 exit_to_user_mode_prepare arch/arm64/kernel/entry-common.c:137 [inline] exit_to_user_mode arch/arm64/kernel/entry-common.c:144 [inline] el0_svc+0xac/0xb0 arch/arm64/kernel/entry-common.c:648 el0t_64_sync_handler+0xc0/0xc4 arch/arm64/kernel/entry-common.c:665 el0t_64_sync+0x19c/0x1a0 arch/arm64/kernel/entry.S:591 The buggy address belongs to the object at ffff000007b16ec0 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of 32-byte region [ffff000007b16ec0, ffff000007b16ee0) The buggy address belongs to the physical page: page:00000000106fc1cf refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x47b16 flags: 0x1ffc00000000200(slab|node=0|zone=0|lastcpupid=0x7ff|kasantag=0x0) page_type: 0xffffffff() raw: 01ffc00000000200 f6ff000002c01400 fffffc00008c1140 dead000000000002 raw: 0000000000000000 0000000000800080 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff000007b16c00: f2 f2 f9 f9 f7 f7 f9 f9 f9 f9 fb fb f3 f3 f5 f5 ffff000007b16d00: f0 f0 f6 f6 fc fc f9 f9 f8 f8 f2 f2 fa fa f1 f1 >ffff000007b16e00: f9 f9 f7 f7 fb fb f0 f0 f7 f7 f5 f5 f8 f8 f7 f7 ^ ffff000007b16f00: f1 f1 fc fc f8 f8 fb fb f8 f8 fd fd f8 f8 fc fc ffff000007b17000: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 ==================================================================