KASAN: use-after-free Read in wait_consider_task

4 views
Skip to first unread message

syzbot

unread,
Sep 21, 2019, 5:19:07 AM9/21/19
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: d573e8a7 Linux 4.19.75
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=13aeb0e5600000
kernel config: https://syzkaller.appspot.com/x/.config?x=50b385e67c7b7cdf
dashboard link: https://syzkaller.appspot.com/bug?extid=a382c48dfcedbcce6b75
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17342d45600000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=107416a1600000

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

audit: type=1400 audit(1569056201.701:35): avc: denied { map } for
pid=7518 comm="bash" path="/bin/bash" dev="sda1" ino=1457
scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=system_u:object_r:file_t:s0 tclass=file permissive=1
audit: type=1400 audit(1569056208.261:36): avc: denied { map } for
pid=7531 comm="syz-executor173" path="/root/syz-executor173597656"
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 __read_once_size include/linux/compiler.h:193
[inline]
BUG: KASAN: use-after-free in wait_consider_task+0x1b51/0x3910
kernel/exit.c:1345
Read of size 4 at addr ffff88809aed44ec by task sshd/7529

CPU: 0 PID: 7529 Comm: sshd 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_load4_noabort+0x14/0x20 mm/kasan/report.c:432
__read_once_size include/linux/compiler.h:193 [inline]
wait_consider_task+0x1b51/0x3910 kernel/exit.c:1345
do_wait_thread kernel/exit.c:1454 [inline]
do_wait+0x439/0x9d0 kernel/exit.c:1525
kernel_wait4+0x171/0x290 kernel/exit.c:1668
__do_sys_wait4+0x147/0x160 kernel/exit.c:1680
__se_sys_wait4 kernel/exit.c:1676 [inline]
__x64_sys_wait4+0x97/0xf0 kernel/exit.c:1676
do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f319e1c3a3e
Code: 90 90 90 90 90 90 90 90 90 90 90 90 48 83 ec 28 8b 05 c2 eb 2d 00 85
c0 75 1d 45 31 d2 48 63 d2 48 63 ff b8 3d 00 00 00 0f 05 <48> 3d 00 f0 ff
ff 77 55 48 83 c4 28 c3 89 54 24 08 48 89 74 24 10
RSP: 002b:00007fff64d580a0 EFLAGS: 00000246 ORIG_RAX: 000000000000003d
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f319e1c3a3e
RDX: 0000000000000001 RSI: 00007fff64d580dc RDI: ffffffffffffffff
RBP: 00005559b70cac88 R08: 00007fff64d581a0 R09: 0101010101010101
R10: 0000000000000000 R11: 0000000000000246 R12: 00005559b7fd7af0
R13: 00005559b70c8fb4 R14: 0000000000000028 R15: 00005559b70caca0

Allocated by task 7529:
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 7529:
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
schedule+0x92/0x1c0 kernel/sched/core.c:3518
schedule_hrtimeout_range_clock+0x1b1/0x380 kernel/time/hrtimer.c:1947
schedule_hrtimeout_range+0x2b/0x40 kernel/time/hrtimer.c:1992
poll_schedule_timeout.constprop.0+0x11a/0x200 fs/select.c:243
do_select+0x12bd/0x16d0 fs/select.c:576
core_sys_select+0x564/0x870 fs/select.c:650
kern_select+0x15d/0x1e0 fs/select.c:691
__do_sys_select fs/select.c:700 [inline]
__se_sys_select fs/select.c:697 [inline]
__x64_sys_select+0xbe/0x150 fs/select.c:697
do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

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

Memory state around the buggy address:
ffff88809aed4380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88809aed4400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff88809aed4480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88809aed4500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88809aed4580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This bug 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 bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches

syzbot

unread,
Dec 10, 2019, 8:44:02 PM12/10/19
to syzkaller...@googlegroups.com
syzbot suspects this bug was fixed by commit:

commit 4eb92a1148342af1d6f82018d20cd862e1d3ab7e
Author: Leon Romanovsky <leo...@mellanox.com>
Date: Thu Oct 11 19:10:10 2018 +0000

RDMA/restrack: Protect from reentry to resource return path

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=17445aeae00000
start commit: d573e8a7 Linux 4.19.75
git tree: linux-4.19.y
If the result looks correct, please mark the bug fixed by replying with:

#syz fix: RDMA/restrack: Protect from reentry to resource return path

For information about bisection process see: https://goo.gl/tpsmEJ#bisection
Reply all
Reply to author
Forward
0 new messages