netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] tools, bpftool: Avoid array index warnings.
@ 2020-10-27 23:36 Ian Rogers
  2020-10-27 23:36 ` [PATCH 2/2] tools, bpftool: Remove two unused variables Ian Rogers
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ian Rogers @ 2020-10-27 23:36 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, John Fastabend, KP Singh,
	Nathan Chancellor, Nick Desaulniers, Quentin Monnet,
	Michal Rostecki, Toke Høiland-Jørgensen,
	Tobias Klauser, linux-kernel, netdev, bpf
  Cc: Ian Rogers

The bpf_caps array is shorter without CAP_BPF, avoid out of bounds reads
if this isn't defined. Working around this avoids -Wno-array-bounds with
clang.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/bpf/bpftool/feature.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/bpf/bpftool/feature.c b/tools/bpf/bpftool/feature.c
index a43a6f10b564..359960a8f1de 100644
--- a/tools/bpf/bpftool/feature.c
+++ b/tools/bpf/bpftool/feature.c
@@ -843,9 +843,14 @@ static int handle_perms(void)
 		else
 			p_err("missing %s%s%s%s%s%s%s%srequired for full feature probing; run as root or use 'unprivileged'",
 			      capability_msg(bpf_caps, 0),
+#ifdef CAP_BPF
 			      capability_msg(bpf_caps, 1),
 			      capability_msg(bpf_caps, 2),
-			      capability_msg(bpf_caps, 3));
+			      capability_msg(bpf_caps, 3)
+#else
+				"", "", "", "", "", ""
+#endif /* CAP_BPF */
+				);
 		goto exit_free;
 	}
 
-- 
2.29.0.rc2.309.g374f81d7ae-goog


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

* [PATCH 2/2] tools, bpftool: Remove two unused variables.
  2020-10-27 23:36 [PATCH 1/2] tools, bpftool: Avoid array index warnings Ian Rogers
@ 2020-10-27 23:36 ` Ian Rogers
  2020-10-28  3:41   ` Andrii Nakryiko
  2020-10-28 13:45   ` Tobias Klauser
  2020-10-28  3:40 ` [PATCH 1/2] tools, bpftool: Avoid array index warnings Andrii Nakryiko
  2020-10-28 13:44 ` Tobias Klauser
  2 siblings, 2 replies; 6+ messages in thread
From: Ian Rogers @ 2020-10-27 23:36 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, John Fastabend, KP Singh,
	Nathan Chancellor, Nick Desaulniers, Quentin Monnet,
	Michal Rostecki, Toke Høiland-Jørgensen,
	Tobias Klauser, linux-kernel, netdev, bpf
  Cc: Ian Rogers

