From: Yi Wang <wang.yi59@zte.com.cn>
To: peterz@infradead.org
Cc: mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, jolsa@kernel.org,
namhyung@kernel.org, ast@kernel.org, daniel@iogearbox.net,
andrii@kernel.org, kafai@fb.com, songliubraving@fb.com,
yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, bpf@vger.kernel.org,
xue.zhihong@zte.com.cn, wang.yi59@zte.com.cn,
wang.liang82@zte.com.cn, "Liu.Xiaoyang" <liu.xiaoyang@zte.com.cn>
Subject: [PATCH] perf: fix segmentation fault in perf_event__synthesize_one_bpf_prog
Date: Wed, 15 Mar 2023 14:58:18 +0800 [thread overview]
Message-ID: <20230315065818.31156-1-wang.yi59@zte.com.cn> (raw)
From: "Liu.Xiaoyang" <liu.xiaoyang@zte.com.cn>
Description of problem:
when /proc/sys/kernel/kptr_restrict set to 2 and there are bpf progs
loaded on system, ptr prog_lens and prog_addrs maybe Null.
then prog_addrs[i] and prog_lens[i] will case segmentation fault.
call trace:
perf: Segmentation fault
perf(sighandler_dump_stack+0x48)
/lib64/libc.so.6(+0x37400)
perf(perf_event__synthesize_bpf_events+0x23a)
perf(+0x235b73)
perf(cmd_record+0xc0d)
perf(+0x2a8c5d)
perf(main+0x69a)
Signed-off-by: Liu.Xiaoyang <liu.xiaoyang@zte.com.cn>
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
---
tools/perf/util/bpf-event.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
index cc7c1f9..7a6ea6d 100644
--- a/tools/perf/util/bpf-event.c
+++ b/tools/perf/util/bpf-event.c
@@ -307,6 +307,11 @@ static int perf_event__synthesize_one_bpf_prog(struct perf_session *session,
__u64 *prog_addrs = (__u64 *)(uintptr_t)(info->jited_ksyms);
int name_len;
+ if (!prog_lens || !prog_addrs) {
+ err = -1;
+ goto out;
+ }
+
*ksymbol_event = (struct perf_record_ksymbol) {
.header = {
.type = PERF_RECORD_KSYMBOL,
--
1.8.3.1
reply other threads:[~2023-03-15 7:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230315065818.31156-1-wang.yi59@zte.com.cn \
--to=wang.yi59@zte.com.cn \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=liu.xiaoyang@zte.com.cn \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=songliubraving@fb.com \
--cc=wang.liang82@zte.com.cn \
--cc=xue.zhihong@zte.com.cn \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).