]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/5.0.19/tools-bpftool-fix-infinite-loop-in-map-create.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 5.0.19 / tools-bpftool-fix-infinite-loop-in-map-create.patch
CommitLineData
e6832405
SL
1From 3d9da545144d5c2bcb96d5cf6f63a0d67fdf1c90 Mon Sep 17 00:00:00 2001
2From: Alban Crequy <alban@kinvolk.io>
3Date: Fri, 12 Apr 2019 14:40:50 +0200
4Subject: 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
9case is missing.
10
11Symptoms: 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
16After the patch:
17$ sudo bpftool map create /sys/fs/bpf/dir/foobar hash key 8 value 8 entries 128
18Error: unknown arg hash
19
20Fixes: 0b592b5a01be ("tools: bpftool: add map create command")
21Signed-off-by: Alban Crequy <alban@kinvolk.io>
22Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
23Acked-by: Song Liu <songliubraving@fb.com>
24Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
25Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
26Signed-off-by: Alexei Starovoitov <ast@kernel.org>
27Signed-off-by: Sasha Levin <sashal@kernel.org>
28---
29 tools/bpf/bpftool/map.c | 3 +++
30 1 file changed, 3 insertions(+)
31
32diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
33index 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--
472.20.1
48