syzbot


KASAN: use-after-free Read in usb_udc_uevent
Status: upstream: reported on 2020/06/02 13:21
Reported-by: syzbot+b0de012ceb1e2a97891b@syzkaller.appspotmail.com
First crash: 724d, last: 8d03h
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-54 KASAN: use-after-free Read in usb_udc_uevent (2) 2 53d 69d 0/2 upstream: reported on 2022/03/17 14:04
android-54 KASAN: use-after-free Read in usb_udc_uevent 1 496d 496d 0/2 auto-closed as invalid on 2021/05/14 11:04

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in usb_udc_uevent+0x11f/0x130 drivers/usb/gadget/udc/core.c:1749
Read of size 8 at addr ffff8880779c6050 by task udevd/3786

CPU: 0 PID: 3786 Comm: udevd Not tainted 5.18.0-rc7-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0xeb/0x495 mm/kasan/report.c:313
 print_report mm/kasan/report.c:429 [inline]
 kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491
 usb_udc_uevent+0x11f/0x130 drivers/usb/gadget/udc/core.c:1749
 dev_uevent+0x295/0x780 drivers/base/core.c:2335
 uevent_show+0x1b8/0x380 drivers/base/core.c:2391
 dev_attr_show+0x4b/0x90 drivers/base/core.c:2094
 sysfs_kf_seq_show+0x219/0x3d0 fs/sysfs/file.c:59
 seq_read_iter+0x4f5/0x1280 fs/seq_file.c:230
 kernfs_fop_read_iter+0x514/0x6f0 fs/kernfs/file.c:236
 call_read_iter include/linux/fs.h:2044 [inline]
 new_sync_read+0x384/0x5f0 fs/read_write.c:401
 vfs_read+0x492/0x5d0 fs/read_write.c:482
 ksys_read+0x127/0x250 fs/read_write.c:620
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7ff2e3b258fe
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:00007fff2df0abc8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00005613e1fd5620 RCX: 00007ff2e3b258fe
RDX: 0000000000001000 RSI: 00005613e2039500 RDI: 0000000000000008
RBP: 00007ff2e3bf2380 R08: 0000000000000008 R09: 00007ff2e3bf5a60
R10: 0000000000000080 R11: 0000000000000246 R12: 00005613e1fd5620
R13: 0000000000000d68 R14: 00007ff2e3bf1780 R15: 0000000000000d68
 </TASK>

Allocated by task 17897:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:436 [inline]
 ____kasan_kmalloc mm/kasan/common.c:515 [inline]
 ____kasan_kmalloc mm/kasan/common.c:474 [inline]
 __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:524
 kmalloc include/linux/slab.h:581 [inline]
 kzalloc include/linux/slab.h:714 [inline]
 dev_new drivers/usb/gadget/legacy/raw_gadget.c:184 [inline]
 raw_open+0x87/0x4c0 drivers/usb/gadget/legacy/raw_gadget.c:374
 misc_open+0x372/0x4a0 drivers/char/misc.c:141
 chrdev_open+0x266/0x770 fs/char_dev.c:414
 do_dentry_open+0x4a1/0x11e0 fs/open.c:824
 do_open fs/namei.c:3476 [inline]
 path_openat+0x1c71/0x2910 fs/namei.c:3609
 do_filp_open+0x1aa/0x400 fs/namei.c:3636
 do_sys_openat2+0x16d/0x4c0 fs/open.c:1213
 do_sys_open fs/open.c:1229 [inline]
 __do_sys_openat fs/open.c:1245 [inline]
 __se_sys_openat fs/open.c:1240 [inline]
 __x64_sys_openat+0x13f/0x1f0 fs/open.c:1240
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 17896:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track+0x21/0x30 mm/kasan/common.c:45
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
 ____kasan_slab_free mm/kasan/common.c:366 [inline]
 ____kasan_slab_free+0x166/0x1a0 mm/kasan/common.c:328
 kasan_slab_free include/linux/kasan.h:200 [inline]
 slab_free_hook mm/slub.c:1728 [inline]
 slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1754
 slab_free mm/slub.c:3510 [inline]
 kfree+0xd6/0x4d0 mm/slub.c:4552
 kref_put include/linux/kref.h:65 [inline]
 raw_release+0x218/0x290 drivers/usb/gadget/legacy/raw_gadget.c:413
 __fput+0x277/0x9d0 fs/file_table.c:317
 task_work_run+0xdd/0x1a0 kernel/task_work.c:164
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:169 [inline]
 exit_to_user_mode_prepare+0x23c/0x250 kernel/entry/common.c:201
 __syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline]
 syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:294
 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x44/0xae

