syzbot


KASAN: use-after-free Read in usb_udc_uevent

Status: auto-obsoleted due to no activity on 2023/05/11 18:44
Reported-by: syzbot+4debd9904ac31638c9c6@syzkaller.appspotmail.com
First crash: 457d, last: 433d
Similar bugs (8)
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 145d 145d 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 308d 308d 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 748d 764d 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 472d 472d 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 1191d 1191d 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 465d 504d 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 630d 1417d 22/26 fixed on 2023/02/24 13:50
android-54 KASAN: use-after-free Read in usb_udc_uevent (4) 1 91d 91d 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+0xb2/0x120 drivers/usb/gadget/udc/core.c:1747
Read of size 8 at addr ffff888118728010 by task udevd/160

CPU: 0 PID: 160 Comm: udevd Not tainted 5.10.161-syzkaller-00019-g416c4356f372 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/21/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/0x3c0 mm/kasan/report.c:233
 __kasan_report mm/kasan/report.c:419 [inline]
 kasan_report+0x1a4/0x1f0 mm/kasan/report.c:436
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:309
 usb_udc_uevent+0xb2/0x120 drivers/usb/gadget/udc/core.c:1747
 dev_uevent+0x4f1/0x700 drivers/base/core.c:2226
 uevent_show+0x1a6/0x330 drivers/base/core.c:2282
 dev_attr_show+0x56/0xd0 drivers/base/core.c:1984
 sysfs_kf_seq_show+0x26b/0x400 fs/sysfs/file.c:61
 kernfs_seq_show+0x117/0x160 fs/kernfs/file.c:168
 seq_read_iter+0x429/0xd20 fs/seq_file.c:230
 kernfs_fop_read_iter+0x161/0x490 fs/kernfs/file.c:241
 call_read_iter include/linux/fs.h:1963 [inline]
 new_sync_read fs/read_write.c:415 [inline]
 vfs_read+0x9e2/0xbf0 fs/read_write.c:496
 ksys_read+0x198/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 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x61/0xc6
RIP: 0033:0x7f2a925f48fe
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:00007ffd92fecf38 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00005612bf6e61a0 RCX: 00007f2a925f48fe
RDX: 0000000000001000 RSI: 00005612bf71c320 RDI: 000000000000000c
RBP: 00007f2a926c1380 R08: 000000000000000c R09: 00007f2a926c4a60
R10: 0000000000000004 R11: 0000000000000246 R12: 00005612bf6e61a0
R13: 0000000000000d68 R14: 00007f2a926c0780 R15: 0000000000000d68

Allocated by task 8481:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:428 [inline]
 ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:507
 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:516
 kasan_kmalloc include/linux/kasan.h:269 [inline]
 kmem_cache_alloc_trace+0x1dd/0x330 mm/slub.c:2983
 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+0x8a/0x3c0 drivers/usb/gadget/legacy/raw_gadget.c:384
 misc_open+0x3ea/0x440 drivers/char/misc.c:141
 chrdev_open+0x5fb/0x680 fs/char_dev.c:414
 do_dentry_open+0x7a2/0x1090 fs/open.c:819
 vfs_open+0x73/0x80 fs/open.c:942
 do_open fs/namei.c:3329 [inline]
 path_openat+0x2638/0x2fd0 fs/namei.c:3448
 do_filp_open+0x200/0x440 fs/namei.c:3475
 do_sys_openat2+0x13b/0x470 fs/open.c:1211
 do_sys_open fs/open.c:1227 [inline]
 __do_sys_openat fs/open.c:1243 [inline]
 __se_sys_openat fs/open.c:1238 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1238
 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x61/0xc6

Freed by task 8480:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4c/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:357
 ____kasan_slab_free+0x121/0x160 mm/kasan/common.c:360
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:368
 kasan_slab_free include/linux/kasan.h:235 [inline]
 slab_free_hook mm/slub.c:1604 [inline]
 slab_free_freelist_hook+0xcc/0x1a0 mm/slub.c:1630
 slab_free mm/slub.c:3212 [inline]
 kfree+0xc3/0x290 mm/slub.c:4200
 dev_free drivers/usb/gadget/legacy/raw_gadget.c:226 [inline]
 kref_put+0x79f/0x860 include/linux/kref.h:65
 raw_release+0x141/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:423
 __fput+0x348/0x7c0 fs/file_table.c:281
 ____fput+0x15/0x20 fs/file_table.c:314
 task_work_run+0x147/0x1b0 kernel/task_work.c:154
 exit_task_work include/linux/task_work.h:30 [inline]
 do_exit+0x63c/0x2340 kernel/exit.c:813
 do_group_exit+0x13a/0x300 kernel/exit.c:910
 get_signal+0xe17/0x1440 kernel/signal.c:2780
 arch_do_signal+0x8e/0x650 arch/x86/kernel/signal.c:805
 exit_to_user_mode_loop+0xa3/0xe0 kernel/entry/common.c:161
 exit_to_user_mode_prepare kernel/entry/common.c:191 [inline]
 syscall_exit_to_user_mode+0x77/0xa0 kernel/entry/common.c:266
 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 ffff888118728000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 16 bytes inside of
 4096-byte region [ffff888118728000, ffff888118729000)
