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

4 views
Skip to first unread message

syzbot

unread,
Dec 1, 2022, 9:39:37 PM12/1/22
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 1c84384fbdc7 Merge tag 'android12-5.4.219_r00' into androi..
git tree: android12-5.4
console output: https://syzkaller.appspot.com/x/log.txt?x=11f331a1880000
kernel config: https://syzkaller.appspot.com/x/.config?x=c29947a309dbd4d3
dashboard link: https://syzkaller.appspot.com/bug?extid=01df223debc8da0a5199
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/cf55c9bd09b4/disk-1c84384f.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/505e757f14ad/vmlinux-1c84384f.xz
kernel image: https://storage.googleapis.com/syzbot-assets/ad1a0815b668/bzImage-1c84384f.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+01df22...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in usb_udc_uevent+0xac/0x120 drivers/usb/gadget/udc/core.c:1597
Read of size 8 at addr ffff8881ed1ea010 by task udevd/1128

CPU: 0 PID: 1128 Comm: udevd Not tainted 5.4.219-syzkaller-00093-g1c84384fbdc7 #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 17662:
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 17661:
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 ffff8881ed1ea000
which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 16 bytes inside of
4096-byte region [ffff8881ed1ea000, ffff8881ed1eb000)
The buggy address belongs to the page:
page:ffffea0007b47a00 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
do_sys_open+0x34e/0x7e0 fs/open.c:1107
do_syscall_64+0xcb/0x1c0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x5c/0xc1

Memory state around the buggy address:
ffff8881ed1e9f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8881ed1e9f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8881ed1ea000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8881ed1ea080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8881ed1ea100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
May 9, 2023, 11:23:53 AM5/9/23
to syzkaller-a...@googlegroups.com
Auto-closing this bug as obsolete.
Crashes did not happen for a while, no reproducer and no activity.
Reply all
Reply to author
Forward
0 new messages