The buggy address belongs to the object at ffff8880779c6000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 80 bytes inside of
 4096-byte region [ffff8880779c6000, ffff8880779c7000)

The buggy address belongs to the physical page:
page:ffffea0001de7000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x779c0
head:ffffea0001de7000 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea00016a1000 dead000000000002 ffff888010c42140
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 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3164, tgid 3164 (S30dbus), ts 24599775912, free_ts 24542733611
 prep_new_page mm/page_alloc.c:2441 [inline]
 get_page_from_freelist+0xba2/0x3e00 mm/page_alloc.c:4182
 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5408
 alloc_pages+0x1aa/0x310 mm/mempolicy.c:2272
 alloc_slab_page mm/slub.c:1799 [inline]
 allocate_slab+0x26c/0x3c0 mm/slub.c:1944
 new_slab mm/slub.c:2004 [inline]
 ___slab_alloc+0x8df/0xf20 mm/slub.c:3005
 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3092
 slab_alloc_node mm/slub.c:3183 [inline]
 slab_alloc mm/slub.c:3225 [inline]
 kmem_cache_alloc_trace+0x310/0x3f0 mm/slub.c:3256
 kmalloc include/linux/slab.h:581 [inline]
 kzalloc include/linux/slab.h:714 [inline]
 tomoyo_find_next_domain+0x126/0x1f80 security/tomoyo/domain.c:714
 tomoyo_bprm_check_security security/tomoyo/tomoyo.c:101 [inline]
 tomoyo_bprm_check_security+0x121/0x1a0 security/tomoyo/tomoyo.c:91
 security_bprm_check+0x45/0xa0 security/security.c:866
 search_binary_handler fs/exec.c:1714 [inline]
 exec_binprm fs/exec.c:1767 [inline]
 bprm_execve fs/exec.c:1836 [inline]
 bprm_execve+0x732/0x1970 fs/exec.c:1798
 do_execveat_common+0x727/0x890 fs/exec.c:1941
 do_execve fs/exec.c:2011 [inline]
 __do_sys_execve fs/exec.c:2087 [inline]
 __se_sys_execve fs/exec.c:2082 [inline]
 __x64_sys_execve+0x8f/0xc0 fs/exec.c:2082
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1356 [inline]
 free_pcp_prepare+0x549/0xd20 mm/page_alloc.c:1406
 free_unref_page_prepare mm/page_alloc.c:3328 [inline]
 free_unref_page+0x19/0x6a0 mm/page_alloc.c:3423
 __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2523
 qlink_free mm/kasan/quarantine.c:157 [inline]
 qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0xa2/0xc0 mm/kasan/common.c:446
 kasan_slab_alloc include/linux/kasan.h:224 [inline]
 slab_post_alloc_hook mm/slab.h:749 [inline]
 slab_alloc_node mm/slub.c:3217 [inline]
 slab_alloc mm/slub.c:3225 [inline]
 __kmalloc+0x200/0x350 mm/slub.c:4410
 kmalloc include/linux/slab.h:586 [inline]
 tomoyo_add_entry security/tomoyo/common.c:2022 [inline]
 tomoyo_supervisor+0xce6/0xf00 security/tomoyo/common.c:2094
 tomoyo_audit_path_log security/tomoyo/file.c:168 [inline]
 tomoyo_path_permission security/tomoyo/file.c:587 [inline]
 tomoyo_path_permission+0x270/0x3a0 security/tomoyo/file.c:573
 tomoyo_check_open_permission+0x33e/0x380 security/tomoyo/file.c:777
 tomoyo_file_open security/tomoyo/tomoyo.c:311 [inline]
 tomoyo_file_open+0x9d/0xc0 security/tomoyo/tomoyo.c:306
 security_file_open+0x45/0xb0 security/security.c:1651
 do_dentry_open+0x349/0x11e0 fs/open.c:811
 do_open fs/namei.c:3476 [inline]
 path_openat+0x1c71/0x2910 fs/namei.c:3609
 do_filp_open+0x1aa/0x400 fs/namei.c:3636
 do_sys_openat2+0x16d/0x4c0 fs/open.c:1213

