syzbot


KASAN: use-after-free Read in dev_uevent

Status: auto-closed as invalid on 2021/09/24 00:56
Reported-by: syzbot+d918aee87b36f4240436@syzkaller.appspotmail.com
First crash: 1296d, last: 1232d
Similar bugs (6)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 KASAN: use-after-free Read in dev_uevent origin:upstream missing-backport C inconclusive 4 89d 582d 0/3 upstream: reported C repro on 2023/03/07 19:30
android-54 KASAN: use-after-free Read in dev_uevent (2) 2 1074d 1080d 0/2 auto-closed as invalid on 2022/03/01 02:09
android-6-1 KASAN: use-after-free Read in dev_uevent 6 287d 458d 0/2 auto-obsoleted due to no activity on 2024/03/27 01:05
android-5-10 KASAN: use-after-free Read in dev_uevent 1 1057d 1057d 0/2 auto-closed as invalid on 2022/02/16 03:05
upstream KASAN: use-after-free Read in dev_uevent kernel syz 54 601d 1574d 22/28 fixed on 2023/02/24 13:50
upstream KASAN: slab-use-after-free Read in dev_uevent kernel C error error 70 117d 583d 0/28 auto-obsoleted due to no activity on 2024/10/08 09:06

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in dev_uevent+0x3dd/0x730 drivers/base/core.c:1863
Read of size 8 at addr ffff8881935e2058 by task systemd-udevd/32167

CPU: 0 PID: 32167 Comm: systemd-udevd Not tainted 5.4.121-syzkaller-00750-g54f14b62ffed #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1d8/0x24e lib/dump_stack.c:118
 print_address_description+0x9b/0x650 mm/kasan/report.c:384
 __kasan_report+0x182/0x260 mm/kasan/report.c:516
 kasan_report+0x30/0x60 mm/kasan/common.c:641
 dev_uevent+0x3dd/0x730 drivers/base/core.c:1863
 uevent_show+0x1a2/0x2e0 drivers/base/core.c:1934
 dev_attr_show+0x50/0xc0 drivers/base/core.c:1638
 sysfs_kf_seq_show+0x265/0x3e0 fs/sysfs/file.c:61
 seq_read+0x4aa/0xd10 fs/seq_file.c:229
 __vfs_read+0x103/0x770 fs/read_write.c:425
 vfs_read+0x161/0x370 fs/read_write.c:461
 ksys_read+0x186/0x2b0 fs/read_write.c:587
 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7fb1cbf35910
Code: b6 fe ff ff 48 8d 3d 0f be 08 00 48 83 ec 08 e8 06 db 01 00 66 0f 1f 44 00 00 83 3d f9 2d 2c 00 00 75 10 b8 00 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 de 9b 01 00 48 89 04 24
RSP: 002b:00007ffd2dc5d0b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 0000556a694bed60 RCX: 00007fb1cbf35910
RDX: 0000000000001000 RSI: 0000556a694ac110 RDI: 0000000000000007
RBP: 00007fb1cc1f0440 R08: 00007fb1cc1f41a8 R09: 0000000000001010
R10: 0000556a694bed60 R11: 0000000000000246 R12: 0000000000001000
R13: 0000000000000d68 R14: 0000556a694ac110 R15: 00007fb1cc1ef900

Allocated by task 32114:
 save_stack mm/kasan/common.c:70 [inline]
 set_track mm/kasan/common.c:78 [inline]
 __kasan_kmalloc+0x137/0x1e0 mm/kasan/common.c:517
 kmem_cache_alloc_trace+0x139/0x2b0 mm/slub.c:2848
 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+0x949/0x1100 fs/open.c:796
 do_last fs/namei.c:3495 [inline]
 path_openat+0x1127/0x3da0 fs/namei.c:3612
 do_filp_open+0x208/0x450 fs/namei.c:3642
 do_sys_open+0x383/0x7c0 fs/open.c:1113
 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 32114:
 save_stack mm/kasan/common.c:70 [inline]
 set_track mm/kasan/common.c:78 [inline]
 kasan_set_free_info mm/kasan/common.c:333 [inline]
 __kasan_slab_free+0x18a/0x240 mm/kasan/common.c:475
 slab_free_hook mm/slub.c:1454 [inline]
 slab_free_freelist_hook+0x7b/0x150 mm/slub.c:1492
 slab_free mm/slub.c:3072 [inline]
 kfree+0xe0/0x660 mm/slub.c:4061
 raw_release+0x130/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:411
 __fput+0x27d/0x6c0 fs/file_table.c:281
 task_work_run+0x186/0x1b0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xcb9/0x2bf0 kernel/exit.c:812
 do_group_exit+0x15c/0x2c0 kernel/exit.c:910
 get_signal+0x164f/0x1fc0 kernel/signal.c:2745
 do_signal+0x8d/0x610 arch/x86/kernel/signal.c:793
 exit_to_usermode_loop arch/x86/entry/common.c:159 [inline]
 prepare_exit_to_usermode+0x207/0x310 arch/x86/entry/common.c:194
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff8881935e2000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 88 bytes inside of
 4096-byte region [ffff8881935e2000, ffff8881935e3000)
