syzbot


KASAN: use-after-free Read in usb_udc_uevent (2)

Status: auto-closed as invalid on 2022/07/31 07:22
Reported-by: syzbot+e4c98459d95773ca4fd2@syzkaller.appspotmail.com
First crash: 980d, last: 964d
Similar bugs (9)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 KASAN: use-after-free Read in usb_udc_uevent 1 361d 361d 0/3 auto-obsoleted due to no activity on 2024/03/05 09:48
android-5-10 KASAN: use-after-free Read in usb_udc_uevent (3) 1 95d 95d 0/2 auto-obsoleted due to no activity on 2024/11/16 03:41
android-5-10 KASAN: use-after-free Read in usb_udc_uevent (2) 1 525d 525d 0/2 auto-obsoleted due to no activity on 2023/09/13 18:59
android-5-15 KASAN: use-after-free Read in usb_udc_uevent 1 688d 688d 0/2 auto-obsoleted due to no activity on 2023/04/11 06:40
android-54 KASAN: use-after-free Read in usb_udc_uevent 1 1407d 1407d 0/2 auto-closed as invalid on 2021/05/14 11:04
android-54 KASAN: use-after-free Read in usb_udc_uevent (3) 2 682d 720d 0/2 auto-obsoleted due to no activity on 2023/05/09 15:23
upstream KASAN: use-after-free Read in usb_udc_uevent usb syz error 30 846d 1633d 22/28 fixed on 2023/02/24 13:50
android-5-10 KASAN: use-after-free Read in usb_udc_uevent 2 650d 673d 0/2 auto-obsoleted due to no activity on 2023/05/11 18:44
android-54 KASAN: use-after-free Read in usb_udc_uevent (4) 1 307d 307d 0/2 auto-obsoleted due to no activity on 2024/04/18 10:07

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in usb_udc_uevent+0xac/0x120 drivers/usb/gadget/udc/core.c:1597
Read of size 8 at addr ffff8881cb860010 by task udevd/155

CPU: 0 PID: 155 Comm: udevd Not tainted 5.4.180-syzkaller-00088-g61c005f0f166 #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
 usb_udc_uevent+0xac/0x120 drivers/usb/gadget/udc/core.c:1597
 dev_uevent+0x41c/0x5b0 drivers/base/core.c:1887
 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:0x7f61e77f28fe
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:00007ffec65447d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 000055a28994c6a0 RCX: 00007f61e77f28fe
RDX: 0000000000001000 RSI: 000055a28994e550 RDI: 000000000000000c
RBP: 00007f61e78bf380 R08: 000000000000000c R09: 00007f61e78c2a60
R10: 0000000000000063 R11: 0000000000000246 R12: 000055a28994c6a0
R13: 0000000000000d68 R14: 00007f61e78be780 R15: 0000000000000d68

Allocated by task 15546:
 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:2856
 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 15545:
 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+0x80/0x150 mm/slub.c:1494
 slab_free mm/slub.c:3080 [inline]
 kfree+0xed/0x690 mm/slub.c:4071
 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
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_usermode_loop arch/x86/entry/common.c:163 [inline]
 prepare_exit_to_usermode+0x2b0/0x310 arch/x86/entry/common.c:194
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff8881cb860000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 16 bytes inside of
 4096-byte region [ffff8881cb860000, ffff8881cb861000)
The buggy address belongs to the page:
page:ffffea00072e1800 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:4857
 alloc_slab_page+0x39/0x3e0 mm/slub.c:343
 allocate_slab mm/slub.c:1683 [inline]
 new_slab+0x97/0x460 mm/slub.c:1749
 new_slab_objects mm/slub.c:2506 [inline]
 ___slab_alloc+0x330/0x4c0 mm/slub.c:2667
 __slab_alloc mm/slub.c:2707 [inline]
 slab_alloc_node mm/slub.c:2792 [inline]
 slab_alloc mm/slub.c:2837 [inline]
 kmem_cache_alloc_trace+0x199/0x2b0 mm/slub.c:2854
 kmalloc include/linux/slab.h:556 [inline]
 kzalloc include/linux/slab.h:690 [inline]
 kernfs_iop_get_link+0x63/0x550 fs/kernfs/symlink.c:135
 vfs_readlink+0x13f/0x3b0 fs/namei.c:4815
 do_readlinkat+0x249/0x340 fs/stat.c:411
 __do_sys_readlink fs/stat.c:432 [inline]
 __se_sys_readlink fs/stat.c:429 [inline]
 __x64_sys_readlink+0x7b/0x90 fs/stat.c:429
 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:4919 [inline]
 __free_pages+0x47/0x1e0 mm/page_alloc.c:4925
 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
 finish_task_switch+0x23f/0x550 kernel/sched/core.c:3475
 context_switch kernel/sched/core.c:3607 [inline]
 __schedule+0x886/0x1020 kernel/sched/core.c:4303
 schedule+0x13b/0x1d0 kernel/sched/core.c:4371
 smpboot_thread_fn+0x560/0x880 kernel/smpboot.c:161
 kthread+0x30f/0x330 kernel/kthread.c:288
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352

Memory state around the buggy address:
 ffff8881cb85ff00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8881cb85ff80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8881cb860000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                         ^
 ffff8881cb860080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881cb860100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/04/02 07:21 android12-5.4 61c005f0f166 79a2a8fc .config console log report info ci2-android-5-4-kasan KASAN: use-after-free Read in usb_udc_uevent
2022/03/17 14:03 android12-5.4 ffcfa2b78144 dfa9a8ed .config console log report info ci2-android-5-4-kasan KASAN: use-after-free Read in usb_udc_uevent
* Struck through repros no longer work on HEAD.