syzbot


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

Status: auto-obsoleted due to no activity on 2023/09/13 18:59
Reported-by: syzbot+f22c8d990ac1a87aaa68@syzkaller.appspotmail.com
First crash: 524d, last: 524d
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-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
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 649d 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+0xb0/0x120 drivers/usb/gadget/udc/core.c:1807
Read of size 8 at addr ffff88811a634010 by task udevd/450

CPU: 0 PID: 450 Comm: udevd Not tainted 5.10.178-syzkaller-00238-g8a30c9beebe8 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023
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:1807
 dev_uevent+0x4e9/0x6f0 drivers/base/core.c:2229
 uevent_show+0x1a0/0x310 drivers/base/core.c:2285
 dev_attr_show+0x56/0xd0 drivers/base/core.c:1987
 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:1970 [inline]
 new_sync_read fs/read_write.c:415 [inline]
 vfs_read+0x999/0xbb0 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/0xc6
RIP: 0033:0x7fc36c2ebb6a
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:00007ffd1d785258 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 000055e944b1b3e0 RCX: 00007fc36c2ebb6a
RDX: 0000000000001000 RSI: 000055e944b0e390 RDI: 0000000000000008
RBP: 000055e944b1b3e0 R08: 0000000000000008 R09: 0000000000040000
R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000003fff R14: 00007ffd1d785738 R15: 000000000000000a

Allocated by task 24060:
 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:384
 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:3397 [inline]
 path_openat+0x2660/0x3000 fs/namei.c:3515
 do_filp_open+0x21c/0x460 fs/namei.c:3542
 do_sys_openat2+0x13f/0x6f0 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/0xc6

Freed by task 24059:
 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:423
 __fput+0x309/0x760 fs/file_table.c:281
 ____fput+0x15/0x20 fs/file_table.c:314
 task_work_run+0x129/0x190 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_user_mode_loop+0xbf/0xd0 kernel/entry/common.c:172
 exit_to_user_mode_prepare kernel/entry/common.c:199 [inline]
 syscall_exit_to_user_mode+0xbc/0x1d0 kernel/entry/common.c:274
 do_syscall_64+0x40/0x70 arch/x86/entry/common.c:56
 entry_SYSCALL_64_after_hwframe+0x61/0xc6

The buggy address belongs to the object at ffff88811a634000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 16 bytes inside of
 4096-byte region [ffff88811a634000, ffff88811a635000)
The buggy address belongs to the page:
page:ffffea0004698c00 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88811a632000 pfn:0x11a630
head:ffffea0004698c00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head)
raw: 4000000000010200 ffffea0004601608 ffffea0005b32208 ffff888100042c00
raw: ffff88811a632000 0000000000040002 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 450, ts 507166605684, free_ts 504822668411
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2455 [inline]
 prep_new_page+0x166/0x180 mm/page_alloc.c:2461
 get_page_from_freelist+0x2d8c/0x2f30 mm/page_alloc.c:4253
 __alloc_pages_nodemask+0x435/0xaf0 mm/page_alloc.c:5345
 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]
 kmem_cache_alloc_trace+0x1bd/0x2e0 mm/slub.c:2972
 kmalloc include/linux/slab.h:552 [inline]
 kzalloc include/linux/slab.h:664 [inline]
 uevent_show+0x160/0x310 drivers/base/core.c:2280
 dev_attr_show+0x56/0xd0 drivers/base/core.c:1987
 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:1970 [inline]
 new_sync_read fs/read_write.c:415 [inline]
 vfs_read+0x999/0xbb0 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
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1348 [inline]
 __free_pages_ok+0x82c/0x850 mm/page_alloc.c:1628
 free_the_page+0x76/0x370 mm/page_alloc.c:5406
 __free_pages+0x67/0xc0 mm/page_alloc.c:5415
 __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:
 ffff88811a633f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88811a633f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88811a634000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                         ^
 ffff88811a634080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88811a634100: 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
2023/06/15 18:52 android13-5.10-lts 8a30c9beebe8 90d4044e .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.