The buggy address belongs to the page:
page:ffffea00064d7800 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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC)
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook mm/page_alloc.c:2165 [inline]
 prep_new_page+0x19a/0x380 mm/page_alloc.c:2171
 get_page_from_freelist+0x550/0x8b0 mm/page_alloc.c:3794
 __alloc_pages_nodemask+0x3a2/0x880 mm/page_alloc.c:4855
 alloc_slab_page+0x39/0x3e0 mm/slub.c:342
 allocate_slab mm/slub.c:1675 [inline]
 new_slab+0x97/0x460 mm/slub.c:1741
 new_slab_objects mm/slub.c:2498 [inline]
 ___slab_alloc+0x330/0x4c0 mm/slub.c:2659
 __slab_alloc mm/slub.c:2699 [inline]
 slab_alloc_node mm/slub.c:2784 [inline]
 slab_alloc mm/slub.c:2829 [inline]
 kmem_cache_alloc_trace+0x199/0x2b0 mm/slub.c:2846
 kmalloc include/linux/slab.h:556 [inline]
 kzalloc include/linux/slab.h:690 [inline]
 kobject_uevent_env+0x252/0x1000 lib/kobject_uevent.c:524
 device_del+0xf07/0x1020 drivers/base/core.c:3086
 usb_disable_device+0x356/0x640 drivers/usb/core/message.c:1271
 usb_disconnect+0x346/0x880 drivers/usb/core/hub.c:2217
 hub_port_connect drivers/usb/core/hub.c:4974 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5238 [inline]
 port_event drivers/usb/core/hub.c:5384 [inline]
 hub_event+0x1cac/0x4e30 drivers/usb/core/hub.c:5466
 process_one_work+0x679/0x1030 kernel/workqueue.c:2277
 worker_thread+0xa6f/0x1400 kernel/workqueue.c:2423
 kthread+0x30f/0x330 kernel/kthread.c:268
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352
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_pcp_prepare+0x1a9/0x270 mm/page_alloc.c:1233
 free_unref_page_prepare mm/page_alloc.c:3085 [inline]
 free_unref_page_list+0x115/0x6c0 mm/page_alloc.c:3154
 release_pages+0x98f/0x9d0 mm/swap.c:842
 tlb_batch_pages_flush mm/mmu_gather.c:49 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:184 [inline]
 tlb_flush_mmu+0x77f/0x910 mm/mmu_gather.c:191
 tlb_finish_mmu+0xcb/0x200 mm/mmu_gather.c:272
 exit_mmap+0x2e8/0x540 mm/mmap.c:3176
 __mmput+0x34/0x240 kernel/fork.c:1089
 exit_mm kernel/exit.c:489 [inline]
 do_exit+0xc19/0x2bf0 kernel/exit.c:799
 do_group_exit+0x15c/0x2c0 kernel/exit.c:910
 __do_sys_exit_group+0x13/0x20 kernel/exit.c:921
 __ia32_sys_exit_group+0x0/0x40 kernel/exit.c:919
 __x64_sys_exit_group+0x37/0x40 kernel/exit.c:919
 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Memory state around the buggy address:
 ffff8881935e1f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8881935e1f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8881935e2000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff8881935e2080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881935e2100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/05/27 00:56 android12-5.4 54f14b62ffed 858ea628 .config console log report info ci2-android-5-4-kasan KASAN: use-after-free Read in dev_uevent
2021/04/18 04:40 android12-5.4 9d49fb308497 7e2b734b .config console log report info ci2-android-5-4-kasan KASAN: use-after-free Read in dev_uevent
2021/04/08 06:46 android12-5.4 46c5fdececa6 6a81331a .config console log report info ci2-android-5-4-kasan KASAN: use-after-free Read in dev_uevent
2021/03/24 08:41 android12-5.4 c50ff8e5608b e613994b .config console log report info ci2-android-5-4-kasan KASAN: use-after-free Read in dev_uevent
* Struck through repros no longer work on HEAD.