KASAN: use-after-free Read in perf_output_read

8 views
Skip to first unread message

syzbot

unread,
Apr 10, 2019, 8:00:23 PM4/10/19
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: def7f547 ANDROID: arm64 defconfig / build config for cuttl..
git tree: android-4.14
console output: https://syzkaller.appspot.com/x/log.txt?x=1205388b400000
kernel config: https://syzkaller.appspot.com/x/.config?x=90aa0b84f0f13b56
dashboard link: https://syzkaller.appspot.com/bug?extid=882da54068f9d25233e1
compiler: gcc (GCC) 8.0.1 20180413 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=175b3e47400000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11165733400000

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

==================================================================
BUG: KASAN: use-after-free in perf_output_read_group
kernel/events/core.c:5874 [inline]
BUG: KASAN: use-after-free in perf_output_read+0xe4d/0xfb0
kernel/events/core.c:5909
Read of size 8 at addr ffff8881d27cfc78 by task syz-executor589/2137

CPU: 0 PID: 2137 Comm: syz-executor589 Not tainted 4.14.84+ #13
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0xb9/0x11b lib/dump_stack.c:53
print_address_description+0x60/0x22b mm/kasan/report.c:252
kasan_report_error mm/kasan/report.c:351 [inline]
kasan_report.cold.6+0x11b/0x2dd mm/kasan/report.c:409
perf_output_read_group kernel/events/core.c:5874 [inline]
perf_output_read+0xe4d/0xfb0 kernel/events/core.c:5909
perf_output_sample+0x10dd/0x1780 kernel/events/core.c:5951
__perf_event_output kernel/events/core.c:6261 [inline]
perf_event_output_forward+0x121/0x230 kernel/events/core.c:6274
__perf_event_overflow+0x116/0x320 kernel/events/core.c:7510
perf_swevent_overflow+0x166/0x1f0 kernel/events/core.c:7586
perf_swevent_event+0x19c/0x270 kernel/events/core.c:7619
do_perf_sw_event kernel/events/core.c:7727 [inline]
___perf_sw_event+0x296/0x480 kernel/events/core.c:7758
__perf_sw_event+0x3f/0x70 kernel/events/core.c:7770
perf_sw_event include/linux/perf_event.h:1041 [inline]
__do_page_fault+0x77f/0xb60 arch/x86/mm/fault.c:1466
page_fault+0x22/0x50 arch/x86/entry/entry_64.S:1104
RIP: 0010:copy_user_enhanced_fast_string+0x7/0x10
arch/x86/lib/copy_user_64.S:180
RSP: 0018:ffff8881cff97b48 EFLAGS: 00010206
RAX: 0000000000000000 RBX: 0000000000001000 RCX: 0000000000000500
RDX: 0000000000001000 RSI: ffff8881cfd99b00 RDI: 00000000203f1000
RBP: 00000000203f0500 R08: 0000000000000000 R09: 0000000000000040
R10: ffffed1039fb33ff R11: ffff8881cfd99fff R12: ffff8881cfd99000
R13: 00007ffffffff000 R14: 00000000203f1500 R15: 0000000000001000
copy_user_generic arch/x86/include/asm/uaccess_64.h:37 [inline]
raw_copy_to_user arch/x86/include/asm/uaccess_64.h:112 [inline]
copyout+0x99/0xc0 lib/iov_iter.c:137
copy_page_to_iter_iovec lib/iov_iter.c:206 [inline]
copy_page_to_iter+0x31d/0xd40 lib/iov_iter.c:710
pipe_to_user+0xa6/0x160 fs/splice.c:1237
splice_from_pipe_feed fs/splice.c:502 [inline]
__splice_from_pipe+0x324/0x740 fs/splice.c:626
vmsplice_to_user+0x1bd/0x1e0 fs/splice.c:1272
SYSC_vmsplice fs/splice.c:1353 [inline]
SyS_vmsplice+0x12f/0x150 fs/splice.c:1334
do_syscall_64+0x19b/0x4b0 arch/x86/entry/common.c:289
entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x446529
RSP: 002b:00007f52a91feda8 EFLAGS: 00000246 ORIG_RAX: 0000000000000116
RAX: ffffffffffffffda RBX: 00000000006dbc58 RCX: 0000000000446529
RDX: 0000000000000001 RSI: 0000000020000000 RDI: 0000000000000003
RBP: 00000000006dbc50 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dbc5c
R13: 0004000000000011 R14: 00007f52a91ff9c0 R15: 00000000006dbd4c

Allocated by task 2134:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc.part.1+0x4f/0xd0 mm/kasan/kasan.c:551
__kmalloc+0x153/0x340 mm/slub.c:3760
kmalloc include/linux/slab.h:493 [inline]
kzalloc include/linux/slab.h:661 [inline]
rb_alloc+0x33/0x460 kernel/events/ring_buffer.c:722
perf_mmap+0xc42/0x1370 kernel/events/core.c:5459
call_mmap include/linux/fs.h:1787 [inline]
mmap_region+0x836/0xfb0 mm/mmap.c:1731
do_mmap+0x551/0xb80 mm/mmap.c:1509
do_mmap_pgoff include/linux/mm.h:2167 [inline]
vm_mmap_pgoff+0x180/0x1d0 mm/util.c:333
SYSC_mmap_pgoff mm/mmap.c:1559 [inline]
SyS_mmap_pgoff+0xf8/0x1a0 mm/mmap.c:1517
do_syscall_64+0x19b/0x4b0 arch/x86/entry/common.c:289
entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 0:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0xac/0x190 mm/kasan/kasan.c:524
slab_free_hook mm/slub.c:1389 [inline]
slab_free_freelist_hook mm/slub.c:1410 [inline]
slab_free mm/slub.c:2966 [inline]
kfree+0xf5/0x310 mm/slub.c:3897
__rcu_reclaim kernel/rcu/rcu.h:195 [inline]
rcu_do_batch kernel/rcu/tree.c:2691 [inline]
invoke_rcu_callbacks kernel/rcu/tree.c:2945 [inline]
__rcu_process_callbacks kernel/rcu/tree.c:2912 [inline]
rcu_process_callbacks+0x54d/0xee0 kernel/rcu/tree.c:2929
__do_softirq+0x20d/0x9bd kernel/softirq.c:288

The buggy address belongs to the object at ffff8881d27cfb80
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 248 bytes inside of
512-byte region [ffff8881d27cfb80, ffff8881d27cfd80)
The buggy address belongs to the page:
page:ffffea000749f380 count:1 mapcount:0 mapping: (null) index:0x0
compound_mapcount: 0
flags: 0x4000000000008100(slab|head)
raw: 4000000000008100 0000000000000000 0000000000000000 00000001800c000c
raw: dead000000000100 dead000000000200 ffff8881da802c00 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8881d27cfb00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8881d27cfb80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff8881d27cfc00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8881d27cfc80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8881d27cfd00: 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
Reply all
Reply to author
Forward
0 new messages