syzbot


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

Status: premoderation: reported on 2024/08/18 03:39
Reported-by: syzbot+390abd5f25a94b20c762@syzkaller.appspotmail.com
First crash: 57d, last: 57d
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 323d 323d 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 (2) 1 487d 486d 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 926d 942d 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 650d 650d 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 1369d 1369d 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 644d 682d 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 808d 1595d 22/28 fixed on 2023/02/24 13:50
android-5-10 KASAN: use-after-free Read in usb_udc_uevent 2 612d 635d 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 269d 269d 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+0xb0/0x120 drivers/usb/gadget/udc/core.c:1824
Read of size 8 at addr ffff888120d1c010 by task udevd/93

CPU: 0 PID: 93 Comm: udevd Not tainted 5.10.223-syzkaller-01561-g0890c03b8b7d #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x81/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:435 [inline]
 kasan_report+0x179/0x1c0 mm/kasan/report.c:452
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:309
 usb_udc_uevent+0xb0/0x120 drivers/usb/gadget/udc/core.c:1824
 dev_uevent+0x4e9/0x6f0 drivers/base/core.c:2244
 uevent_show+0x1b4/0x330 drivers/base/core.c:2302
 dev_attr_show+0x56/0xd0 drivers/base/core.c:2002
 sysfs_kf_seq_show+0x265/0x3e0 fs/sysfs/file.c:61
 kernfs_seq_show+0x119/0x160 fs/kernfs/file.c:168
 seq_read_iter+0x430/0xd00 fs/seq_file.c:230
 kernfs_fop_read_iter+0x145/0x470 fs/kernfs/file.c:241
 call_read_iter include/linux/fs.h:2015 [inline]
 new_sync_read fs/read_write.c:415 [inline]
 vfs_read+0x990/0xba0 fs/read_write.c:496
 ksys_read+0x199/0x2c0 fs/read_write.c:634
 __do_sys_read fs/read_write.c:644 [inline]
 __se_sys_read fs/read_write.c:642 [inline]
 __x64_sys_read+0x7b/0x90 fs/read_write.c:642
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7f173910ab6a
Code: 00 3d 00 00 41 00 75 0d 50 48 8d 3d 2d 08 0a 00 e8 ea 7d 01 00 31 c0 e9 07 ff ff ff 64 8b 04 25 18 00 00 00 85 c0 75 1b 0f 05 <48> 3d 00 f0 ff ff 76 6c 48 8b 15 8f a2 0d 00 f7 d8 64 89 02 48 83
RSP: 002b:00007ffd358f0768 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 000055be4f6dee30 RCX: 00007f173910ab6a
RDX: 0000000000001000 RSI: 000055be4f7bcaf0 RDI: 000000000000000c
RBP: 000055be4f6dee30 R08: 000000000000000c R09: 0000000000000008
R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000003fff R14: 00007ffd358f0c48 R15: 000000000000000a

Allocated by task 9148:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:430 [inline]
 ____kasan_kmalloc+0xdb/0x110 mm/kasan/common.c:509
 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:518
 kasan_kmalloc include/linux/kasan.h:254 [inline]
 kmem_cache_alloc_trace+0x18a/0x2e0 mm/slub.c:2974
 kmalloc include/linux/slab.h:552 [inline]
 kzalloc include/linux/slab.h:664 [inline]
 dev_new drivers/usb/gadget/legacy/raw_gadget.c:190 [inline]
 raw_open+0x8b/0x3c0 drivers/usb/gadget/legacy/raw_gadget.c:386
 misc_open+0x30f/0x380 drivers/char/misc.c:141
 chrdev_open+0x4f7/0x620 fs/char_dev.c:414
 do_dentry_open+0x7c1/0x10d0 fs/open.c:819
 vfs_open+0x73/0x80 fs/open.c:942
 do_open fs/namei.c:3391 [inline]
 path_openat+0x2660/0x3000 fs/namei.c:3509
 do_filp_open+0x21c/0x460 fs/namei.c:3536
 do_sys_openat2+0x13f/0x710 fs/open.c:1217
 do_sys_open fs/open.c:1233 [inline]
 __do_sys_openat fs/open.c:1249 [inline]
 __se_sys_openat fs/open.c:1244 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1244
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Freed by task 9151:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:45
 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:370
 ____kasan_slab_free+0x121/0x160 mm/kasan/common.c:362
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:370
 kasan_slab_free include/linux/kasan.h:220 [inline]
 slab_free_hook mm/slub.c:1595 [inline]
 slab_free_freelist_hook+0xc0/0x190 mm/slub.c:1621
 slab_free mm/slub.c:3203 [inline]
 kfree+0xc3/0x270 mm/slub.c:4191
 dev_free drivers/usb/gadget/legacy/raw_gadget.c:226 [inline]
 kref_put+0x701/0x7c0 include/linux/kref.h:65
 raw_release+0x145/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:425
 __fput+0x33d/0x7b0 fs/file_table.c:281
 ____fput+0x15/0x20 fs/file_table.c:314
 task_work_run+0x129/0x190 kernel/task_work.c:165
 exit_task_work include/linux/task_work.h:32 [inline]
 do_exit+0xc83/0x2a50 kernel/exit.c:863
 do_group_exit+0x141/0x310 kernel/exit.c:985
 __do_sys_exit_group kernel/exit.c:996 [inline]
 __se_sys_exit_group kernel/exit.c:994 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:994
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

