================================================================== BUG: KASAN: use-after-free in dev_uevent+0x32c/0x5b0 drivers/base/core.c:1872 Read of size 8 at addr ffff8881e47a6058 by task udevd/14127 CPU: 0 PID: 14127 Comm: udevd Not tainted 5.4.147-syzkaller-00036-geb4a5a5dbd5b #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x18e/0x1de lib/dump_stack.c:118 print_address_description+0x9b/0x650 mm/kasan/report.c:384 __kasan_report+0x182/0x260 mm/kasan/report.c:516 kasan_report+0x30/0x60 mm/kasan/common.c:653 dev_uevent+0x32c/0x5b0 drivers/base/core.c:1872 uevent_show+0x1a2/0x2e0 drivers/base/core.c:1943 dev_attr_show+0x50/0xc0 drivers/base/core.c:1647 sysfs_kf_seq_show+0x265/0x3e0 fs/sysfs/file.c:61 seq_read+0x4ca/0xda0 fs/seq_file.c:232 __vfs_read+0xa7/0x690 fs/read_write.c:425 vfs_read+0x161/0x370 fs/read_write.c:461 ksys_read+0x13f/0x240 fs/read_write.c:587 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7f2561df78fe 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:00007fffc9e83028 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 0000565371e8ec90 RCX: 00007f2561df78fe RDX: 0000000000001000 RSI: 0000565371e96e10 RDI: 0000000000000008 RBP: 00007f2561ec4380 R08: 0000000000000008 R09: 00007f2561ec7a60 R10: 0000000000000008 R11: 0000000000000246 R12: 0000565371e8ec90 R13: 0000000000000d68 R14: 00007f2561ec3780 R15: 0000000000000d68 Allocated by task 12094: save_stack mm/kasan/common.c:70 [inline] set_track mm/kasan/common.c:78 [inline] __kasan_kmalloc+0x137/0x1e0 mm/kasan/common.c:529 kmem_cache_alloc_trace+0x139/0x2b0 mm/slub.c:2849 kmalloc include/linux/slab.h:556 [inline] kzalloc include/linux/slab.h:690 [inline] dev_new drivers/usb/gadget/legacy/raw_gadget.c:182 [inline] raw_open+0x84/0x370 drivers/usb/gadget/legacy/raw_gadget.c:372 misc_open+0x346/0x3c0 drivers/char/misc.c:141 chrdev_open+0x4ec/0x5b0 fs/char_dev.c:414 do_dentry_open+0x7e6/0xef0 fs/open.c:796 do_last fs/namei.c:3495 [inline] path_openat+0xfed/0x3a50 fs/namei.c:3612 do_filp_open+0x19a/0x3a0 fs/namei.c:3642 do_sys_open+0x2e2/0x6d0 fs/open.c:1113 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 12093: save_stack mm/kasan/common.c:70 [inline] set_track mm/kasan/common.c:78 [inline] kasan_set_free_info mm/kasan/common.c:345 [inline] __kasan_slab_free+0x18a/0x240 mm/kasan/common.c:487 slab_free_hook mm/slub.c:1455 [inline] slab_free_freelist_hook+0x7b/0x150 mm/slub.c:1493 slab_free mm/slub.c:3073 [inline] kfree+0xe0/0x660 mm/slub.c:4064 raw_release+0x130/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:411 __fput+0x27d/0x6c0 fs/file_table.c:281 task_work_run+0x186/0x1b0 kernel/task_work.c:113 exit_task_work include/linux/task_work.h:22 [inline] do_exit+0xc0a/0x2aa0 kernel/exit.c:812 do_group_exit+0x15c/0x2c0 kernel/exit.c:910 get_signal+0x150f/0x1e00 kernel/signal.c:2745 do_signal+0x3b/0x580 arch/x86/kernel/signal.c:809 exit_to_usermode_loop arch/x86/entry/common.c:159 [inline] prepare_exit_to_usermode+0x207/0x310 arch/x86/entry/common.c:194 entry_SYSCALL_64_after_hwframe+0x44/0xa9 The buggy address belongs to the object at ffff8881e47a6000 which belongs to the cache kmalloc-4k of size 4096 The buggy address is located 88 bytes inside of 4096-byte region [ffff8881e47a6000, ffff8881e47a7000) The buggy address belongs to the page: page:ffffea000791e800 refcount:1 mapcount:0 mapping:ffff8881f5c0c280 index:0x0 compound_mapcount: 0 flags: 0x8000000000010200(slab|head) raw: 8000000000010200 dead000000000100 dead000000000122 ffff8881f5c0c280 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 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL) set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook mm/page_alloc.c:2165 [inline] prep_new_page+0x19a/0x380 mm/page_alloc.c:2171 get_page_from_freelist+0x550/0x8b0 mm/page_alloc.c:3794 __alloc_pages_nodemask+0x2d6/0x740 mm/page_alloc.c:4855 alloc_slab_page+0x39/0x3e0 mm/slub.c:343 allocate_slab mm/slub.c:1676 [inline] new_slab+0x97/0x460 mm/slub.c:1742 new_slab_objects mm/slub.c:2499 [inline] ___slab_alloc+0x330/0x4c0 mm/slub.c:2660 __slab_alloc mm/slub.c:2700 [inline] slab_alloc_node mm/slub.c:2785 [inline] slab_alloc mm/slub.c:2830 [inline] __kmalloc+0x1ee/0x2f0 mm/slub.c:3902 __kmalloc_node include/linux/slab.h:422 [inline] kmalloc_node include/linux/slab.h:599 [inline] kvmalloc_node+0x7e/0xf0 mm/util.c:564 kvmalloc include/linux/mm.h:758 [inline] seq_buf_alloc fs/seq_file.c:35 [inline] seq_read+0x225/0xda0 fs/seq_file.c:207 __vfs_read+0xa7/0x690 fs/read_write.c:425 vfs_read+0x161/0x370 fs/read_write.c:461 ksys_read+0x13f/0x240 fs/read_write.c:587 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x44/0xa9 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1176 [inline] __free_pages_ok+0xbb6/0xcc0 mm/page_alloc.c:1438 free_the_page mm/page_alloc.c:4917 [inline] __free_pages+0x47/0x1e0 mm/page_alloc.c:4923 free_thread_stack kernel/fork.c:299 [inline] release_task_stack kernel/fork.c:439 [inline] put_task_stack+0x1ed/0x220 kernel/fork.c:450 copy_process+0x47e3/0x52c0 kernel/fork.c:2316 _do_fork+0x145/0x840 kernel/fork.c:2391 __do_sys_clone kernel/fork.c:2549 [inline] __se_sys_clone kernel/fork.c:2530 [inline] __x64_sys_clone+0x20d/0x250 kernel/fork.c:2530 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Memory state around the buggy address: ffff8881e47a5f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff8881e47a5f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff8881e47a6000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8881e47a6080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881e47a6100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================