syzbot


KASAN: use-after-free Read in dec_rlimit_ucounts

Status: auto-closed as invalid on 2022/04/09 01:56
Subsystems: kernel
[Documentation on labels]
Reported-by: syzbot+3d8df6bbc77b00ffb512@syzkaller.appspotmail.com
First crash: 1061d, last: 1002d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Write in dec_rlimit_ucounts kernel C 4 1145d 1178d 20/28 fixed on 2021/11/10 13:22

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in dec_rlimit_ucounts+0xf9/0x170 kernel/ucount.c:285
Read of size 8 at addr ffff88807471c280 by task kworker/0:6/3668

CPU: 0 PID: 3668 Comm: kworker/0:6 Not tainted 5.16.0-rc8-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events free_ipc
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1dc/0x2d8 lib/dump_stack.c:106
 print_address_description+0x65/0x380 mm/kasan/report.c:247
 __kasan_report mm/kasan/report.c:433 [inline]
 kasan_report+0x19a/0x1f0 mm/kasan/report.c:450
 dec_rlimit_ucounts+0xf9/0x170 kernel/ucount.c:285
 mqueue_evict_inode+0x554/0x6a0 ipc/mqueue.c:537
 evict+0x2a4/0x620 fs/inode.c:590
 __dentry_kill+0x43e/0x660 fs/dcache.c:582
 shrink_dentry_list+0x6bd/0x880 fs/dcache.c:1176
 shrink_dcache_parent+0xcd/0x830
 do_one_tree+0x23/0xe0 fs/dcache.c:1657
 shrink_dcache_for_umount+0x79/0x150 fs/dcache.c:1674
 generic_shutdown_super+0x63/0x300 fs/super.c:447
 kill_anon_super fs/super.c:1059 [inline]
 kill_litter_super+0x71/0xa0 fs/super.c:1068
 deactivate_locked_super+0xa7/0xf0 fs/super.c:335
 cleanup_mnt+0x462/0x510 fs/namespace.c:1137
 mntput_no_expire+0xe63/0xfe0 fs/namespace.c:1223
 free_ipc_ns ipc/namespace.c:123 [inline]
 free_ipc+0x82/0x1e0 ipc/namespace.c:141
 process_one_work+0x853/0x1140 kernel/workqueue.c:2298
 worker_thread+0xac1/0x1320 kernel/workqueue.c:2445
 kthread+0x468/0x490 kernel/kthread.c:327
 ret_from_fork+0x1f/0x30
 </TASK>

Allocated by task 4298:
 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:434 [inline]
 __kasan_slab_alloc+0xb6/0xf0 mm/kasan/common.c:467
 kasan_slab_alloc include/linux/kasan.h:259 [inline]
 slab_post_alloc_hook mm/slab.h:519 [inline]
 slab_alloc_node mm/slub.c:3234 [inline]
 slab_alloc mm/slub.c:3242 [inline]
 kmem_cache_alloc+0x1c9/0x310 mm/slub.c:3247
 kmem_cache_zalloc include/linux/slab.h:714 [inline]
 create_user_ns+0x60f/0x1470 kernel/user_namespace.c:105
 copy_creds+0x3bb/0xd40 kernel/cred.c:370
 copy_process+0xc0a/0x5ca0 kernel/fork.c:2063
 kernel_clone+0x22a/0x7e0 kernel/fork.c:2582
 __do_sys_clone kernel/fork.c:2699 [inline]
 __se_sys_clone kernel/fork.c:2683 [inline]
 __x64_sys_clone+0x245/0x2b0 kernel/fork.c:2683
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 7806:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4c/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:370
 ____kasan_slab_free+0x10d/0x150 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:235 [inline]
 slab_free_hook mm/slub.c:1723 [inline]
 slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1749
 slab_free mm/slub.c:3513 [inline]
 kmem_cache_free+0xa4/0x180 mm/slub.c:3530
 free_user_ns+0x24b/0x340 kernel/user_namespace.c:202
 process_one_work+0x853/0x1140 kernel/workqueue.c:2298
 worker_thread+0xac1/0x1320 kernel/workqueue.c:2445
 kthread+0x468/0x490 kernel/kthread.c:327
 ret_from_fork+0x1f/0x30

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xfa/0x130 mm/kasan/generic.c:348
 insert_work+0x54/0x400 kernel/workqueue.c:1354
 __queue_work+0x928/0xc60 kernel/workqueue.c:1520
 queue_work_on+0x12b/0x220 kernel/workqueue.c:1547
 put_user_ns include/linux/user_namespace.h:156 [inline]
 put_cred_rcu+0x28a/0x400 kernel/cred.c:125
 rcu_do_batch kernel/rcu/tree.c:2506 [inline]
 rcu_core+0x9b8/0x1610 kernel/rcu/tree.c:2741
 __do_softirq+0x392/0x7a3 kernel/softirq.c:558

