================================================================== BUG: KASAN: slab-use-after-free in string_nocheck lib/vsprintf.c:644 [inline] BUG: KASAN: slab-use-after-free in string+0x39c/0x3d0 lib/vsprintf.c:726 Read of size 1 at addr ffff8880177efac1 by task udevd/22741 CPU: 1 PID: 22741 Comm: udevd Not tainted 6.3.0-syzkaller-04439-g4173cf6fb6b7 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/14/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106 print_address_description.constprop.0+0x2c/0x3c0 mm/kasan/report.c:319 print_report mm/kasan/report.c:430 [inline] kasan_report+0x11c/0x130 mm/kasan/report.c:536 string_nocheck lib/vsprintf.c:644 [inline] string+0x39c/0x3d0 lib/vsprintf.c:726 vsnprintf+0xa36/0x1710 lib/vsprintf.c:2796 add_uevent_var+0x161/0x390 lib/kobject_uevent.c:665 dev_uevent+0x191/0x780 drivers/base/core.c:2527 uevent_show+0x1bc/0x380 drivers/base/core.c:2598 dev_attr_show+0x4f/0xd0 drivers/base/core.c:2301 sysfs_kf_seq_show+0x21d/0x430 fs/sysfs/file.c:59 seq_read_iter+0x4f9/0x12d0 fs/seq_file.c:230 kernfs_fop_read_iter+0x4ce/0x690 fs/kernfs/file.c:279 call_read_iter include/linux/fs.h:1845 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x679/0x920 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:0x7f2aafb16b6a 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:00007fff8d592d98 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 000055bc7aea3330 RCX: 00007f2aafb16b6a RDX: 0000000000001000 RSI: 000055bc7ae942f0 RDI: 0000000000000008 RBP: 000055bc7aea3330 R08: 0000000000000008 R09: 0000000000000010 R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000003fff R14: 00007fff8d593278 R15: 000000000000000a Allocated by task 22774: 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:374 [inline] ____kasan_kmalloc mm/kasan/common.c:333 [inline] __kasan_kmalloc+0xa3/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:560 [inline] raw_ioctl_init+0x152/0x830 drivers/usb/gadget/legacy/raw_gadget.c:460 raw_ioctl+0xbf5/0x2a60 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 22774: 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:521 ____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:162 [inline] __cache_free mm/slab.c:3390 [inline] __do_kmem_cache_free mm/slab.c:3577 [inline] __kmem_cache_free+0xcd/0x2c0 mm/slab.c:3584 dev_free+0x9a/0x700 drivers/usb/gadget/legacy/raw_gadget.c:210 kref_put include/linux/kref.h:65 [inline] raw_release+0x21d/0x2d0 drivers/usb/gadget/legacy/raw_gadget.c:424 __fput+0x27c/0xa90 fs/file_table.c:321 task_work_run+0x16f/0x270 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xad3/0x2960 kernel/exit.c:869 do_group_exit+0xd4/0x2a0 kernel/exit.c:1019 get_signal+0x2315/0x25b0 kernel/signal.c:2874 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+0x11f/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+0x46/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff8880177efac0 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 1 bytes inside of freed 32-byte region [ffff8880177efac0, ffff8880177efae0) The buggy address belongs to the physical page: page:ffffea00005dfbc0 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880177effc1 pfn:0x177ef flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffff888012440100 ffffea000073c790 ffffea000073be10 raw: ffff8880177effc1 ffff8880177ef000 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 0x342040(__GFP_IO|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE), pid 5066, tgid 5066 (udevd), ts 218248874024, free_ts 218242578935 prep_new_page mm/page_alloc.c:2553 [inline] get_page_from_freelist+0x1190/0x2e20 mm/page_alloc.c:4326 __alloc_pages+0x1cb/0x4a0 mm/page_alloc.c:5592 __alloc_pages_node include/linux/gfp.h:237 [inline] kmem_getpages mm/slab.c:1360 [inline] cache_grow_begin+0x9b/0x3b0 mm/slab.c:2570 cache_alloc_refill+0x27f/0x380 mm/slab.c:2943 ____cache_alloc mm/slab.c:3019 [inline] ____cache_alloc mm/slab.c:3002 [inline] __do_cache_alloc mm/slab.c:3202 [inline] slab_alloc_node mm/slab.c:3250 [inline] __kmem_cache_alloc_node+0x360/0x3f0 mm/slab.c:3541 __do_kmalloc_node mm/slab_common.c:965 [inline] __kmalloc+0x4e/0x190 mm/slab_common.c:979 kmalloc include/linux/slab.h:564 [inline] kzalloc include/linux/slab.h:681 [inline] tomoyo_encode2.part.0+0xe9/0x3a0 security/tomoyo/realpath.c:45 tomoyo_encode2 security/tomoyo/realpath.c:31 [inline] tomoyo_encode+0x2c/0x50 security/tomoyo/realpath.c:80 tomoyo_realpath_from_path+0x185/0x600 security/tomoyo/realpath.c:283 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_perm+0x230/0x430 security/tomoyo/file.c:822 security_inode_getattr+0xd3/0x140 security/security.c:2114 vfs_getattr fs/stat.c:167 [inline] vfs_statx+0x16e/0x430 fs/stat.c:242 vfs_fstatat+0x90/0xb0 fs/stat.c:276 __do_sys_newfstatat+0x8a/0x110 fs/stat.c:446 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 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1454 [inline] free_pcp_prepare+0x5d5/0xa50 mm/page_alloc.c:1504 free_unref_page_prepare mm/page_alloc.c:3388 [inline] free_unref_page+0x1d/0x490 mm/page_alloc.c:3483 mm_free_pgd kernel/fork.c:737 [inline] __mmdrop+0xd7/0x420 kernel/fork.c:790 mmdrop include/linux/sched/mm.h:50 [inline] __mmput+0x405/0x4c0 kernel/fork.c:1219 mmput+0x60/0x70 kernel/fork.c:1230 exit_mm kernel/exit.c:563 [inline] do_exit+0x9d7/0x2960 kernel/exit.c:856 do_group_exit+0xd4/0x2a0 kernel/exit.c:1019 get_signal+0x2315/0x25b0 kernel/signal.c:2874 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+0x11f/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+0x46/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd Memory state around the buggy address: ffff8880177ef980: 00 00 fc fc fc fc fc fc fa fb fb fb fc fc fc fc ffff8880177efa00: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc >ffff8880177efa80: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc ^ ffff8880177efb00: fa fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc ffff8880177efb80: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc ==================================================================