================================================================== BUG: KASAN: use-after-free in string_nocheck lib/vsprintf.c:644 [inline] BUG: KASAN: use-after-free in string+0x39c/0x3d0 lib/vsprintf.c:726 Read of size 1 at addr ffff88802b8aee80 by task udevd/16142 CPU: 1 PID: 16142 Comm: udevd Not tainted 6.2.0-rc3-syzkaller-00008-g1fe4fd6f5cad #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:306 [inline] print_report+0x15e/0x461 mm/kasan/report.c:417 kasan_report+0xbf/0x1f0 mm/kasan/report.c:517 string_nocheck lib/vsprintf.c:644 [inline] string+0x39c/0x3d0 lib/vsprintf.c:726 vsnprintf+0xa11/0x16b0 lib/vsprintf.c:2796 add_uevent_var+0x161/0x390 lib/kobject_uevent.c:665 dev_uevent+0x191/0x780 drivers/base/core.c:2422 uevent_show+0x1bc/0x380 drivers/base/core.c:2493 dev_attr_show+0x4f/0x90 drivers/base/core.c:2196 sysfs_kf_seq_show+0x21d/0x3d0 fs/sysfs/file.c:59 seq_read_iter+0x4f9/0x1280 fs/seq_file.c:230 kernfs_fop_read_iter+0x53e/0x790 fs/kernfs/file.c:279 call_read_iter include/linux/fs.h:2183 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x681/0x930 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:0x7fc7c0f258fe Code: c0 e9 e6 fe ff ff 50 48 8d 3d 0e c7 09 00 e8 c9 cf 01 00 66 0f 1f 84 00 00 00 00 00 64 8b 04 25 18 00 00 00 85 c0 75 14 0f 05 <48> 3d 00 f0 ff ff 77 5a c3 66 0f 1f 84 00 00 00 00 00 48 83 ec 28 RSP: 002b:00007ffe2351d8b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 0000562161e38490 RCX: 00007fc7c0f258fe RDX: 0000000000001000 RSI: 0000562161eaf160 RDI: 0000000000000008 RBP: 00007fc7c0ff2380 R08: 0000000000000008 R09: 00007fc7c0ff5a60 R10: 0000000000002000 R11: 0000000000000246 R12: 0000562161e38490 R13: 0000000000000d68 R14: 00007fc7c0ff1780 R15: 0000000000000d68 Allocated by task 16232: 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:371 [inline] ____kasan_kmalloc mm/kasan/common.c:330 [inline] __kasan_kmalloc+0xa3/0xb0 mm/kasan/common.c:380 kmalloc include/linux/slab.h:580 [inline] raw_ioctl_init+0x152/0x820 drivers/usb/gadget/legacy/raw_gadget.c:460 raw_ioctl+0xbf5/0x27d0 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 16232: 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:518 ____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:177 [inline] __cache_free mm/slab.c:3394 [inline] __do_kmem_cache_free mm/slab.c:3580 [inline] __kmem_cache_free+0xcd/0x3b0 mm/slab.c:3587 dev_free+0x9a/0x700 drivers/usb/gadget/legacy/raw_gadget.c:210 kref_put include/linux/kref.h:65 [inline] raw_release+0x21d/0x290 drivers/usb/gadget/legacy/raw_gadget.c:424 __fput+0x27c/0xa90 fs/file_table.c:320 task_work_run+0x16f/0x270 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xaa8/0x2950 kernel/exit.c:867 do_group_exit+0xd4/0x2a0 kernel/exit.c:1012 get_signal+0x21c3/0x2450 kernel/signal.c:2859 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+0x15f/0x250 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296 do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff88802b8aee80 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of 32-byte region [ffff88802b8aee80, ffff88802b8aeea0) The buggy address belongs to the physical page: page:ffffea0000ae2b80 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88802b8aefc1 pfn:0x2b8ae flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffff888012440100 ffffea0000b3db10 ffffea0000a39a10 raw: ffff88802b8aefc1 ffff88802b8ae000 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 0x2420c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_THISNODE), pid 6, tgid 6 (kworker/0:0), ts 183058973414, free_ts 182926472507 prep_new_page mm/page_alloc.c:2531 [inline] get_page_from_freelist+0x119c/0x2ce0 mm/page_alloc.c:4283 __alloc_pages+0x1cb/0x5b0 mm/page_alloc.c:5549 __alloc_pages_node include/linux/gfp.h:237 [inline] kmem_getpages mm/slab.c:1363 [inline] cache_grow_begin+0x94/0x390 mm/slab.c:2574 cache_alloc_refill+0x27f/0x380 mm/slab.c:2947 ____cache_alloc mm/slab.c:3023 [inline] ____cache_alloc mm/slab.c:3006 [inline] __do_cache_alloc mm/slab.c:3206 [inline] slab_alloc_node mm/slab.c:3254 [inline] __kmem_cache_alloc_node+0x44f/0x510 mm/slab.c:3544 kmalloc_trace+0x26/0x60 mm/slab_common.c:1062 kmalloc include/linux/slab.h:580 [inline] kzalloc include/linux/slab.h:720 [inline] nsim_fib6_rt_nh_add+0x4a/0x290 drivers/net/netdevsim/fib.c:500 nsim_fib6_rt_create drivers/net/netdevsim/fib.c:562 [inline] nsim_fib6_rt_insert drivers/net/netdevsim/fib.c:752 [inline] nsim_fib6_event drivers/net/netdevsim/fib.c:856 [inline] nsim_fib_event drivers/net/netdevsim/fib.c:889 [inline] nsim_fib_event_work+0x1369/0x24a0 drivers/net/netdevsim/fib.c:1492 process_one_work+0x9bf/0x1710 kernel/workqueue.c:2289 process_scheduled_works kernel/workqueue.c:2352 [inline] worker_thread+0x858/0x1090 kernel/workqueue.c:2438 kthread+0x2e8/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1446 [inline] free_pcp_prepare+0x65c/0xc00 mm/page_alloc.c:1496 free_unref_page_prepare mm/page_alloc.c:3369 [inline] free_unref_page+0x1d/0x490 mm/page_alloc.c:3464 slab_destroy mm/slab.c:1619 [inline] slabs_destroy+0x85/0xc0 mm/slab.c:1639 cache_flusharray mm/slab.c:3365 [inline] ___cache_free+0x2ac/0x3d0 mm/slab.c:3428 qlink_free mm/kasan/quarantine.c:168 [inline] qlist_free_all+0x4f/0x1a0 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x192/0x220 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0x63/0x90 mm/kasan/common.c:302 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook mm/slab.h:761 [inline] slab_alloc_node mm/slab.c:3261 [inline] slab_alloc mm/slab.c:3270 [inline] __kmem_cache_alloc_lru mm/slab.c:3447 [inline] kmem_cache_alloc+0x225/0x460 mm/slab.c:3456 vm_area_alloc+0x20/0x100 kernel/fork.c:458 mmap_region+0x44c/0x1dd0 mm/mmap.c:2601 do_mmap+0x831/0xf60 mm/mmap.c:1411 vm_mmap_pgoff+0x1af/0x280 mm/util.c:520 ksys_mmap_pgoff+0x41f/0x5a0 mm/mmap.c:1457 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: ffff88802b8aed80: 00 00 00 00 fc fc fc fc 00 00 fc fc fc fc fc fc ffff88802b8aee00: 00 fc fc fc fc fc fc fc 00 00 00 00 fc fc fc fc >ffff88802b8aee80: fa fb fb fb fc fc fc fc 00 00 00 fc fc fc fc fc ^ ffff88802b8aef00: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ffff88802b8aef80: 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================