提交 8694d8c1 编写于 作者: A Alban Crequy 提交者: Alexei Starovoitov

tools: bpftool: fix infinite loop in map create

"bpftool map create" has an infinite loop on "while (argc)". The error
case is missing.

Symptoms: when forgetting to type the keyword 'type' in front of 'hash':
$ sudo bpftool map create /sys/fs/bpf/dir/foobar hash key 8 value 8 entries 128
(infinite loop, taking all the CPU)
^C

After the patch:
$ sudo bpftool map create /sys/fs/bpf/dir/foobar hash key 8 value 8 entries 128
Error: unknown arg hash

Fixes: 0b592b5a ("tools: bpftool: add map create command")
Signed-off-by: NAlban Crequy <alban@kinvolk.io>
Reviewed-by: NQuentin Monnet <quentin.monnet@netronome.com>
Acked-by: NSong Liu <songliubraving@fb.com>
Reviewed-by: NJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
上级 ecfc3fca
...@@ -1151,6 +1151,9 @@ static int do_create(int argc, char **argv) ...@@ -1151,6 +1151,9 @@ static int do_create(int argc, char **argv)
return -1; return -1;
} }
NEXT_ARG(); NEXT_ARG();
} else {
p_err("unknown arg %s", *argv);
return -1;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册