The buggy address belongs to the page:
page:ffffea000461ca00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x118728
head:ffffea000461ca00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x8000000000010200(slab|head)
raw: 8000000000010200 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 0xd60c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_RETRY_MAYFAIL|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 379, ts 143722128296, free_ts 143717388293
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2386 [inline]
 prep_new_page mm/page_alloc.c:2392 [inline]
 get_page_from_freelist+0x755/0x810 mm/page_alloc.c:4073
 __alloc_pages_nodemask+0x3b6/0x890 mm/page_alloc.c:5160
 alloc_slab_page mm/slub.c:1815 [inline]
 allocate_slab+0x78/0x540 mm/slub.c:1817
 new_slab mm/slub.c:1878 [inline]
 new_slab_objects mm/slub.c:2636 [inline]
 ___slab_alloc+0x131/0x2e0 mm/slub.c:2800
 __slab_alloc+0x63/0xa0 mm/slub.c:2840
 slab_alloc_node mm/slub.c:2922 [inline]
 slab_alloc mm/slub.c:2964 [inline]
 __kmalloc+0x24f/0x360 mm/slub.c:4038
 __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]
 kvzalloc include/linux/mm.h:830 [inline]
 alloc_netdev_mqs+0x8e/0xcf0 net/core/dev.c:10491
 rtnl_create_link+0x238/0x940 net/core/rtnetlink.c:3172
 veth_newlink+0x2a0/0xba0 drivers/net/veth.c:1344
 __rtnl_newlink net/core/rtnetlink.c:3446 [inline]
 rtnl_newlink+0x158c/0x1ff0 net/core/rtnetlink.c:3494
 rtnetlink_rcv_msg+0x95a/0xc60 net/core/rtnetlink.c:5571
 netlink_rcv_skb+0x1f0/0x460 net/netlink/af_netlink.c:2515
 rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:5589
 netlink_unicast_kernel net/netlink/af_netlink.c:1313 [inline]
 netlink_unicast+0x91a/0xb10 net/netlink/af_netlink.c:1339
 netlink_sendmsg+0xa40/0xd00 net/netlink/af_netlink.c:1934
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1332 [inline]
 __free_pages_ok+0x7f8/0x830 mm/page_alloc.c:1612
 free_the_page mm/page_alloc.c:5221 [inline]
 __free_pages+0x383/0x570 mm/page_alloc.c:5228
 __free_slab+0xd3/0x190 mm/slub.c:1903
 free_slab mm/slub.c:1918 [inline]
 discard_slab mm/slub.c:1924 [inline]
 unfreeze_partials+0x17d/0x1b0 mm/slub.c:2419
 put_cpu_partial+0xc8/0x190 mm/slub.c:2455
 __slab_free+0x2d8/0x3a0 mm/slub.c:3104
 do_slab_free mm/slub.c:3200 [inline]
 ___cache_free+0x11f/0x140 mm/slub.c:3219
 qlink_free+0x38/0x40 mm/kasan/quarantine.c:146
 qlist_free_all+0x4c/0xc0 mm/kasan/quarantine.c:165
 kasan_quarantine_reduce+0x15a/0x170 mm/kasan/quarantine.c:272
 __kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:438
 kasan_slab_alloc include/linux/kasan.h:259 [inline]
 slab_post_alloc_hook include/../mm/slab.h:583 [inline]
 slab_alloc_node mm/slub.c:2956 [inline]
 slab_alloc mm/slub.c:2964 [inline]
 __kmalloc_track_caller+0x18d/0x350 mm/slub.c:4545
 kvasprintf+0xd6/0x180 lib/kasprintf.c:25
 kvasprintf_const+0x5e/0x180 lib/kasprintf.c:49
 kobject_set_name_vargs+0x61/0x120 lib/kobject.c:289
 kobject_add_varg lib/kobject.c:384 [inline]
 kobject_init_and_add+0xdb/0x190 lib/kobject.c:473

Memory state around the buggy address:
 ffff888118727f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888118727f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888118728000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                         ^
 ffff888118728080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888118728100: 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/02/10 18:44 android12-5.10-lts 416c4356f372 e29a17f5 .config console log report info ci2-android-5-10 KASAN: use-after-free Read in usb_udc_uevent
2023/01/18 05:05 android12-5.10-lts 416c4356f372 42660d9e .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.