From: Taeung Song <hidden> Date: 2018-07-19 12:10:20
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(-)
@@ -217,6 +217,14 @@ int do_pin_any(int argc, char **argv, int (*get_fd_by_id)(__u32))interr;intfd;+if(argc<3){+p_err("too few arguments, id ID and FILE path is required");+return-1;+}elseif(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));
This patch is going to be merged to the bpf-next tree, I presume, and
there is more man pages there:
$ make -C tools/bpf/bpftool/ doc
make: Entering directory 'linux/tools/bpf/bpftool'
DESCEND Documentation
make[1]: Entering directory '/linux/tools/bpf/bpftool/Documentation'
GEN bpftool-perf.8
GEN bpftool-map.8
GEN bpftool.8
GEN bpftool-prog.8
GEN bpftool-cgroup.8
GEN bpf-helpers.rst
Parsed description of 80 helper function(s)
GEN bpf-helpers.7
make[1]: Leaving directory 'linux/tools/bpf/bpftool/Documentation'
make: Leaving directory 'linux/tools/bpf/bpftool'
$ git status
On branch work
Your branch is ahead of 'pending' by 10 commits.
(use "git push" to publish your local commits)
Untracked files:
(use "git add <file>..." to include in what will be committed)
tools/bpf/bpftool/Documentation/bpf-helpers.7
tools/bpf/bpftool/Documentation/bpf-helpers.rst
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
nothing added to commit but untracked files present (use "git add" to track)
See the bpf-helpers.* files? Those are all auto-generated.
If you respin for -next please split the series and put [PATCH bpf-next
v4] as prefix of first patch, and [PATCH bpf v4] as prefix for the
second, as one of them is an improvement, and second a bug fix.
Thank you!!
This patch is going to be merged to the bpf-next tree, I presume, and
there is more man pages there:
$ make -C tools/bpf/bpftool/ doc
make: Entering directory 'linux/tools/bpf/bpftool'
DESCEND Documentation
make[1]: Entering directory '/linux/tools/bpf/bpftool/Documentation'
GEN bpftool-perf.8
GEN bpftool-map.8
GEN bpftool.8
GEN bpftool-prog.8
GEN bpftool-cgroup.8
GEN bpf-helpers.rst
Parsed description of 80 helper function(s)
GEN bpf-helpers.7
make[1]: Leaving directory 'linux/tools/bpf/bpftool/Documentation'
make: Leaving directory 'linux/tools/bpf/bpftool'
$ git status
On branch work
Your branch is ahead of 'pending' by 10 commits.
(use "git push" to publish your local commits)
Untracked files:
(use "git add <file>..." to include in what will be committed)
tools/bpf/bpftool/Documentation/bpf-helpers.7
tools/bpf/bpftool/Documentation/bpf-helpers.rst
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
nothing added to commit but untracked files present (use "git add" to track)
See the bpf-helpers.* files? Those are all auto-generated.
If you respin for -next please split the series and put [PATCH bpf-next
v4] as prefix of first patch, and [PATCH bpf v4] as prefix for the
second, as one of them is an improvement, and second a bug fix.
I've just applied patch 2/2 to bpf tree, thanks Taeung! I think best for
patch 1/2 would be if you rebase this against bpf-next tree as Jakub
mentioned so wouldn't need an immediate follow-up due to incomplete
.gitignore then.
Thanks,
Daniel
This patch is going to be merged to the bpf-next tree, I presume, and
there is more man pages there:
$ make -C tools/bpf/bpftool/ doc
make: Entering directory 'linux/tools/bpf/bpftool'
DESCEND Documentation
make[1]: Entering directory '/linux/tools/bpf/bpftool/Documentation'
GEN bpftool-perf.8
GEN bpftool-map.8
GEN bpftool.8
GEN bpftool-prog.8
GEN bpftool-cgroup.8
GEN bpf-helpers.rst
Parsed description of 80 helper function(s)
GEN bpf-helpers.7
make[1]: Leaving directory 'linux/tools/bpf/bpftool/Documentation'
make: Leaving directory 'linux/tools/bpf/bpftool'
$ git status
On branch work
Your branch is ahead of 'pending' by 10 commits.
(use "git push" to publish your local commits)
Untracked files:
(use "git add <file>..." to include in what will be committed)
tools/bpf/bpftool/Documentation/bpf-helpers.7
tools/bpf/bpftool/Documentation/bpf-helpers.rst
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
nothing added to commit but untracked files present (use "git add" to track)
See the bpf-helpers.* files? Those are all auto-generated.
If you respin for -next please split the series and put [PATCH bpf-next
v4] as prefix of first patch, and [PATCH bpf v4] as prefix for the
second, as one of them is an improvement, and second a bug fix.
I've just applied patch 2/2 to bpf tree, thanks Taeung! I think best for
patch 1/2 would be if you rebase this against bpf-next tree as Jakub
mentioned so wouldn't need an immediate follow-up due to incomplete
.gitignore then.
Thanks,
Daniel