syzbot


KASAN: use-after-free Read in release_task

Status: fixed on 2019/12/09 13:28
Reported-by: syzbot+54e42b59136e39165088@syzkaller.appspotmail.com
Fix commit: 4eb92a114834 RDMA/restrack: Protect from reentry to resource return path
First crash: 1887d, last: 1884d
Fix bisection: fixed by (bisect log) :
commit 4eb92a1148342af1d6f82018d20cd862e1d3ab7e
Author: Leon Romanovsky <leonro@mellanox.com>
Date: Thu Oct 11 19:10:10 2018 +0000

  RDMA/restrack: Protect from reentry to resource return path

  

Sample crash report:
audit: type=1800 audit(1569503452.824:33): pid=7509 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:kernel_t:s0 op=collect_data cause=failed(directio) comm="startpar" name="rc.local" dev="sda1" ino=2465 res=0
kauditd_printk_skb: 2 callbacks suppressed
audit: type=1400 audit(1569503462.664:36): avc:  denied  { map } for  pid=7695 comm="syz-executor969" path="/root/syz-executor969346647" dev="sda1" ino=16484 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
==================================================================
BUG: KASAN: use-after-free in __list_del_entry_valid+0xe6/0xf5 lib/list_debug.c:51
Read of size 8 at addr ffff8880a1084710 by task ucma_close_id/7697

CPU: 1 PID: 7697 Comm: ucma_close_id Not tainted 4.19.75 #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+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report mm/kasan/report.c:412 [inline]
 kasan_report.cold+0x8c/0x2ba mm/kasan/report.c:396
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 __list_del_entry_valid+0xe6/0xf5 lib/list_debug.c:51
 __list_del_entry include/linux/list.h:117 [inline]
 list_del_rcu include/linux/rculist.h:130 [inline]
 __unhash_process kernel/exit.c:80 [inline]
 __exit_signal kernel/exit.c:156 [inline]
 release_task+0xd6d/0x1630 kernel/exit.c:201
 exit_notify kernel/exit.c:746 [inline]
 do_exit+0x14f2/0x2fa0 kernel/exit.c:896
 kthread+0x2c3/0x420 kernel/kthread.c:248
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

Allocated by task 7695:
 save_stack+0x45/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc mm/kasan/kasan.c:553 [inline]
 kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:531
 kasan_slab_alloc+0xf/0x20 mm/kasan/kasan.c:490
 kmem_cache_alloc_node+0x144/0x710 mm/slab.c:3649
 alloc_task_struct_node kernel/fork.c:157 [inline]
 dup_task_struct kernel/fork.c:802 [inline]
 copy_process.part.0+0x1ce0/0x7a30 kernel/fork.c:1732
 copy_process kernel/fork.c:1689 [inline]
 _do_fork+0x257/0xfd0 kernel/fork.c:2202
 __do_sys_clone kernel/fork.c:2309 [inline]
 __se_sys_clone kernel/fork.c:2303 [inline]
 __x64_sys_clone+0xbf/0x150 kernel/fork.c:2303
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 7697:
 save_stack+0x45/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3503 [inline]
 kmem_cache_free+0x86/0x260 mm/slab.c:3765
 free_task_struct kernel/fork.c:162 [inline]
 free_task+0xdd/0x120 kernel/fork.c:416
 __put_task_struct+0x20f/0x4c0 kernel/fork.c:689
 put_task_struct include/linux/sched/task.h:96 [inline]
 finish_task_switch+0x52b/0x780 kernel/sched/core.c:2710
 context_switch kernel/sched/core.c:2829 [inline]
 __schedule+0x86e/0x1dc0 kernel/sched/core.c:3474
 preempt_schedule_irq+0xb5/0x140 kernel/sched/core.c:3701
 retint_kernel+0x1b/0x2d
 debug_lockdep_rcu_enabled.part.0+0x2a/0x60 kernel/rcu/update.c:254
 debug_lockdep_rcu_enabled kernel/rcu/update.c:253 [inline]
 rcu_read_lock_held+0x71/0xd0 kernel/rcu/update.c:281
 release_task+0x105b/0x1630 kernel/exit.c:193
 exit_notify kernel/exit.c:746 [inline]
 do_exit+0x14f2/0x2fa0 kernel/exit.c:896
 kthread+0x2c3/0x420 kernel/kthread.c:248
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

The buggy address belongs to the object at ffff8880a1084340
 which belongs to the cache task_struct of size 6080
The buggy address is located 976 bytes inside of
 6080-byte region [ffff8880a1084340, ffff8880a1085b00)
The buggy address belongs to the page:
page:ffffea0002842100 count:1 mapcount:0 mapping:ffff88812c26d800 index:0x0 compound_mapcount: 0
flags: 0x1fffc0000008100(slab|head)
raw: 01fffc0000008100 ffffea0001fa6a88 ffffea0002845108 ffff88812c26d800
raw: 0000000000000000 ffff8880a1084340 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a1084600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a1084680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a1084700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                         ^
 ffff8880a1084780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a1084800: 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
2019/09/26 13:14 linux-4.19.y d573e8a79f70 24d405a3 .config console log report syz C ci2-linux-4-19
2019/09/24 04:05 linux-4.19.y d573e8a79f70 c68252d2 .config console log report syz C ci2-linux-4-19
* Struck through repros no longer work on HEAD.