tools/bpftool: Fix segfault case regarding 'pin' arguments
authorTaeung Song <treeze.taeung@gmail.com>
Thu, 19 Jul 2018 12:10:05 +0000 (21:10 +0900)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 20 Jul 2018 08:16:54 +0000 (10:16 +0200)
commit759b94a00a207ef605f3fd6f6e99570799688145
tree5cbf780a0d57a7c4b80ac978791590e734ea0b48
parentbb3928673955b423db270982ff7dad19a3e22d9c
tools/bpftool: Fix segfault case regarding 'pin' arguments

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 <jakub.kicinski@netronome.com>
Reported-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/bpf/bpftool/common.c