================================================================== BUG: KASAN: use-after-free in dev_uevent+0x712/0x780 drivers/base/core.c:2278 Read of size 8 at addr ffff88802dc8c098 by task systemd-udevd/3251 CPU: 0 PID: 3251 Comm: systemd-udevd Not tainted 5.13.0-rc2-next-20210518-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x13e/0x1d6 lib/dump_stack.c:129 print_address_description.constprop.0.cold+0x6c/0x309 mm/kasan/report.c:233 __kasan_report mm/kasan/report.c:419 [inline] kasan_report.cold+0x83/0xdf mm/kasan/report.c:436 dev_uevent+0x712/0x780 drivers/base/core.c:2278 uevent_show+0x1bb/0x390 drivers/base/core.c:2349 dev_attr_show+0x4b/0x90 drivers/base/core.c:2051 sysfs_kf_seq_show+0x1f8/0x400 fs/sysfs/file.c:61 seq_read_iter+0x4d3/0x1220 fs/seq_file.c:227 kernfs_fop_read_iter+0x44f/0x5f0 fs/kernfs/file.c:241 call_read_iter include/linux/fs.h:2108 [inline] new_sync_read+0x41e/0x6e0 fs/read_write.c:415 vfs_read+0x35c/0x570 fs/read_write.c:496 ksys_read+0x12d/0x250 fs/read_write.c:634 do_syscall_64+0x31/0xb0 arch/x86/entry/common.c:47 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7fbb9a32f910 Code: b6 fe ff ff 48 8d 3d 0f be 08 00 48 83 ec 08 e8 06 db 01 00 66 0f 1f 44 00 00 83 3d f9 2d 2c 00 00 75 10 b8 00 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 de 9b 01 00 48 89 04 24 RSP: 002b:00007ffdb39ac7e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 0000556127366be0 RCX: 00007fbb9a32f910 RDX: 0000000000001000 RSI: 0000556127362250 RDI: 0000000000000007 RBP: 00007fbb9a5ea440 R08: 00007fbb9a5ee1d8 R09: 0000000000001010 R10: 0000556127366be0 R11: 0000000000000246 R12: 0000000000001000 R13: 0000000000000d68 R14: 0000556127362250 R15: 00007fbb9a5e9900 Allocated by task 3205: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:46 [inline] set_alloc_info mm/kasan/common.c:431 [inline] ____kasan_kmalloc mm/kasan/common.c:510 [inline] ____kasan_kmalloc mm/kasan/common.c:469 [inline] __kasan_kmalloc+0x9b/0xd0 mm/kasan/common.c:519 kmalloc include/linux/slab.h:590 [inline] kzalloc include/linux/slab.h:720 [inline] dev_new drivers/usb/gadget/legacy/raw_gadget.c:183 [inline] raw_open+0x8d/0x4d0 drivers/usb/gadget/legacy/raw_gadget.c:373 misc_open+0x372/0x4a0 drivers/char/misc.c:141 chrdev_open+0x266/0x770 fs/char_dev.c:414 do_dentry_open+0x4b9/0x11c0 fs/open.c:826 do_open fs/namei.c:3361 [inline] path_openat+0x1c09/0x27d0 fs/namei.c:3494 do_filp_open+0x190/0x3d0 fs/namei.c:3521 do_sys_openat2+0x16d/0x420 fs/open.c:1196 do_sys_open fs/open.c:1212 [inline] __do_sys_openat fs/open.c:1228 [inline] __se_sys_openat fs/open.c:1223 [inline] __x64_sys_openat+0x13f/0x1f0 fs/open.c:1223 do_syscall_64+0x31/0xb0 arch/x86/entry/common.c:47 entry_SYSCALL_64_after_hwframe+0x44/0xae Freed by task 3204: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38 kasan_set_track+0x1c/0x30 mm/kasan/common.c:46 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:357 ____kasan_slab_free mm/kasan/common.c:363 [inline] ____kasan_slab_free mm/kasan/common.c:328 [inline] __kasan_slab_free+0xfb/0x130 mm/kasan/common.c:371 kasan_slab_free include/linux/kasan.h:212 [inline] slab_free_hook mm/slub.c:1623 [inline] slab_free_freelist_hook+0xdf/0x240 mm/slub.c:1648 slab_free mm/slub.c:3208 [inline] kfree+0xeb/0x650 mm/slub.c:4274 kref_put include/linux/kref.h:65 [inline] raw_release+0x218/0x290 drivers/usb/gadget/legacy/raw_gadget.c:412 __fput+0x288/0x920 fs/file_table.c:280 task_work_run+0xdd/0x1a0 kernel/task_work.c:164 exit_task_work include/linux/task_work.h:32 [inline] do_exit+0xbfc/0x2a70 kernel/exit.c:826 do_group_exit+0x125/0x310 kernel/exit.c:923 __do_sys_exit_group kernel/exit.c:934 [inline] __se_sys_exit_group kernel/exit.c:932 [inline] __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:932 do_syscall_64+0x31/0xb0 arch/x86/entry/common.c:47 entry_SYSCALL_64_after_hwframe+0x44/0xae The buggy address belongs to the object at ffff88802dc8c000 which belongs to the cache kmalloc-4k of size 4096 The buggy address is located 152 bytes inside of 4096-byte region [ffff88802dc8c000, ffff88802dc8d000) The buggy address belongs to the page: page:ffffea0000b72200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2dc88 head:ffffea0000b72200 order:3 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888011042140 raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 4858, ts 363165571727, free_ts 363129945771 prep_new_page mm/page_alloc.c:2377 [inline] get_page_from_freelist+0x125c/0x2ed0 mm/page_alloc.c:4038 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5239 alloc_pages+0x18c/0x2a0 mm/mempolicy.c:2272 alloc_slab_page mm/slub.c:1686 [inline] allocate_slab+0x2c2/0x4c0 mm/slub.c:1826 new_slab mm/slub.c:1889 [inline] new_slab_objects mm/slub.c:2635 [inline] ___slab_alloc+0x4ba/0x820 mm/slub.c:2798 __slab_alloc.constprop.0+0xa7/0xf0 mm/slub.c:2838 slab_alloc_node mm/slub.c:2920 [inline] slab_alloc mm/slub.c:2962 [inline] __kmalloc+0x312/0x330 mm/slub.c:4112 kmalloc include/linux/slab.h:595 [inline] tomoyo_realpath_from_path+0xc3/0x620 security/tomoyo/realpath.c:254 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_perm+0x21b/0x400 security/tomoyo/file.c:822 security_inode_getattr+0xcf/0x140 security/security.c:1332 vfs_getattr fs/stat.c:139 [inline] vfs_statx+0x164/0x390 fs/stat.c:207 vfs_fstatat fs/stat.c:225 [inline] vfs_lstat include/linux/fs.h:3384 [inline] __do_sys_newlstat+0x91/0x110 fs/stat.c:380 do_syscall_64+0x31/0xb0 arch/x86/entry/common.c:47 entry_SYSCALL_64_after_hwframe+0x44/0xae page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1305 [inline] __free_pages_ok+0x4cb/0xf30 mm/page_alloc.c:1586 unfreeze_partials+0x17c/0x1d0 mm/slub.c:2416 put_cpu_partial+0x13d/0x230 mm/slub.c:2452 qlink_free mm/kasan/quarantine.c:146 [inline] qlist_free_all+0x5a/0xc0 mm/kasan/quarantine.c:165 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:272 __kasan_slab_alloc+0x8e/0xa0 mm/kasan/common.c:441 kasan_slab_alloc include/linux/kasan.h:236 [inline] slab_post_alloc_hook mm/slab.h:512 [inline] slab_alloc_node mm/slub.c:2954 [inline] slab_alloc mm/slub.c:2962 [inline] __kmalloc+0x1f4/0x330 mm/slub.c:4112 kmalloc include/linux/slab.h:595 [inline] tomoyo_realpath_from_path+0xc3/0x620 security/tomoyo/realpath.c:254 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_perm+0x21b/0x400 security/tomoyo/file.c:822 security_inode_getattr+0xcf/0x140 security/security.c:1332 vfs_getattr fs/stat.c:139 [inline] vfs_fstat+0x43/0xb0 fs/stat.c:164 __do_sys_newfstat+0x81/0x100 fs/stat.c:404 do_syscall_64+0x31/0xb0 arch/x86/entry/common.c:47 entry_SYSCALL_64_after_hwframe+0x44/0xae Memory state around the buggy address: ffff88802dc8bf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88802dc8c000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88802dc8c080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88802dc8c100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88802dc8c180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================