syzbot


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

Status: auto-obsoleted due to no activity on 2023/05/09 15:23
Reported-by: syzbot+01df223debc8da0a5199@syzkaller.appspotmail.com
First crash: 720d, last: 682d
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-54 KASAN: use-after-free Read in usb_udc_uevent (2) 2 964d 980d 0/2 auto-closed as invalid on 2022/07/31 07:22
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
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 ffff8881e8b4c010 by task udevd/487

CPU: 1 PID: 487 Comm: udevd Not tainted 5.4.219-syzkaller-00013-g4a947285bcca #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1d8/0x241 lib/dump_stack.c:118
 print_address_description+0x8c/0x630 mm/kasan/report.c:384
 __kasan_report+0xf6/0x130 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+0x4f1/0x700 drivers/base/core.c:1887
 uevent_show+0x1a1/0x2f0 drivers/base/core.c:1943
 dev_attr_show+0x50/0xc0 drivers/base/core.c:1647
 sysfs_kf_seq_show+0x264/0x3e0 fs/sysfs/file.c:61
 seq_read+0x4ca/0xda0 fs/seq_file.c:232
 __vfs_read+0x103/0x760 fs/read_write.c:425
 vfs_read+0x166/0x370 fs/read_write.c:461
 ksys_read+0x198/0x2c0 fs/read_write.c:587
 do_syscall_64+0xcb/0x1c0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x5c/0xc1

Allocated by task 19798:
 save_stack mm/kasan/common.c:70 [inline]
 set_track mm/kasan/common.c:78 [inline]
 __kasan_kmalloc+0x131/0x1e0 mm/kasan/common.c:529
 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+0x5fb/0x680 fs/char_dev.c:414
 do_dentry_open+0x946/0x10f0 fs/open.c:796
 do_last fs/namei.c:3495 [inline]
 path_openat+0x1603/0x3ea0 fs/namei.c:3614
 do_filp_open+0x208/0x450 fs/namei.c:3644
 do_sys_open+0x393/0x7e0 fs/open.c:1113
 do_syscall_64+0xcb/0x1c0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x5c/0xc1

Freed by task 19796:
 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+0x178/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+0xc6/0x260 mm/slub.c:4071
 raw_release+0x130/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:411
 __fput+0x261/0x680 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+0x1ba/0x1d0 arch/x86/entry/common.c:163
 prepare_exit_to_usermode+0x17c/0x1d0 arch/x86/entry/common.c:194
 entry_SYSCALL_64_after_hwframe+0x5c/0xc1

The buggy address belongs to the object at ffff8881e8b4c000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 16 bytes inside of
 4096-byte region [ffff8881e8b4c000, ffff8881e8b4d000)
The buggy address belongs to the page:
page:ffffea0007a2d200 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+0x194/0x380 mm/page_alloc.c:2171
 get_page_from_freelist+0x524/0x560 mm/page_alloc.c:3794
 __alloc_pages_nodemask+0x372/0x860 mm/page_alloc.c:4891
 alloc_slab_page+0x39/0x3e0 mm/slub.c:343
 allocate_slab mm/slub.c:1683 [inline]
 new_slab+0x97/0x450 mm/slub.c:1749
 new_slab_objects mm/slub.c:2505 [inline]
 ___slab_alloc+0x320/0x4a0 mm/slub.c:2667
 __slab_alloc+0x5a/0x90 mm/slub.c:2707
 slab_alloc_node mm/slub.c:2792 [inline]
 slab_alloc mm/slub.c:2837 [inline]
 kmem_cache_alloc_trace+0x129/0x240 mm/slub.c:2854
 kmalloc include/linux/slab.h:556 [inline]
 kzalloc include/linux/slab.h:690 [inline]
 kernfs_iop_get_link+0x63/0x560 fs/kernfs/symlink.c:135
 vfs_readlink+0x181/0x420 fs/namei.c:4817
 do_readlinkat+0x28f/0x3b0 fs/stat.c:410
 __do_sys_readlink fs/stat.c:431 [inline]
 __se_sys_readlink fs/stat.c:428 [inline]
 __x64_sys_readlink+0x7b/0x90 fs/stat.c:428
 do_syscall_64+0xcb/0x1c0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x5c/0xc1
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+0x7fe/0x930 mm/page_alloc.c:1438
 free_the_page mm/page_alloc.c:4953 [inline]
 __free_pages+0x8f/0x250 mm/page_alloc.c:4959
 __free_slab+0x22b/0x2e0 mm/slub.c:1774
 free_slab mm/slub.c:1789 [inline]
 discard_slab mm/slub.c:1795 [inline]
 unfreeze_partials+0x14f/0x180 mm/slub.c:2288
 put_cpu_partial+0xb5/0x150 mm/slub.c:2324
 __slab_free+0x2ac/0x370 mm/slub.c:2971
 qlist_free_all+0x4c/0xb0 mm/kasan/quarantine.c:167
 quarantine_reduce+0x174/0x190 mm/kasan/quarantine.c:260
 __kasan_kmalloc+0x43/0x1e0 mm/kasan/common.c:507
 slab_post_alloc_hook mm/slab.h:584 [inline]
 slab_alloc_node mm/slub.c:2829 [inline]
 slab_alloc mm/slub.c:2837 [inline]
 kmem_cache_alloc+0xd0/0x210 mm/slub.c:2842
 getname_flags+0xb8/0x4e0 fs/namei.c:141
 user_path_at_empty+0x28/0x50 fs/namei.c:2683
 user_path_at include/linux/namei.h:49 [inline]
 vfs_statx fs/stat.c:187 [inline]
 vfs_lstat include/linux/fs.h:3361 [inline]
 __do_sys_newlstat fs/stat.c:353 [inline]
 __se_sys_newlstat+0xde/0x860 fs/stat.c:347
 do_syscall_64+0xcb/0x1c0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x5c/0xc1

Memory state around the buggy address:
 ffff8881e8b4bf00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8881e8b4bf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8881e8b4c000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                         ^
 ffff8881e8b4c080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881e8b4c100: 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
2023/01/09 15:22 android12-5.4 4a947285bcca 1dac8c7a .config console log report info ci2-android-5-4-kasan KASAN: use-after-free Read in usb_udc_uevent
2022/12/02 02:39 android12-5.4 1c84384fbdc7 e080de16 .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.