mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH bpf v2] tools: bpftool: fix infinite loop in map create
@ 2019-04-12 12:40 Alban Crequy
  2019-04-12 13:20 ` Quentin Monnet
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Alban Crequy @ 2019-04-12 12:40 UTC (permalink / raw)
  To: ast, daniel; +Cc: bpf, netdev, linux-kernel, alban, iago

From: Alban Crequy <alban@kinvolk.io>

"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: 0b592b5a01be ("tools: bpftool: add map create command")
Signed-off-by: Alban Crequy <alban@kinvolk.io>

---

Changes in v2:
- Explain the cause of the bug in commitmsg
- Add the "fixes" line in the commitmsg (Jakub's review)
- Rebase on the bpf tree

v1 was initially based on bpf-next and submitted on
https://marc.info/?l=linux-kernel&m=155310327709613&w=2
---
 tools/bpf/bpftool/map.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index 05b029b934a6..1ccc38718458 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -1151,6 +1151,9 @@ static int do_create(int argc, char **argv)
 				return -1;
 			}
 			NEXT_ARG();
+		} else {
+			p_err("unknown arg %s", *argv);
+			return -1;
 		}
 	}
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-04-16  9:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-12 12:40 [PATCH bpf v2] tools: bpftool: fix infinite loop in map create Alban Crequy
2019-04-12 13:20 ` Quentin Monnet
2019-04-12 18:07   ` Song Liu
2019-04-12 23:45 ` Jakub Kicinski
2019-04-16  8:52 ` Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®