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: <1431860222-61636-32-git-send-email-wangnan0@huawei.com>
Date:	Sun, 17 May 2015 10:56:56 +0000
From:	Wang Nan <wangnan0@...wei.com>
To:	<paulus@...ba.org>, <a.p.zijlstra@...llo.nl>, <mingo@...hat.com>,
	<acme@...nel.org>, <namhyung@...nel.org>, <jolsa@...nel.org>,
	<dsahern@...il.com>, <ast@...mgrid.com>, <daniel@...earbox.net>,
	<brendan.d.gregg@...il.com>, <masami.hiramatsu.pt@...achi.com>
CC:	<lizefan@...wei.com>, <linux-kernel@...r.kernel.org>,
	<pi3orama@....com>
Subject: [RFC PATCH v3 31/37] perf bpf: Collect all eBPF programs

This patch collects 'struct bpf_prog_handler *' after opening an object
file. Handlers are stored into an array of MAX_PROBES slots.

Signed-off-by: Wang Nan <wangnan0@...wei.com>
---
 tools/perf/util/bpf-loader.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 17cd2b6..67bfb62 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -8,6 +8,7 @@
 #include "perf.h"
 #include "debug.h"
 #include "bpf-loader.h"
+#include "probe-finder.h" // for MAX_PROBES
 
 #define DEFINE_PRINT_FN(name, level) \
 static int libbpf_##name(const char *fmt, ...)	\
@@ -32,11 +33,17 @@ static bool libbpf_inited = false;
 struct {
 	struct bpf_object *objects[MAX_OBJECTS];
 	size_t nr_objects;
+
+	struct {
+		struct bpf_prog_handler *prog;
+	} progs[MAX_PROBES];
+	size_t nr_progs;
 } params;
 
 int bpf_prepare_load(const char *filename)
 {
 	struct bpf_object *obj;
+	struct bpf_prog_handler *prog;
 
 	if (!libbpf_inited)
 		libbpf_set_print(libbpf_warning,
@@ -57,6 +64,24 @@ int bpf_prepare_load(const char *filename)
 	}
 
 	params.objects[params.nr_objects++] = obj;
+
+	bpf_obj_for_each_prog(obj, prog) {
+		const char *title;
+
+		if (params.nr_progs + 1 > MAX_PROBES) {
+			pr_err("Too many programs. "
+			       "Increase MAX_PROBES\n");
+			return -EMFILE;
+		}
+
+		params.progs[params.nr_progs++].prog = prog;
+
+		if (bpf_prog_get_title(prog, &title, false)) {
+			pr_err("Unable to get title of a program\n");
+			return -EINVAL;
+		}
+		pr_debug("bpf: add program '%s'\n", title);
+	}
 	return 0;
 }
 
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