Memory state around the buggy address:
 ffff8880779c5f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880779c5f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880779c6000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                 ^
 ffff8880779c6080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880779c6100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (26):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce 2022/05/17 23:00 upstream 42226c989789 744a39e2 .config log report info KASAN: use-after-free Read in usb_udc_uevent
ci-upstream-kasan-gce 2022/05/13 20:07 upstream f3f19f939c11 107f6434 .config log report info KASAN: use-after-free Read in usb_udc_uevent
ci-qemu-upstream 2022/05/03 18:56 upstream ef8e4d3c2ab1 dc9e5259 .config log report info KASAN: use-after-free Read in usb_udc_uevent
ci-upstream-kasan-gce-selinux-root 2022/04/29 00:07 upstream 259b897e5a79 e9076525 .config log report info KASAN: use-after-free Read in usb_udc_uevent
ci-upstream-kasan-gce-smack-root 2021/12/06 02:02 upstream 944207047ca4 a617004c .config log report info KASAN: use-after-free Read in usb_udc_uevent
ci-upstream-kasan-gce 2021/08/20 16:47 upstream d992fe5318d8 b599f2fc .config log report info KASAN: use-after-free Read in usb_udc_uevent
ci-upstream-kasan-gce 2021/08/12 16:53 upstream 1746f4db5135 6972b106 .config log report info KASAN: use-after-free Read in usb_udc_uevent
ci-upstream-kasan-gce-root 2021/07/21 02:47 upstream 8cae8cd89f05 1b201b48 .config log report info KASAN: use-after-free Read in usb_udc_uevent
ci-upstream-kasan-gce-root 2021/07/17 14:06 upstream d980cc0620ae f115ae98 .config log report info KASAN: use-after-free Read in usb_udc_uevent
ci-upstream-kasan-gce-root 2021/07/09 03:47 upstream 3dbdb38e2869 1b20171a .config log report info KASAN: use-after-free Read in usb_udc_uevent
ci-upstream-kasan-gce 2021/05/10 04:58 upstream 6efb943b8616 bc5434be .config log report info KASAN: use-after-free Read in usb_udc_uevent
ci-upstream-kasan-gce 2021/04/25 00:57 upstream 8db5efb83fa9 17f0b706 .config log report info KASAN: use-after-free Read in usb_udc_uevent
ci-qemu-upstream-386 2022/04/26 14:42 upstream d615b5416f8a 1fa34c1b .config log report info KASAN: use-after-free Read in usb_udc_uevent
ci-upstream-linux-next-kasan-gce-root 2022/02/09 15:09 linux-next ef6b35306dd8 0b33604d .config log report info KASAN: use-after-free Read in usb_udc_uevent
ci-upstream-linux-next-kasan-gce-root 2022/01/08 20:06 linux-next b8170452cd51 2ca0d385 .config log report info KASAN: use-after-free Read in usb_udc_uevent
ci-upstream-linux-next-kasan-gce-root 2021/12/27 02:22 linux-next ea586a076e8a e4f103c4 .config log report info KASAN: use-after-free Read in usb_udc_uevent
ci2-upstream-usb 2021/04/21 15:25 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 4b853c236c7b 95777977 .config log report info KASAN: use-after-free Read in usb_udc_uevent
ci-upstream-kasan-gce-root 2020/12/28 23:27 upstream 5c8fe583cce5 8259d56c .config log report info
ci-upstream-kasan-gce-root 2020/12/11 08:36 upstream 33dc9614dc20 f900b48c .config log report info
ci-upstream-kasan-gce-root 2020/11/21 01:47 upstream 4d02da974ea8 740ff461 .config log report info
ci-upstream-kasan-gce-selinux-root 2020/07/16 06:51 upstream 994e99a96c9b f3bec699 .config log report
ci-upstream-kasan-gce-selinux-root 2020/06/02 13:56 upstream f359287765c0 52fd7b7d .config log report
ci-upstream-kasan-gce-smack-root 2020/05/31 03:45 upstream ffeb595d8481 6f3e1c7c .config log report
ci-upstream-kasan-gce-386 2020/11/17 11:27 upstream 9c87c9f41245 1bf9a662 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/11/10 06:24 linux-next c34f157421f6 64069d48 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/11/07 15:29 linux-next c34f157421f6 64069d48 .config log report info