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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1461175313-38310-12-git-send-email-wangnan0@huawei.com>
Date:	Wed, 20 Apr 2016 18:01:51 +0000
From:	Wang Nan <wangnan0@...wei.com>
To:	<acme@...nel.org>, <jolsa@...hat.com>, <brendan.d.gregg@...il.com>
CC:	<linux-kernel@...r.kernel.org>, <pi3orama@....com>,
	Wang Nan <wangnan0@...wei.com>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	"Alexei Starovoitov" <ast@...nel.org>,
	Jiri Olsa <jolsa@...nel.org>, Li Zefan <lizefan@...wei.com>
Subject: [RFC PATCH 11/13] perf bpf: Accept ubpf programs

This patch allows user passing a UBPF function through bpf file with
section name leading with 'UBPF;'. For example:

 #define SEC(NAME) __attribute__((section(NAME), used))
 SEC("UBPF;perf_record_exit")
 void record_exit(int *samples)
 {
    char fmt[] = "Hello! receive %d samples\n";
    ubpf_printf(fmt, *samples);
 }

Signed-off-by: Wang Nan <wangnan0@...wei.com>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Alexei Starovoitov <ast@...nel.org>
Cc: Brendan Gregg <brendan.d.gregg@...il.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Li Zefan <lizefan@...wei.com>
---
 tools/perf/util/bpf-loader.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 493307d..20a0370 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -305,6 +305,19 @@ config_bpf_program(struct bpf_program *prog)
 		return PTR_ERR(config_str);
 	}
 
+	if (strncmp(config_str, "UBPF;", 5) == 0) {
+		pr_debug("bpf: load a UBPF program %s\n", config_str);
+		err = bpf_program__set_ubpf(prog);
+		if (err) {
+			char errbuf[BUFSIZ];
+
+			libbpf_strerror(err, errbuf, sizeof(errbuf));
+			pr_warning("Set %s to ubpf failed: %s\n", config_str, errbuf);
+			return err;
+		}
+		return 0;
+	}
+
 	priv = calloc(sizeof(*priv), 1);
 	if (!priv) {
 		pr_debug("bpf: failed to alloc priv\n");
@@ -607,6 +620,9 @@ int bpf__probe(struct bpf_object *obj)
 		if (err)
 			goto out;
 
+		if (bpf_program__is_ubpf(prog))
+			continue;
+
 		err = bpf_program__get_private(prog, (void **)&priv);
 		if (err || !priv)
 			goto out;
@@ -650,6 +666,9 @@ int bpf__unprobe(struct bpf_object *obj)
 	bpf_object__for_each_program(prog, obj) {
 		int i;
 
+		if (bpf_program__is_ubpf(prog))
+			continue;
+
 		err = bpf_program__get_private(prog, (void **)&priv);
 		if (err || !priv)
 			continue;
@@ -707,6 +726,9 @@ int bpf__foreach_tev(struct bpf_object *obj,
 		struct bpf_prog_priv *priv;
 		int i, fd;
 
+		if (bpf_program__is_ubpf(prog))
+			continue;
+
 		err = bpf_program__get_private(prog,
 				(void **)&priv);
 		if (err || !priv) {
-- 
1.8.3.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