netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] tools: bpftool: return from do_event_pipe() on bad arguments
@ 2018-08-23 16:46 Quentin Monnet
  2018-08-23 16:56 ` Daniel Borkmann
  2018-08-23 17:35 ` Sergei Shtylyov
  0 siblings, 2 replies; 5+ messages in thread
From: Quentin Monnet @ 2018-08-23 16:46 UTC (permalink / raw)
  To: Daniel Borkmann, Alexei Starovoitov
  Cc: Jakub Kicinski, netdev, oss-drivers, Quentin Monnet

When command line parsing fails in the while loop in do_event_pipe()
because the number of arguments is incorrect or because the keyword is
unknown, an error message is displayed, but bpfool remains stucked in
the loop. Make sure we exit the loop upon failure.

Fixes: f412eed9dfde ("tools: bpftool: add simple perf event output reader")
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 tools/bpf/bpftool/map_perf_ring.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/bpf/bpftool/map_perf_ring.c b/tools/bpf/bpftool/map_perf_ring.c
index 1832100d1b27..6d41323be291 100644
--- a/tools/bpf/bpftool/map_perf_ring.c
+++ b/tools/bpf/bpftool/map_perf_ring.c
@@ -194,8 +194,10 @@ int do_event_pipe(int argc, char **argv)
 	}
 
 	while (argc) {
-		if (argc < 2)
+		if (argc < 2) {
 			BAD_ARG();
+			goto err_close_map;
+		}
 
 		if (is_prefix(*argv, "cpu")) {
 			char *endptr;
@@ -221,6 +223,7 @@ int do_event_pipe(int argc, char **argv)
 			NEXT_ARG();
 		} else {
 			BAD_ARG();
+			goto err_close_map;
 		}
 
 		do_all = false;
-- 
2.14.1

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

* Re: [PATCH bpf] tools: bpftool: return from do_event_pipe() on bad arguments
  2018-08-23 16:46 [PATCH bpf] tools: bpftool: return from do_event_pipe() on bad arguments Quentin Monnet
@ 2018-08-23 16:56 ` Daniel Borkmann
  2018-08-23 17:35 ` Sergei Shtylyov
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel Borkmann @ 2018-08-23 16:56 UTC (permalink / raw)
  To: Quentin Monnet, Alexei Starovoitov; +Cc: Jakub Kicinski, netdev, oss-drivers

On 08/23/2018 06:46 PM, Quentin Monnet wrote:
> When command line parsing fails in the while loop in do_event_pipe()
> because the number of arguments is incorrect or because the keyword is
> unknown, an error message is displayed, but bpfool remains stucked in
> the loop. Make sure we exit the loop upon failure.
> 
> Fixes: f412eed9dfde ("tools: bpftool: add simple perf event output reader")
> Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>

Applied to bpf, thanks Quentin!

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

* Re: [PATCH bpf] tools: bpftool: return from do_event_pipe() on bad arguments
  2018-08-23 16:46 [PATCH bpf] tools: bpftool: return from do_event_pipe() on bad arguments Quentin Monnet
  2018-08-23 16:56 ` Daniel Borkmann
@ 2018-08-23 17:35 ` Sergei Shtylyov
  2018-08-23 17:48   ` Quentin Monnet
  1 sibling, 1 reply; 5+ messages in thread
From: Sergei Shtylyov @ 2018-08-23 17:35 UTC (permalink / raw)
  To: Quentin Monnet, Daniel Borkmann, Alexei Starovoitov
  Cc: Jakub Kicinski, netdev, oss-drivers

Hello!

On 08/23/2018 07:46 PM, Quentin Monnet wrote:

> When command line parsing fails in the while loop in do_event_pipe()
> because the number of arguments is incorrect or because the keyword is
> unknown, an error message is displayed, but bpfool

   bp-who? ;-)

> remains stucked in

   Stuck.

> the loop. Make sure we exit the loop upon failure.
> 
> Fixes: f412eed9dfde ("tools: bpftool: add simple perf event output reader")
> Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
[...]

MBR, Sergei

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

* Re: [PATCH bpf] tools: bpftool: return from do_event_pipe() on bad arguments
  2018-08-23 17:35 ` Sergei Shtylyov
@ 2018-08-23 17:48   ` Quentin Monnet
  2018-08-23 18:35     ` Daniel Borkmann
  0 siblings, 1 reply; 5+ messages in thread
From: Quentin Monnet @ 2018-08-23 17:48 UTC (permalink / raw)
  To: Sergei Shtylyov, Daniel Borkmann, Alexei Starovoitov
  Cc: Jakub Kicinski, netdev, oss-drivers

2018-08-23 20:35 UTC+0300 ~ Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com>
> Hello!
> 
> On 08/23/2018 07:46 PM, Quentin Monnet wrote:
> 
>> When command line parsing fails in the while loop in do_event_pipe()
>> because the number of arguments is incorrect or because the keyword is
>> unknown, an error message is displayed, but bpfool
> 
>    bp-who? ;-)
> 
>> remains stucked in
> 
>    Stuck.
> 
>> the loop. Make sure we exit the loop upon failure.
>>
>> Fixes: f412eed9dfde ("tools: bpftool: add simple perf event output reader")
>> Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
>> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> [...]
> 
> MBR, Sergei

Thanks Sergei! The patch has been applied so I cannot fix these, but
I'll make sure to give an additional pass to my future commit logs…

Best,
Quentin

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

* Re: [PATCH bpf] tools: bpftool: return from do_event_pipe() on bad arguments
  2018-08-23 17:48   ` Quentin Monnet
@ 2018-08-23 18:35     ` Daniel Borkmann
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Borkmann @ 2018-08-23 18:35 UTC (permalink / raw)
  To: Quentin Monnet, Sergei Shtylyov, Alexei Starovoitov
  Cc: Jakub Kicinski, netdev, oss-drivers

On 08/23/2018 07:48 PM, Quentin Monnet wrote:
> 2018-08-23 20:35 UTC+0300 ~ Sergei Shtylyov
> <sergei.shtylyov@cogentembedded.com>
>> Hello!
>>
>> On 08/23/2018 07:46 PM, Quentin Monnet wrote:
>>
>>> When command line parsing fails in the while loop in do_event_pipe()
>>> because the number of arguments is incorrect or because the keyword is
>>> unknown, an error message is displayed, but bpfool
>>
>>    bp-who? ;-)
>>
>>> remains stucked in
>>
>>    Stuck.
>>
>>> the loop. Make sure we exit the loop upon failure.
>>>
>>> Fixes: f412eed9dfde ("tools: bpftool: add simple perf event output reader")
>>> Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
>>> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
>> [...]
>>
>> MBR, Sergei
> 
> Thanks Sergei! The patch has been applied so I cannot fix these, but
> I'll make sure to give an additional pass to my future commit logs…

I fixed the two commit log typos up, thanks.

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

end of thread, other threads:[~2018-08-23 22:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-23 16:46 [PATCH bpf] tools: bpftool: return from do_event_pipe() on bad arguments Quentin Monnet
2018-08-23 16:56 ` Daniel Borkmann
2018-08-23 17:35 ` Sergei Shtylyov
2018-08-23 17:48   ` Quentin Monnet
2018-08-23 18:35     ` Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).