================================================================== BUG: KASAN: slab-use-after-free in string_nocheck lib/vsprintf.c:644 [inline] BUG: KASAN: slab-use-after-free in string+0x394/0x3d0 lib/vsprintf.c:726 Read of size 1 at addr ffff888075b91940 by task udevd/4467 CPU: 0 PID: 4467 Comm: udevd Not tainted 6.5.0-rc1-syzkaller-00276-g20edcec23f92 #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+0xd9/0x1b0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:364 [inline] print_report+0xc4/0x620 mm/kasan/report.c:475 kasan_report+0xda/0x110 mm/kasan/report.c:588 string_nocheck lib/vsprintf.c:644 [inline] string+0x394/0x3d0 lib/vsprintf.c:726 vsnprintf+0xc5f/0x1870 lib/vsprintf.c:2817 add_uevent_var+0x17c/0x390 lib/kobject_uevent.c:665 dev_uevent+0x18b/0x760 drivers/base/core.c:2575 uevent_show+0x1bf/0x380 drivers/base/core.c:2646 dev_attr_show+0x4f/0xd0 drivers/base/core.c:2349 sysfs_kf_seq_show+0x23e/0x400 fs/sysfs/file.c:59 seq_read_iter+0x4e5/0x1280 fs/seq_file.c:230 kernfs_fop_read_iter+0x4c8/0x680 fs/kernfs/file.c:279 call_read_iter include/linux/fs.h:1865 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x4e0/0x930 fs/read_write.c:470 ksys_read+0x12f/0x250 fs/read_write.c:613 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f8da3916b6a 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:00007ffdba7bb048 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 00005599ffe59b30 RCX: 00007f8da3916b6a RDX: 0000000000001000 RSI: 00005599ffe8c8c0 RDI: 000000000000000c RBP: 00005599ffe59b30 R08: 000000000000000c R09: 0000000004000000 R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000003fff R14: 00007ffdba7bb528 R15: 000000000000000a Allocated by task 17673: kasan_save_stack+0x33/0x50 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+0xa3/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:582 [inline] raw_ioctl_init+0x163/0x840 drivers/usb/gadget/legacy/raw_gadget.c:460 raw_ioctl+0x9d9/0x2b80 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+0x18f/0x210 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 17670: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x28/0x40 mm/kasan/generic.c:522 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x13f/0x190 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:162 [inline] __cache_free mm/slab.c:3370 [inline] __do_kmem_cache_free mm/slab.c:3557 [inline] __kmem_cache_free+0xcc/0x2d0 mm/slab.c:3564 dev_free+0x9a/0x700 drivers/usb/gadget/legacy/raw_gadget.c:210 kref_put include/linux/kref.h:65 [inline] raw_release+0x184/0x2e0 drivers/usb/gadget/legacy/raw_gadget.c:424 __fput+0x3fd/0xac0 fs/file_table.c:384 task_work_run+0x14d/0x240 kernel/task_work.c:179 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop kernel/entry/common.c:171 [inline] exit_to_user_mode_prepare+0x210/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+0x44/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff888075b91940 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of freed 32-byte region [ffff888075b91940, ffff888075b91960) The buggy address belongs to the physical page: page:ffffea0001d6e440 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888075b91fc1 pfn:0x75b91 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0x3f() raw: 00fff00000000200 ffff888012840100 ffffea00008db110 ffffea0001e4afd0 raw: ffff888075b91fc1 ffff888075b91000 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 5189, tgid 5188 (syz-executor.5), ts 168702410092, free_ts 166074168494 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x2d2/0x350 mm/page_alloc.c:1570 prep_new_page mm/page_alloc.c:1577 [inline] get_page_from_freelist+0x10a9/0x31e0 mm/page_alloc.c:3221 __alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4477 __alloc_pages_node include/linux/gfp.h:237 [inline] kmem_getpages mm/slab.c:1356 [inline] cache_grow_begin+0x99/0x3a0 mm/slab.c:2550 cache_alloc_refill+0x294/0x3a0 mm/slab.c:2923 ____cache_alloc mm/slab.c:2999 [inline] ____cache_alloc mm/slab.c:2982 [inline] __do_cache_alloc mm/slab.c:3182 [inline] slab_alloc_node mm/slab.c:3230 [inline] __kmem_cache_alloc_node+0x3c9/0x470 mm/slab.c:3521 kmalloc_trace+0x25/0xe0 mm/slab_common.c:1076 kmalloc include/linux/slab.h:582 [inline] kzalloc include/linux/slab.h:703 [inline] ref_tracker_alloc+0x17c/0x5a0 lib/ref_tracker.c:203 __netdev_tracker_alloc include/linux/netdevice.h:4077 [inline] netdev_hold include/linux/netdevice.h:4106 [inline] dst_init+0xdf/0x580 net/core/dst.c:52 dst_alloc+0xc3/0x1b0 net/core/dst.c:93 rt_dst_alloc+0x3c/0x3a0 net/ipv4/route.c:1633 __mkroute_output net/ipv4/route.c:2590 [inline] ip_route_output_key_hash_rcu+0x870/0x2ad0 net/ipv4/route.c:2812 ip_route_output_key_hash+0x190/0x340 net/ipv4/route.c:2641 __ip_route_output_key include/net/route.h:134 [inline] ip_route_output_flow+0x27/0x150 net/ipv4/route.c:2869 ip_route_output_key include/net/route.h:150 [inline] sctp_v4_get_dst+0x442/0x12c0 net/sctp/protocol.c:451 sctp_transport_pmtu+0x306/0x740 net/sctp/transport.c:243 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1161 [inline] free_unref_page_prepare+0x508/0xb90 mm/page_alloc.c:2348 free_unref_page+0x33/0x3b0 mm/page_alloc.c:2443 slab_destroy mm/slab.c:1608 [inline] slabs_destroy+0x85/0xc0 mm/slab.c:1628 cache_flusharray mm/slab.c:3341 [inline] ___cache_free+0x2b6/0x420 mm/slab.c:3404 qlink_free mm/kasan/quarantine.c:166 [inline] qlist_free_all+0x4c/0x1b0 mm/kasan/quarantine.c:185 kasan_quarantine_reduce+0x18b/0x1d0 mm/kasan/quarantine.c:292 __kasan_slab_alloc+0x65/0x90 mm/kasan/common.c:305 kasan_slab_alloc include/linux/kasan.h:186 [inline] slab_post_alloc_hook mm/slab.h:762 [inline] slab_alloc_node mm/slab.c:3237 [inline] __kmem_cache_alloc_node+0x167/0x470 mm/slab.c:3521 __do_kmalloc_node mm/slab_common.c:984 [inline] __kmalloc+0x4c/0x100 mm/slab_common.c:998 kmalloc include/linux/slab.h:586 [inline] kzalloc include/linux/slab.h:703 [inline] tomoyo_encode2+0x100/0x3d0 security/tomoyo/realpath.c:45 tomoyo_encode+0x29/0x50 security/tomoyo/realpath.c:80 tomoyo_realpath_from_path+0x196/0x710 security/tomoyo/realpath.c:283 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path2_perm+0x2a1/0x710 security/tomoyo/file.c:922 tomoyo_path_rename+0x102/0x1b0 security/tomoyo/tomoyo.c:299 security_path_rename+0x148/0x230 security/security.c:1789 do_renameat2+0x78b/0xdc0 fs/namei.c:4996 Memory state around the buggy address: ffff888075b91800: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ffff888075b91880: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc >ffff888075b91900: 05 fc fc fc fc fc fc fc fa fb fb fb fc fc fc fc ^ ffff888075b91980: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ffff888075b91a00: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ==================================================================