KASAN: slab-out-of-bounds Read in bpf_test_finish

5 views
Skip to first unread message

syzbot

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

syzbot found the following crash on:

HEAD commit: 666c420f FROMLIST: ANDROID: binder: Add BINDER_GET_NODE_IN..
git tree: android-4.14
console output: https://syzkaller.appspot.com/x/log.txt?x=11597f69400000
kernel config: https://syzkaller.appspot.com/x/.config?x=89d929f317ea847c
dashboard link: https://syzkaller.appspot.com/bug?extid=594d3b0318a62a59d411
compiler: gcc (GCC) 8.0.1 20180413 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16d074a1400000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=121b2f69400000

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

audit: type=1400 audit(1537870356.412:8): avc: denied { prog_load } for
pid=1786 comm="syz-executor167"
scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=bpf
permissive=1
==================================================================
BUG: KASAN: slab-out-of-bounds in _copy_to_user+0x9a/0xc0 lib/usercopy.c:27
Read of size 710 at addr ffff8801d033fff3 by task syz-executor167/1786

CPU: 0 PID: 1786 Comm: syz-executor167 Not tainted 4.14.71+ #8
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
_copy_to_user+0x9a/0xc0 lib/usercopy.c:27
copy_to_user include/linux/uaccess.h:155 [inline]
bpf_test_finish.isra.0+0xc8/0x190 net/bpf/test_run.c:59
bpf_prog_test_run_skb+0x4d0/0x8c0 net/bpf/test_run.c:144
bpf_prog_test_run kernel/bpf/syscall.c:1330 [inline]
SYSC_bpf kernel/bpf/syscall.c:1602 [inline]
SyS_bpf+0x79d/0x3640 kernel/bpf/syscall.c:1547
do_syscall_64+0x19b/0x4b0 arch/x86/entry/common.c:289
entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x440339
RSP: 002b:00007ffdf4655e78 EFLAGS: 00000213 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 0000000000440339
RDX: 0000000000000028 RSI: 0000000020000180 RDI: 000000000000000a
RBP: 00000000006ca018 R08: 0000000000000000 R09: 00000000004002c8
R10: 0000000000000000 R11: 0000000000000213 R12: 0000000000401bc0
R13: 0000000000401c50 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 223:
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_array include/linux/slab.h:607 [inline]
kcalloc include/linux/slab.h:618 [inline]
alloc_pipe_info+0x15b/0x370 fs/pipe.c:650
get_pipe_inode fs/pipe.c:712 [inline]
create_pipe_files+0xdc/0x880 fs/pipe.c:745
__do_pipe_flags+0x32/0x210 fs/pipe.c:802
SYSC_pipe2 fs/pipe.c:850 [inline]
SyS_pipe2+0x83/0x160 fs/pipe.c:844
do_syscall_64+0x19b/0x4b0 arch/x86/entry/common.c:289
entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 223:
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
free_pipe_info+0x1f5/0x2a0 fs/pipe.c:683
put_pipe_info+0xb3/0xd0 fs/pipe.c:561
pipe_release+0x1a6/0x240 fs/pipe.c:582
__fput+0x25e/0x6f0 fs/file_table.c:210
task_work_run+0x116/0x190 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:191 [inline]
exit_to_usermode_loop+0x12e/0x150 arch/x86/entry/common.c:163
prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
syscall_return_slowpath arch/x86/entry/common.c:267 [inline]
do_syscall_64+0x35d/0x4b0 arch/x86/entry/common.c:294
entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff8801d033fa80
which belongs to the cache kmalloc-1024 of size 1024
The buggy address is located 371 bytes to the right of
1024-byte region [ffff8801d033fa80, ffff8801d033fe80)
The buggy address belongs to the page:
page:ffffea000740cf00 count:1 mapcount:0 mapping: (null) index:0x0
compound_mapcount: 0
flags: 0x4000000000008100(slab|head)
raw: 4000000000008100 0000000000000000 0000000000000000 00000001800e000e
raw: 0000000000000000 0000000100000001 ffff8801da802a00 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8801d033fe80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8801d033ff00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> ffff8801d033ff80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
^
ffff8801d0340000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff8801d0340080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================


---
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