lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230315065818.31156-1-wang.yi59@zte.com.cn>
Date:   Wed, 15 Mar 2023 14:58:18 +0800
From:   Yi Wang <wang.yi59@....com.cn>
To:     peterz@...radead.org
Cc:     mingo@...hat.com, acme@...nel.org, mark.rutland@....com,
        alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
        namhyung@...nel.org, ast@...nel.org, daniel@...earbox.net,
        andrii@...nel.org, kafai@...com, songliubraving@...com, yhs@...com,
        john.fastabend@...il.com, kpsingh@...nel.org,
        linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
        netdev@...r.kernel.org, bpf@...r.kernel.org,
        xue.zhihong@....com.cn, wang.yi59@....com.cn,
        wang.liang82@....com.cn, "Liu.Xiaoyang" <liu.xiaoyang@....com.cn>
Subject: [PATCH] perf: fix segmentation fault in perf_event__synthesize_one_bpf_prog

From: "Liu.Xiaoyang" <liu.xiaoyang@....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@....com.cn>
Signed-off-by: Yi Wang <wang.yi59@....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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