[PATCH v2 1/2] tools/bpftool: ignore build products

Subsystems: bpf [general] (safe dynamic programs and tools), the rest

STALE2948d

3 messages, 1 author, 2018-07-19 · open the first message on its own page

[PATCH v2 1/2] tools/bpftool: ignore build products

From: Taeung Song <hidden>
Date: 2018-07-19 02:45:28

For untracked things of tools/bpf, add this.

Signed-off-by: Taeung Song <redacted>
---
 tools/bpf/.gitignore | 5 +++++
 1 file changed, 5 insertions(+)
 create mode 100644 tools/bpf/.gitignore
diff --git a/tools/bpf/.gitignore b/tools/bpf/.gitignore
new file mode 100644
index 000000000000..dfe2bd5a4b95
--- /dev/null
+++ b/tools/bpf/.gitignore
@@ -0,0 +1,5 @@
+FEATURE-DUMP.bpf
+bpf_asm
+bpf_dbg
+bpf_exp.yacc.*
+bpf_jit_disasm
-- 
2.17.1

[PATCH v2 2/2] tools/bpftool: Fix segfault case regarding 'pin' arguments

From: Taeung Song <hidden>
Date: 2018-07-19 02:45:32

Arguments of 'pin' subcommand should be checked
at the very beginning of do_pin_any().
Otherwise segfault errors can occur when using
'map pin' or 'prog pin' commands, so fix it.

  # bpftool prog pin id
  Segmentation fault

Fixes: 71bb428fe2c1 ("tools: bpf: add bpftool")
Reviewed-by: Jakub Kicinski <redacted>
Reported-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: Taeung Song <redacted>
---
 tools/bpf/bpftool/common.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index 32f9e397a6c0..3f140eff039f 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -217,6 +217,14 @@ int do_pin_any(int argc, char **argv, int (*get_fd_by_id)(__u32))
 	int err;
 	int fd;
 
+	if (argc < 3) {
+		p_err("too few arguments, id ID and FILE path is required");
+		return -1;
+	} else if (argc > 3) {
+		p_err("too many arguments");
+		return -1;
+	}
+
 	if (!is_prefix(*argv, "id")) {
 		p_err("expected 'id' got %s", *argv);
 		return -1;
@@ -230,9 +238,6 @@ int do_pin_any(int argc, char **argv, int (*get_fd_by_id)(__u32))
 	}
 	NEXT_ARG();
 
-	if (argc != 1)
-		usage();
-
 	fd = get_fd_by_id(id);
 	if (fd < 0) {
 		p_err("can't get prog by id (%u): %s", id, strerror(errno));
-- 
2.17.1

Re: [PATCH v2 1/2] tools/bpftool: ignore build products

From: Taeung Song <hidden>
Date: 2018-07-19 12:09:34

I'll resend v3 because it is better to add "bpftool*.8"
to tools/bpf/bpftool/.gitignore.

   Untracked files:
     (use "git add <file>..." to include in what will be committed)

           tools/bpf/bpftool/Documentation/bpftool-cgroup.8
           tools/bpf/bpftool/Documentation/bpftool-map.8
           tools/bpf/bpftool/Documentation/bpftool-perf.8
           tools/bpf/bpftool/Documentation/bpftool-prog.8
           tools/bpf/bpftool/Documentation/bpftool.8

Thanks,
Taeung

On 07/19/2018 11:45 AM, Taeung Song wrote:
quoted hunk
For untracked things of tools/bpf, add this.

Signed-off-by: Taeung Song <redacted>
---
  tools/bpf/.gitignore | 5 +++++
  1 file changed, 5 insertions(+)
  create mode 100644 tools/bpf/.gitignore
diff --git a/tools/bpf/.gitignore b/tools/bpf/.gitignore
new file mode 100644
index 000000000000..dfe2bd5a4b95
--- /dev/null
+++ b/tools/bpf/.gitignore
@@ -0,0 +1,5 @@
+FEATURE-DUMP.bpf
+bpf_asm
+bpf_dbg
+bpf_exp.yacc.*
+bpf_jit_disasm
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help