KASAN: vmalloc-out-of-bounds Read in bpf_trace_run7

11 views
Skip to first unread message

syzbot

unread,
Jan 5, 2021, 10:25:25 AM1/5/21
to and...@kernel.org, a...@kernel.org, b...@vger.kernel.org, dan...@iogearbox.net, da...@davemloft.net, ha...@kernel.org, john.fa...@gmail.com, ka...@fb.com, kps...@kernel.org, ku...@kernel.org, linux-...@vger.kernel.org, mi...@redhat.com, net...@vger.kernel.org, ros...@goodmis.org, songliu...@fb.com, syzkall...@googlegroups.com, y...@fb.com
Hello,

syzbot found the following issue on:

HEAD commit: 00a279e4 selftests/bpf: Add tests for user- and non-CO-RE ..
git tree: bpf-next
console output: https://syzkaller.appspot.com/x/log.txt?x=11b1fc1f500000
kernel config: https://syzkaller.appspot.com/x/.config?x=2eb8bc0ec06304ce
dashboard link: https://syzkaller.appspot.com/bug?extid=fad5d91c7158ce568634
compiler: gcc (GCC) 10.1.0-syz 20200507

Unfortunately, I don't have any reproducer for this issue yet.

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

==================================================================
BUG: KASAN: vmalloc-out-of-bounds in __bpf_trace_run kernel/trace/bpf_trace.c:2088 [inline]
BUG: KASAN: vmalloc-out-of-bounds in bpf_trace_run7+0x48f/0x4a0 kernel/trace/bpf_trace.c:2130
Read of size 8 at addr ffffc90000ca0030 by task syz-executor.2/10711

CPU: 0 PID: 10711 Comm: syz-executor.2 Not tainted 5.10.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:79 [inline]
dump_stack+0x107/0x163 lib/dump_stack.c:120
print_address_description.constprop.0.cold+0x5/0x4c8 mm/kasan/report.c:385
__kasan_report mm/kasan/report.c:545 [inline]
kasan_report.cold+0x1f/0x37 mm/kasan/report.c:562
__bpf_trace_run kernel/trace/bpf_trace.c:2088 [inline]
bpf_trace_run7+0x48f/0x4a0 kernel/trace/bpf_trace.c:2130
__bpf_trace_percpu_alloc_percpu+0x1dc/0x220 include/trace/events/percpu.h:10
trace_percpu_alloc_percpu include/trace/events/percpu.h:10 [inline]
pcpu_alloc+0xbc4/0x17e0 mm/percpu.c:1844
perf_trace_event_reg kernel/trace/trace_event_perf.c:107 [inline]
perf_trace_event_init+0x35f/0xb20 kernel/trace/trace_event_perf.c:204
perf_trace_init+0x176/0x240 kernel/trace/trace_event_perf.c:228
perf_tp_event_init+0xa2/0x120 kernel/events/core.c:9563
perf_try_init_event+0x12a/0x570 kernel/events/core.c:11031
perf_init_event kernel/events/core.c:11083 [inline]
perf_event_alloc.part.0+0xe5b/0x3a40 kernel/events/core.c:11361
perf_event_alloc kernel/events/core.c:11740 [inline]
__do_sys_perf_event_open+0x647/0x2f30 kernel/events/core.c:11838
do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x45e299
Code: 0d b4 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 db b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f1784968c68 EFLAGS: 00000246
ORIG_RAX: 000000000000012a
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 000000000045e299
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000180
RBP: 000000000119bfd0 R08: 0000000000000000 R09: 0000000000000000
R10: ffffffffffffffff R11: 0000000000000246 R12: 000000000119bf8c
R13: 00007ffe18fb31bf R14: 00007f17849699c0 R15: 000000000119bf8c


Memory state around the buggy address:
ffffc90000c9ff00: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
ffffc90000c9ff80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
>ffffc90000ca0000: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
^
ffffc90000ca0080: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
ffffc90000ca0100: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
==================================================================


---
This report 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 issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
Jan 20, 2021, 6:09:25 PM1/20/21
to and...@kernel.org, a...@kernel.org, b...@vger.kernel.org, dan...@iogearbox.net, da...@davemloft.net, ha...@kernel.org, john.fa...@gmail.com, ka...@fb.com, kps...@kernel.org, ku...@kernel.org, linux-...@vger.kernel.org, mi...@redhat.com, net...@vger.kernel.org, ros...@goodmis.org, songliu...@fb.com, syzkall...@googlegroups.com, y...@fb.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 7d68e382 bpf: Permit size-0 datasec
git tree: bpf-next
console output: https://syzkaller.appspot.com/x/log.txt?x=1418c3c7500000
kernel config: https://syzkaller.appspot.com/x/.config?x=e0c7843b8af99dff
dashboard link: https://syzkaller.appspot.com/bug?extid=fad5d91c7158ce568634
compiler: gcc (GCC) 10.1.0-syz 20200507
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1224daa4d00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13dfabd0d00000

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

==================================================================
BUG: KASAN: vmalloc-out-of-bounds in __bpf_trace_run kernel/trace/bpf_trace.c:2088 [inline]
BUG: KASAN: vmalloc-out-of-bounds in bpf_trace_run7+0x411/0x420 kernel/trace/bpf_trace.c:2130
Read of size 8 at addr ffffc90000e5c030 by task syz-executor460/8508

