================================================================== BUG: KASAN: use-after-free in usb_udc_uevent+0x11f/0x130 drivers/usb/gadget/udc/core.c:1645 Read of size 8 at addr ffff888014476050 by task systemd-udevd/24105 CPU: 1 PID: 24105 Comm: systemd-udevd Not tainted 5.10.0-rc2-next-20201106-syzkaller #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+0x107/0x163 lib/dump_stack.c:118 print_address_description.constprop.0.cold+0xae/0x4c8 mm/kasan/report.c:385 __kasan_report mm/kasan/report.c:545 [inline] kasan_report.cold+0x1f/0x37 mm/kasan/report.c:562 usb_udc_uevent+0x11f/0x130 drivers/usb/gadget/udc/core.c:1645 dev_uevent+0x295/0x780 drivers/base/core.c:1913 uevent_show+0x1bb/0x390 drivers/base/core.c:1969 dev_attr_show+0x4b/0x90 drivers/base/core.c:1671 sysfs_kf_seq_show+0x1f8/0x400 fs/sysfs/file.c:61 seq_read+0x432/0x1070 fs/seq_file.c:208 kernfs_fop_read+0xe9/0x590 fs/kernfs/file.c:251 vfs_read+0x1b5/0x570 fs/read_write.c:494 ksys_read+0x12d/0x250 fs/read_write.c:634 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7f9f58a71910 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:00007fff8db3c908 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 000055cff56c4240 RCX: 00007f9f58a71910 RDX: 0000000000001000 RSI: 000055cff56bd980 RDI: 0000000000000007 RBP: 00007f9f58d2c440 R08: 00007f9f58d30218 R09: 0000000000001010 R10: 000055cff56c4240 R11: 0000000000000246 R12: 0000000000001000 R13: 0000000000000d68 R14: 000055cff56bd980 R15: 00007f9f58d2b900 Allocated by task 24042: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:49 kasan_set_track mm/kasan/common.c:57 [inline] __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:480 kmalloc include/linux/slab.h:552 [inline] kzalloc include/linux/slab.h:664 [inline] dev_new drivers/usb/gadget/legacy/raw_gadget.c:182 [inline] raw_open+0x8d/0x4d0 drivers/usb/gadget/legacy/raw_gadget.c:372 misc_open+0x372/0x4a0 drivers/char/misc.c:141 chrdev_open+0x266/0x770 fs/char_dev.c:414 do_dentry_open+0x4b9/0x11b0 fs/open.c:817 do_open fs/namei.c:3252 [inline] path_openat+0x1b9a/0x2730 fs/namei.c:3369 do_filp_open+0x17e/0x3c0 fs/namei.c:3396 do_sys_openat2+0x16d/0x420 fs/open.c:1168 do_sys_open fs/open.c:1184 [inline] __do_sys_open fs/open.c:1192 [inline] __se_sys_open fs/open.c:1188 [inline] __x64_sys_open+0x119/0x1c0 fs/open.c:1188 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 24041: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:49 kasan_set_track+0x1c/0x30 mm/kasan/common.c:57 kasan_set_free_info+0x1b/0x30 mm/kasan/generic.c:356 __kasan_slab_free+0x102/0x140 mm/kasan/common.c:438 slab_free_hook mm/slub.c:1545 [inline] slab_free_freelist_hook+0x5d/0x150 mm/slub.c:1583 slab_free mm/slub.c:3155 [inline] kfree+0xdb/0x360 mm/slub.c:4154 kref_put include/linux/kref.h:65 [inline] raw_release+0x218/0x290 drivers/usb/gadget/legacy/raw_gadget.c:411 __fput+0x283/0x920 fs/file_table.c:280 task_work_run+0xdd/0x190 kernel/task_work.c:140 tracehook_notify_resume include/linux/tracehook.h:188 [inline] exit_to_user_mode_loop kernel/entry/common.c:172 [inline] exit_to_user_mode_prepare+0x1f0/0x200 kernel/entry/common.c:199 syscall_exit_to_user_mode+0x38/0x260 kernel/entry/common.c:274 entry_SYSCALL_64_after_hwframe+0x44/0xa9 The buggy address belongs to the object at ffff888014476000 which belongs to the cache kmalloc-4k of size 4096 The buggy address is located 80 bytes inside of 4096-byte region [ffff888014476000, ffff888014477000) The buggy address belongs to the page: page:00000000f4b0ebcd refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x14470 head:00000000f4b0ebcd order:3 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head) raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888010042140 raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff888014475f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888014475f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff888014476000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888014476080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888014476100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================