================================================================== BUG: KASAN: slab-use-after-free in string_nocheck lib/vsprintf.c:646 [inline] BUG: KASAN: slab-use-after-free in string+0x394/0x3d0 lib/vsprintf.c:728 Read of size 1 at addr ffff888014ac7908 by task udevd/4511 CPU: 0 PID: 4511 Comm: udevd Not tainted 6.8.0-rc1-syzkaller-00169-gecb1b8288dc7 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/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:377 [inline] print_report+0xc4/0x620 mm/kasan/report.c:488 kasan_report+0xda/0x110 mm/kasan/report.c:601 string_nocheck lib/vsprintf.c:646 [inline] string+0x394/0x3d0 lib/vsprintf.c:728 vsnprintf+0xc5f/0x1870 lib/vsprintf.c:2824 add_uevent_var+0x17c/0x3a0 lib/kobject_uevent.c:665 dev_uevent+0x18b/0x760 drivers/base/core.c:2576 uevent_show+0x1bf/0x380 drivers/base/core.c:2647 dev_attr_show+0x4f/0xd0 drivers/base/core.c:2350 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+0x410/0x580 fs/kernfs/file.c:279 call_read_iter include/linux/fs.h:2079 [inline] new_sync_read fs/read_write.c:395 [inline] vfs_read+0x6bb/0xb70 fs/read_write.c:476 ksys_read+0x12f/0x250 fs/read_write.c:619 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xd3/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x63/0x6b RIP: 0033:0x7fc7af316b6a 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:00007fffa5375328 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 000055af8e04a2d0 RCX: 00007fc7af316b6a RDX: 0000000000001000 RSI: 000055af8e06ee30 RDI: 000000000000000c RBP: 000055af8e04a2d0 R08: 000000000000000c R09: 0000000000000000 R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000003fff R14: 00007fffa5375808 R15: 000000000000000a Allocated by task 13593: kasan_save_stack+0x33/0x50 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:372 [inline] __kasan_kmalloc+0xa2/0xb0 mm/kasan/common.c:389 kmalloc include/linux/slab.h:590 [inline] raw_ioctl_init+0x163/0x840 drivers/usb/gadget/legacy/raw_gadget.c:509 raw_ioctl+0x9d9/0x2b80 drivers/usb/gadget/legacy/raw_gadget.c:1303 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:871 [inline] __se_sys_ioctl fs/ioctl.c:857 [inline] __x64_sys_ioctl+0x18f/0x210 fs/ioctl.c:857 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xd3/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x63/0x6b Freed by task 13593: kasan_save_stack+0x33/0x50 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 kasan_save_free_info+0x3f/0x60 mm/kasan/generic.c:640 poison_slab_object mm/kasan/common.c:241 [inline] __kasan_slab_free+0x121/0x1b0 mm/kasan/common.c:257 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2121 [inline] slab_free mm/slub.c:4299 [inline] kfree+0x124/0x360 mm/slub.c:4409 dev_free+0x9a/0x700 drivers/usb/gadget/legacy/raw_gadget.c:211 kref_put include/linux/kref.h:65 [inline] raw_release+0x184/0x2e0 drivers/usb/gadget/legacy/raw_gadget.c:473 __fput+0x270/0xb70 fs/file_table.c:376 task_work_run+0x14d/0x240 kernel/task_work.c:180 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline] exit_to_user_mode_loop kernel/entry/common.c:108 [inline] exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline] __syscall_exit_to_user_mode_work kernel/entry/common.c:201 [inline] syscall_exit_to_user_mode+0x281/0x2b0 kernel/entry/common.c:212 do_syscall_64+0xe0/0x250 arch/x86/entry/common.c:89 entry_SYSCALL_64_after_hwframe+0x63/0x6b The buggy address belongs to the object at ffff888014ac7900 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 8 bytes inside of freed 32-byte region [ffff888014ac7900, ffff888014ac7920) The buggy address belongs to the physical page: page:ffffea000052b1c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x14ac7 ksm flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000800 ffff888013041500 ffffea00008d61c0 dead000000000003 raw: 0000000000000000 0000000000200020 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 0x112c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL), pid 5282, tgid 5282 (syz-executor.1), ts 179716459817, free_ts 179666813577 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x2d0/0x350 mm/page_alloc.c:1533 prep_new_page mm/page_alloc.c:1540 [inline] get_page_from_freelist+0xa28/0x3780 mm/page_alloc.c:3311 __alloc_pages+0x22f/0x2440 mm/page_alloc.c:4567 __alloc_pages_node include/linux/gfp.h:238 [inline] alloc_pages_node include/linux/gfp.h:261 [inline] alloc_slab_page mm/slub.c:2190 [inline] allocate_slab mm/slub.c:2354 [inline] new_slab+0xcc/0x3a0 mm/slub.c:2407 ___slab_alloc+0x4af/0x19a0 mm/slub.c:3540 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3625 __slab_alloc_node mm/slub.c:3678 [inline] slab_alloc_node mm/slub.c:3850 [inline] __do_kmalloc_node mm/slub.c:3980 [inline] __kmalloc+0x3b4/0x440 mm/slub.c:3994 kmalloc include/linux/slab.h:594 [inline] kzalloc include/linux/slab.h:711 [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_path_perm+0x26f/0x450 security/tomoyo/file.c:822 tomoyo_path_symlink+0x98/0xe0 security/tomoyo/tomoyo.c:212 security_path_symlink+0x101/0x160 security/security.c:1870 do_symlinkat+0x10e/0x310 fs/namei.c:4504 __do_sys_symlinkat fs/namei.c:4522 [inline] __se_sys_symlinkat fs/namei.c:4519 [inline] __x64_sys_symlinkat+0x97/0xc0 fs/namei.c:4519 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xd3/0x250 arch/x86/entry/common.c:83 page last free pid 5107 tgid 5107 stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1140 [inline] free_unref_page_prepare+0x51f/0xb10 mm/page_alloc.c:2346 free_unref_page+0x33/0x3c0 mm/page_alloc.c:2486 vfree+0x181/0x7a0 mm/vmalloc.c:2842 copy_entries_to_user net/ipv4/netfilter/ip_tables.c:866 [inline] get_entries net/ipv4/netfilter/ip_tables.c:1022 [inline] do_ipt_get_ctl+0x8ae/0xaa0 net/ipv4/netfilter/ip_tables.c:1660 nf_getsockopt+0x76/0xe0 net/netfilter/nf_sockopt.c:116 ip_getsockopt+0x186/0x1d0 net/ipv4/ip_sockglue.c:1768 tcp_getsockopt+0x97/0xf0 net/ipv4/tcp.c:4362 do_sock_getsockopt+0x2e1/0x6c0 net/socket.c:2373 __sys_getsockopt+0x1a3/0x270 net/socket.c:2402 __do_sys_getsockopt net/socket.c:2412 [inline] __se_sys_getsockopt net/socket.c:2409 [inline] __x64_sys_getsockopt+0xbd/0x150 net/socket.c:2409 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xd3/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x63/0x6b Memory state around the buggy address: ffff888014ac7800: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc ffff888014ac7880: 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc fc >ffff888014ac7900: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc ^ ffff888014ac7980: 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc fc ffff888014ac7a00: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================