The buggy address belongs to the object at ffff88807471c000
 which belongs to the cache user_namespace of size 776
The buggy address is located 640 bytes inside of
 776-byte region [ffff88807471c000, ffff88807471c308)
The buggy address belongs to the page:
page:ffffea0001d1c700 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88807471c388 pfn:0x7471c
head:ffffea0001d1c700 order:2 compound_mapcount:0 compound_pincount:0
memcg:ffff88801d634701
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff88814074a640
raw: ffff88807471c388 0000000080120011 00000001ffffffff ffff88801d634701
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 4298, ts 175749434180, free_ts 174753316226
 prep_new_page mm/page_alloc.c:2418 [inline]
 get_page_from_freelist+0x729/0x9e0 mm/page_alloc.c:4149
 __alloc_pages+0x255/0x580 mm/page_alloc.c:5369
 alloc_slab_page mm/slub.c:1793 [inline]
 allocate_slab+0xcc/0x540 mm/slub.c:1930
 new_slab mm/slub.c:1993 [inline]
 ___slab_alloc+0x41e/0xc40 mm/slub.c:3022
 __slab_alloc mm/slub.c:3109 [inline]
 slab_alloc_node mm/slub.c:3200 [inline]
 slab_alloc mm/slub.c:3242 [inline]
 kmem_cache_alloc+0x276/0x310 mm/slub.c:3247
 kmem_cache_zalloc include/linux/slab.h:714 [inline]
 create_user_ns+0x60f/0x1470 kernel/user_namespace.c:105
 copy_creds+0x3bb/0xd40 kernel/cred.c:370
 copy_process+0xc0a/0x5ca0 kernel/fork.c:2063
 kernel_clone+0x22a/0x7e0 kernel/fork.c:2582
 __do_sys_clone kernel/fork.c:2699 [inline]
 __se_sys_clone kernel/fork.c:2683 [inline]
 __x64_sys_clone+0x245/0x2b0 kernel/fork.c:2683
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 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:1338 [inline]
 free_pcp_prepare+0xd1c/0xe00 mm/page_alloc.c:1389
 free_unref_page_prepare mm/page_alloc.c:3309 [inline]
 free_unref_page+0x7d/0x580 mm/page_alloc.c:3388
 __stack_depot_save+0x449/0x4a0 lib/stackdepot.c:391
 kasan_save_stack mm/kasan/common.c:40 [inline]
 kasan_set_track+0x68/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:370
 ____kasan_slab_free+0x10d/0x150 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:235 [inline]
 slab_free_hook mm/slub.c:1723 [inline]
 slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1749
 slab_free mm/slub.c:3513 [inline]
 kfree+0xe1/0x330 mm/slub.c:4561
 kvm_arch_vcpu_destroy+0xe5/0x240 arch/x86/kvm/x86.c:10998
 kvm_vcpu_destroy+0x29/0x90 arch/x86/kvm/../../../virt/kvm/kvm_main.c:441
 kvm_free_vcpus arch/x86/kvm/x86.c:11426 [inline]
 kvm_arch_destroy_vm+0x3ef/0x6b0 arch/x86/kvm/x86.c:11545
 kvm_destroy_vm arch/x86/kvm/../../../virt/kvm/kvm_main.c:1189 [inline]
 kvm_put_kvm+0x751/0xe40 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1220
 kvm_vcpu_release+0x53/0x60 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3489
 __fput+0x3fc/0x870 fs/file_table.c:280
 task_work_run+0x146/0x1c0 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:175 [inline]
 exit_to_user_mode_prepare+0x209/0x220 kernel/entry/common.c:207

Memory state around the buggy address:
 ffff88807471c180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807471c200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807471c280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88807471c300: fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88807471c380: fc 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
2022/01/09 01:56 upstream 21f35d2ca83e 2ca0d385 .config console log report info ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in dec_rlimit_ucounts
2021/11/10 23:18 linux-next 73e5c18006f5 75b04091 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in dec_rlimit_ucounts
* Struck through repros no longer work on HEAD.