Avoid an unused variable warning.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/bpf/bpftool/skeleton/profiler.bpf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/bpf/bpftool/skeleton/profiler.bpf.c b/tools/bpf/bpftool/skeleton/profiler.bpf.c
index 4e3512f700c0..ce5b65e07ab1 100644
--- a/tools/bpf/bpftool/skeleton/profiler.bpf.c
+++ b/tools/bpf/bpftool/skeleton/profiler.bpf.c
@@ -70,7 +70,7 @@ int BPF_PROG(fentry_XXX)
 static inline void
 fexit_update_maps(u32 id, struct bpf_perf_event_value *after)
 {
-	struct bpf_perf_event_value *before, diff, *accum;
+	struct bpf_perf_event_value *before, diff;
 
 	before = bpf_map_lookup_elem(&fentry_readings, &id);
 	/* only account samples with a valid fentry_reading */
@@ -95,7 +95,7 @@ int BPF_PROG(fexit_XXX)
 {
 	struct bpf_perf_event_value readings[MAX_NUM_MATRICS];
 	u32 cpu = bpf_get_smp_processor_id();
-	u32 i, one = 1, zero = 0;
+	u32 i, zero = 0;
 	int err;
 	u64 *count;
 
-- 
2.29.0.rc2.309.g374f81d7ae-goog


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

* Re: [PATCH 1/2] tools, bpftool: Avoid array index warnings.
  2020-10-27 23:36 [PATCH 1/2] tools, bpftool: Avoid array index warnings Ian Rogers
  2020-10-27 23:36 ` [PATCH 2/2] tools, bpftool: Remove two unused variables Ian Rogers
@ 2020-10-28  3:40 ` Andrii Nakryiko
  2020-10-28 13:44 ` Tobias Klauser
  2 siblings, 0 replies; 6+ messages in thread
From: Andrii Nakryiko @ 2020-10-28  3:40 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, John Fastabend, KP Singh,
	Nathan Chancellor, Nick Desaulniers, Quentin Monnet,
	Michal Rostecki, Toke Høiland-Jørgensen,
	Tobias Klauser, open list, Networking, bpf

On Tue, Oct 27, 2020 at 4:37 PM Ian Rogers <irogers@google.com> wrote:
>
> The bpf_caps array is shorter without CAP_BPF, avoid out of bounds reads
> if this isn't defined. Working around this avoids -Wno-array-bounds with
> clang.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---

Acked-by: Andrii Nakryiko <andrii@kernel.org>

>  tools/bpf/bpftool/feature.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/tools/bpf/bpftool/feature.c b/tools/bpf/bpftool/feature.c
> index a43a6f10b564..359960a8f1de 100644
> --- a/tools/bpf/bpftool/feature.c
> +++ b/tools/bpf/bpftool/feature.c
> @@ -843,9 +843,14 @@ static int handle_perms(void)
>                 else
>                         p_err("missing %s%s%s%s%s%s%s%srequired for full feature probing; run as root or use 'unprivileged'",
>                               capability_msg(bpf_caps, 0),
> +#ifdef CAP_BPF
>                               capability_msg(bpf_caps, 1),
>                               capability_msg(bpf_caps, 2),
> -                             capability_msg(bpf_caps, 3));
> +                             capability_msg(bpf_caps, 3)
> +#else
> +                               "", "", "", "", "", ""
> +#endif /* CAP_BPF */
> +                               );
>                 goto exit_free;
>         }
>
> --
> 2.29.0.rc2.309.g374f81d7ae-goog
>

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

* Re: [PATCH 2/2] tools, bpftool: Remove two unused variables.
  2020-10-27 23:36 ` [PATCH 2/2] tools, bpftool: Remove two unused variables Ian Rogers
@ 2020-10-28  3:41   ` Andrii Nakryiko
  2020-10-28 13:45   ` Tobias Klauser
  1 sibling, 0 replies; 6+ messages in thread
From: Andrii Nakryiko @ 2020-10-28  3:41 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, John Fastabend, KP Singh,
	Nathan Chancellor, Nick Desaulniers, Quentin Monnet,
	Michal Rostecki, Toke Høiland-Jørgensen,
	Tobias Klauser, open list, Networking, bpf

On Tue, Oct 27, 2020 at 4:37 PM Ian Rogers <irogers@google.com> wrote:
>
> Avoid an unused variable warning.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---

Acked-by: Andrii Nakryiko <andrii@kernel.org>

>  tools/bpf/bpftool/skeleton/profiler.bpf.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/bpf/bpftool/skeleton/profiler.bpf.c b/tools/bpf/bpftool/skeleton/profiler.bpf.c
> index 4e3512f700c0..ce5b65e07ab1 100644
> --- a/tools/bpf/bpftool/skeleton/profiler.bpf.c
> +++ b/tools/bpf/bpftool/skeleton/profiler.bpf.c
> @@ -70,7 +70,7 @@ int BPF_PROG(fentry_XXX)
>  static inline void
>  fexit_update_maps(u32 id, struct bpf_perf_event_value *after)
>  {
> -       struct bpf_perf_event_value *before, diff, *accum;
> +       struct bpf_perf_event_value *before, diff;
>
>         before = bpf_map_lookup_elem(&fentry_readings, &id);
>         /* only account samples with a valid fentry_reading */
> @@ -95,7 +95,7 @@ int BPF_PROG(fexit_XXX)
>  {
>         struct bpf_perf_event_value readings[MAX_NUM_MATRICS];
>         u32 cpu = bpf_get_smp_processor_id();
> -       u32 i, one = 1, zero = 0;
> +       u32 i, zero = 0;
>         int err;
>         u64 *count;
>
> --
> 2.29.0.rc2.309.g374f81d7ae-goog
>

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

* Re: [PATCH 1/2] tools, bpftool: Avoid array index warnings.
  2020-10-27 23:36 [PATCH 1/2] tools, bpftool: Avoid array index warnings Ian Rogers
  2020-10-27 23:36 ` [PATCH 2/2] tools, bpftool: Remove two unused variables Ian Rogers
  2020-10-28  3:40 ` [PATCH 1/2] tools, bpftool: Avoid array index warnings Andrii Nakryiko
@ 2020-10-28 13:44 ` Tobias Klauser
  2 siblings, 0 replies; 6+ messages in thread
From: Tobias Klauser @ 2020-10-28 13:44 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, John Fastabend, KP Singh,
	Nathan Chancellor, Nick Desaulniers, Quentin Monnet,
	Michal Rostecki, Toke Høiland-Jørgensen, linux-kernel,
	netdev, bpf

On 2020-10-28 at 00:36:45 +0100, Ian Rogers <irogers@google.com> wrote:
> The bpf_caps array is shorter without CAP_BPF, avoid out of bounds reads
> if this isn't defined. Working around this avoids -Wno-array-bounds with
> clang.
> 
> Signed-off-by: Ian Rogers <irogers@google.com>

Reviewed-by: Tobias Klauser <tklauser@distanz.ch>

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

* Re: [PATCH 2/2] tools, bpftool: Remove two unused variables.
  2020-10-27 23:36 ` [PATCH 2/2] tools, bpftool: Remove two unused variables Ian Rogers
  2020-10-28  3:41   ` Andrii Nakryiko
@ 2020-10-28 13:45   ` Tobias Klauser
  1 sibling, 0 replies; 6+ messages in thread
From: Tobias Klauser @ 2020-10-28 13:45 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, John Fastabend, KP Singh,
	Nathan Chancellor, Nick Desaulniers, Quentin Monnet,
	Michal Rostecki, Toke Høiland-Jørgensen, linux-kernel,
	netdev, bpf

On 2020-10-28 at 00:36:46 +0100, Ian Rogers <irogers@google.com> wrote:
> Avoid an unused variable warning.
> 
> Signed-off-by: Ian Rogers <irogers@google.com>

Reviewed-by: Tobias Klauser <tklauser@distanz.ch>

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

end of thread, other threads:[~2020-10-28 23:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-27 23:36 [PATCH 1/2] tools, bpftool: Avoid array index warnings Ian Rogers
2020-10-27 23:36 ` [PATCH 2/2] tools, bpftool: Remove two unused variables Ian Rogers
2020-10-28  3:41   ` Andrii Nakryiko
2020-10-28 13:45   ` Tobias Klauser
2020-10-28  3:40 ` [PATCH 1/2] tools, bpftool: Avoid array index warnings Andrii Nakryiko
2020-10-28 13:44 ` Tobias Klauser

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).