The buggy address belongs to the object at ffff888120d1c000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 16 bytes inside of
 4096-byte region [ffff888120d1c000, ffff888120d1d000)
The buggy address belongs to the page:
page:ffffea0004834600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x120d18
head:ffffea0004834600 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head)
raw: 4000000000010200 dead000000000100 dead000000000122 ffff888100042c00
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), pid 306, ts 170797850398, free_ts 170388584602
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2456 [inline]
 prep_new_page+0x166/0x180 mm/page_alloc.c:2462
 get_page_from_freelist+0x2d8c/0x2f30 mm/page_alloc.c:4254
 __alloc_pages_nodemask+0x435/0xaf0 mm/page_alloc.c:5348
 allocate_slab mm/slub.c:1808 [inline]
 new_slab+0x80/0x400 mm/slub.c:1869
 new_slab_objects mm/slub.c:2627 [inline]
 ___slab_alloc+0x302/0x4b0 mm/slub.c:2791
 __slab_alloc+0x63/0xa0 mm/slub.c:2831
 slab_alloc_node mm/slub.c:2913 [inline]
 slab_alloc mm/slub.c:2955 [inline]
 __kmalloc+0x204/0x330 mm/slub.c:4029
 __kmalloc_node include/linux/slab.h:418 [inline]
 kmalloc_node include/linux/slab.h:575 [inline]
 kvmalloc_node+0x82/0x130 mm/util.c:612
 kvmalloc include/linux/mm.h:822 [inline]
 seq_buf_alloc fs/seq_file.c:38 [inline]
 seq_read_iter+0x1ff/0xd00 fs/seq_file.c:210
 kernfs_fop_read_iter+0x145/0x470 fs/kernfs/file.c:241
 call_read_iter include/linux/fs.h:2015 [inline]
 new_sync_read fs/read_write.c:415 [inline]
 vfs_read+0x990/0xba0 fs/read_write.c:496
 ksys_read+0x199/0x2c0 fs/read_write.c:634
 __do_sys_read fs/read_write.c:644 [inline]
 __se_sys_read fs/read_write.c:642 [inline]
 __x64_sys_read+0x7b/0x90 fs/read_write.c:642
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1349 [inline]
 __free_pages_ok+0x82c/0x850 mm/page_alloc.c:1629
 free_the_page+0x76/0x370 mm/page_alloc.c:5409
 __free_pages+0x67/0xc0 mm/page_alloc.c:5418
 __free_slab+0xcf/0x190 mm/slub.c:1894
 free_slab mm/slub.c:1909 [inline]
 discard_slab mm/slub.c:1915 [inline]
 unfreeze_partials+0x15e/0x190 mm/slub.c:2410
 put_cpu_partial+0xbf/0x180 mm/slub.c:2446
 __slab_free+0x2c8/0x3a0 mm/slub.c:3095
 do_slab_free mm/slub.c:3191 [inline]
 ___cache_free+0x111/0x130 mm/slub.c:3210
 qlink_free+0x50/0x90 mm/kasan/quarantine.c:157
 qlist_free_all+0x47/0xb0 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x15a/0x170 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:440
 kasan_slab_alloc include/linux/kasan.h:244 [inline]
 slab_post_alloc_hook+0x61/0x2f0 mm/slab.h:583
 slab_alloc_node mm/slub.c:2947 [inline]
 slab_alloc mm/slub.c:2955 [inline]
 kmem_cache_alloc+0x168/0x2e0 mm/slub.c:2960
 getname_flags+0xba/0x520 fs/namei.c:141
 getname+0x19/0x20 fs/namei.c:212

Memory state around the buggy address:
 ffff888120d1bf00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888120d1bf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888120d1c000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                         ^
 ffff888120d1c080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888120d1c100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/08/18 03:38 android13-5.10-lts 0890c03b8b7d dbc93b08 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in usb_udc_uevent
* Struck through repros no longer work on HEAD.