Commit 8694d8c1 authored by Alban Crequy's avatar Alban Crequy Committed by 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: default avatarAlban Crequy <alban@kinvolk.io>
Reviewed-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
Acked-by: default avatarSong Liu <songliubraving@fb.com>
Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 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%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment