]>
Commit | Line | Data |
---|---|---|
e6832405 SL |
1 | From 3d9da545144d5c2bcb96d5cf6f63a0d67fdf1c90 Mon Sep 17 00:00:00 2001 |
2 | From: Alban Crequy <alban@kinvolk.io> | |
3 | Date: Fri, 12 Apr 2019 14:40:50 +0200 | |
4 | Subject: tools: bpftool: fix infinite loop in map create | |
5 | ||
6 | [ Upstream commit 8694d8c1f82cccec9380e0d3720b84eee315dfb7 ] | |
7 | ||
8 | "bpftool map create" has an infinite loop on "while (argc)". The error | |
9 | case is missing. | |
10 | ||
11 | Symptoms: when forgetting to type the keyword 'type' in front of 'hash': | |
12 | $ sudo bpftool map create /sys/fs/bpf/dir/foobar hash key 8 value 8 entries 128 | |
13 | (infinite loop, taking all the CPU) | |
14 | ^C | |
15 | ||
16 | After the patch: | |
17 | $ sudo bpftool map create /sys/fs/bpf/dir/foobar hash key 8 value 8 entries 128 | |
18 | Error: unknown arg hash | |
19 | ||
20 | Fixes: 0b592b5a01be ("tools: bpftool: add map create command") | |
21 | Signed-off-by: Alban Crequy <alban@kinvolk.io> | |
22 | Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com> | |
23 | Acked-by: Song Liu <songliubraving@fb.com> | |
24 | Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> | |
25 | Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> | |
26 | Signed-off-by: Alexei Starovoitov <ast@kernel.org> | |
27 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
28 | --- | |
29 | tools/bpf/bpftool/map.c | 3 +++ | |
30 | 1 file changed, 3 insertions(+) | |
31 | ||
32 | diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c | |
33 | index 1ef1ee2280a28..227766d9f43b1 100644 | |
34 | --- a/tools/bpf/bpftool/map.c | |
35 | +++ b/tools/bpf/bpftool/map.c | |
36 | @@ -1111,6 +1111,9 @@ static int do_create(int argc, char **argv) | |
37 | return -1; | |
38 | } | |
39 | NEXT_ARG(); | |
40 | + } else { | |
41 | + p_err("unknown arg %s", *argv); | |
42 | + return -1; | |
43 | } | |
44 | } | |
45 | ||
46 | -- | |
47 | 2.20.1 | |
48 |