CPU: 1 PID: 8508 Comm: syz-executor460 Not tainted 5.11.0-rc3-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:79 [inline]
dump_stack+0x107/0x163 lib/dump_stack.c:120
print_address_description.constprop.0.cold+0x5/0x2f8 mm/kasan/report.c:230
__kasan_report mm/kasan/report.c:396 [inline]
kasan_report.cold+0x79/0xd5 mm/kasan/report.c:413
__bpf_trace_run kernel/trace/bpf_trace.c:2088 [inline]
bpf_trace_run7+0x411/0x420 kernel/trace/bpf_trace.c:2130
__bpf_trace_percpu_alloc_percpu+0x1dc/0x220 include/trace/events/percpu.h:10
__traceiter_percpu_alloc_percpu+0x97/0xf0 include/trace/events/percpu.h:10
trace_percpu_alloc_percpu include/trace/events/percpu.h:10 [inline]
pcpu_alloc+0xba6/0x16f0 mm/percpu.c:1844
bpf_prog_alloc+0x78/0x250 kernel/bpf/core.c:117
bpf_prog_load+0x656/0x1f40 kernel/bpf/syscall.c:2152
__do_sys_bpf+0x1251/0x4f00 kernel/bpf/syscall.c:4380
do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x441659
Code: e8 ac e8 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 8b 09 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffebad746f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000441659
RDX: 0000000000000078 RSI: 0000000020000200 RDI: 0000000000000005
RBP: 000000000001191b R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000402470
R13: 0000000000402500 R14: 0000000000000000 R15: 0000000000000000


Memory state around the buggy address:
ffffc90000e5bf00: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
ffffc90000e5bf80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
>ffffc90000e5c000: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
^
ffffc90000e5c080: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
ffffc90000e5c100: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
==================================================================

syzbot

unread,
Jan 21, 2021, 2:14:12 AM1/21/21
to and...@kernel.org, and...@fb.com, a...@kernel.org, b...@vger.kernel.org, dan...@iogearbox.net, da...@davemloft.net, ha...@kernel.org, jakub.k...@netronome.com, john.fa...@gmail.com, ka...@fb.com, kps...@kernel.org, ku...@kernel.org, linux-...@vger.kernel.org, mi...@redhat.com, net...@vger.kernel.org, ros...@goodmis.org, songliu...@fb.com, syzkall...@googlegroups.com, xdp-n...@vger.kernel.org, y...@fb.com
syzbot has bisected this issue to:

commit 8b401f9ed2441ad9e219953927a842d24ed051fc
Author: Yonghong Song <y...@fb.com>
Date: Thu May 23 21:47:45 2019 +0000

bpf: implement bpf_send_signal() helper

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=123408e7500000
start commit: 7d68e382 bpf: Permit size-0 datasec
git tree: bpf-next
final oops: https://syzkaller.appspot.com/x/report.txt?x=113408e7500000
console output: https://syzkaller.appspot.com/x/log.txt?x=163408e7500000
Reported-by: syzbot+fad5d9...@syzkaller.appspotmail.com
Fixes: 8b401f9ed244 ("bpf: implement bpf_send_signal() helper")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

Yonghong Song

unread,
Jan 23, 2021, 2:36:29 PM1/23/21
to syzbot, and...@kernel.org, and...@fb.com, a...@kernel.org, b...@vger.kernel.org, dan...@iogearbox.net, da...@davemloft.net, ha...@kernel.org, jakub.k...@netronome.com, john.fa...@gmail.com, ka...@fb.com, kps...@kernel.org, ku...@kernel.org, linux-...@vger.kernel.org, mi...@redhat.com, net...@vger.kernel.org, ros...@goodmis.org, songliu...@fb.com, syzkall...@googlegroups.com, xdp-n...@vger.kernel.org

I can reproduce the issue with C reproducer. This is an old known issue
though and the failure is due to memory allocation failure in
tracepoint_probe_unregister().

[ 40.807849][ T8287] Call Trace:
[ 40.808201][ T8287] dump_stack+0x77/0x97
[ 40.808695][ T8287] should_fail.cold.6+0x32/0x4c
[ 40.809238][ T8287] should_failslab+0x5/0x10
[ 40.809709][ T8287] slab_pre_alloc_hook.constprop.97+0xa0/0xd0
[ 40.810365][ T8287] ? tracepoint_probe_unregister+0xc7/0x2b0
[ 40.810998][ T8287] __kmalloc+0x64/0x210
[ 40.811442][ T8287] ? trace_raw_output_percpu_destroy_chunk+0x40/0x40
[ 40.812158][ T8287] tracepoint_probe_unregister+0xc7/0x2b0
[ 40.812766][ T8287] bpf_raw_tp_link_release+0x11/0x20
[ 40.813328][ T8287] bpf_link_free+0x20/0x40
[ 40.813802][ T8287] bpf_link_release+0xc/0x10
[ 40.814242][ T8287] __fput+0xa1/0x250
[ 40.814606][ T8287] task_work_run+0x68/0xb0
[ 40.815030][ T8287] exit_to_user_mode_prepare+0x22c/0x250

Steven Rostedt has the following pending patch
https://lore.kernel.org/bpf/20201118093...@gandalf.local.home/
trying to solve this exact problem.

syzbot

unread,
Sep 3, 2022, 2:37:29 PM9/3/22
to syzkall...@googlegroups.com
Auto-closing this bug as obsolete.
No recent activity, existing reproducers are no longer triggering the issue.
Reply all
Reply to author
Forward
0 new messages