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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190111001933.4153792-6-songliubraving@fb.com>
Date:   Thu, 10 Jan 2019 16:19:30 -0800
From:   Song Liu <songliubraving@...com>
To:     <linux-kernel@...r.kernel.org>, <netdev@...r.kernel.org>
CC:     Song Liu <songliubraving@...com>, <peterz@...radead.org>,
        <acme@...nel.org>, <ast@...nel.org>, <daniel@...earbox.net>,
        <kernel-team@...com>, <dsahern@...il.com>
Subject: [PATCH v7 perf, bpf-next 5/8] perf, bpf: emit PERF_RECORD_KSYMBOL for BPF program load/unload

This patch enables emitting PERF_RECORD_KSYMBOL for BPF program load and
unload. A PERF_RECORD_KSYMBOL is issued for each BPF sub program.

Signed-off-by: Song Liu <songliubraving@...com>
---
 kernel/events/core.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 8a8fa1b066ff..023821605b8d 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7798,6 +7798,30 @@ static int perf_event_bpf_get_name(char *name, int len, void *data)
 	return 0;
 }
 
+static void perf_event_bpf_emit_ksymbols(struct bpf_prog *prog,
+					 enum perf_bpf_event_type type)
+{
+	bool unregister = type == PERF_BPF_EVENT_PROG_UNLOAD;
+	int i;
+
+	if (prog->aux->func_cnt == 0) {
+		perf_event_ksymbol(PERF_RECORD_KSYMBOL_TYPE_BPF,
+				   (u64)(unsigned long)prog->bpf_func,
+				   prog->jited_len, unregister,
+				   perf_event_bpf_get_name, prog);
+	} else {
+		for (i = 0; i < prog->aux->func_cnt; i++) {
+			struct bpf_prog *subprog = prog->aux->func[i];
+
+			perf_event_ksymbol(
+				PERF_RECORD_KSYMBOL_TYPE_BPF,
+				(u64)(unsigned long)subprog->bpf_func,
+				subprog->jited_len, unregister,
+				perf_event_bpf_get_name, subprog);
+		}
+	}
+}
+
 void perf_event_bpf_event(struct bpf_prog *prog,
 			  enum perf_bpf_event_type type,
 			  u16 flags)
@@ -7808,6 +7832,16 @@ void perf_event_bpf_event(struct bpf_prog *prog,
 	    type >= PERF_BPF_EVENT_MAX)
 		return;
 
+	switch (type) {
+	case PERF_BPF_EVENT_PROG_LOAD:
+	case PERF_BPF_EVENT_PROG_UNLOAD:
+		if (atomic_read(&nr_ksymbol_events))
+			perf_event_bpf_emit_ksymbols(prog, type);
+		break;
+	default:
+		break;
+	}
+
 	if (!atomic_read(&nr_bpf_events))
 		return;
 
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