* [PATCH] perf: fix segmentation fault in perf_event__synthesize_one_bpf_prog
@ 2023-03-15 6:58 Yi Wang
0 siblings, 0 replies; only message in thread
From: Yi Wang @ 2023-03-15 6:58 UTC (permalink / raw)
To: peterz
Cc: mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung,
ast, daniel, andrii, kafai, songliubraving, yhs, john.fastabend,
kpsingh, linux-perf-users, linux-kernel, netdev, bpf, xue.zhihong,
wang.yi59, wang.liang82, Liu.Xiaoyang
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-15 7:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-15 6:58 [PATCH] perf: fix segmentation fault in perf_event__synthesize_one_bpf_prog Yi Wang
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).