All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf] bpf: Fix incorrect use of strlen in xdp_redirect_cpu
@ 2021-11-12  2:03 Kumar Kartikeya Dwivedi
  2021-11-12 13:50 ` Alexander Lobakin
  2021-11-12 21:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2021-11-12  2:03 UTC (permalink / raw)
  To: bpf; +Cc: Alexei Starovoitov, Andrii Nakryiko

Commit b599015f044d tried to fix a bug where sizeof was incorrectly
applied to a pointer instead of the array string was being copied to, to
find the destination buffer size, but ended up using strlen, which is
still incorrect. However, on closer look ifname_buf has no other use,
hence directly use optarg.

Fixes: b599015f044d ("samples/bpf: Fix application of sizeof to pointer")
Fixes: e531a220cc59 ("samples: bpf: Convert xdp_redirect_cpu to XDP samples helper")
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 samples/bpf/xdp_redirect_cpu_user.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/samples/bpf/xdp_redirect_cpu_user.c b/samples/bpf/xdp_redirect_cpu_user.c
index d84e6949007c..a81704d3317b 100644
--- a/samples/bpf/xdp_redirect_cpu_user.c
+++ b/samples/bpf/xdp_redirect_cpu_user.c
@@ -309,7 +309,6 @@ int main(int argc, char **argv)
 	const char *mprog_filename = NULL, *mprog_name = NULL;
 	struct xdp_redirect_cpu *skel;
 	struct bpf_map_info info = {};
-	char ifname_buf[IF_NAMESIZE];
 	struct bpf_cpumap_val value;
 	__u32 infosz = sizeof(info);
 	int ret = EXIT_FAIL_OPTION;
@@ -390,10 +389,10 @@ int main(int argc, char **argv)
 		case 'd':
 			if (strlen(optarg) >= IF_NAMESIZE) {
 				fprintf(stderr, "-d/--dev name too long\n");
+				usage(argv, long_options, __doc__, mask, true, skel->obj);
 				goto end_cpu;
 			}
-			safe_strncpy(ifname_buf, optarg, strlen(ifname_buf));
-			ifindex = if_nametoindex(ifname_buf);
+			ifindex = if_nametoindex(optarg);
 			if (!ifindex)
 				ifindex = strtoul(optarg, NULL, 0);
 			if (!ifindex) {
-- 
2.33.1


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

* Re: [PATCH bpf] bpf: Fix incorrect use of strlen in xdp_redirect_cpu
  2021-11-12  2:03 [PATCH bpf] bpf: Fix incorrect use of strlen in xdp_redirect_cpu Kumar Kartikeya Dwivedi
@ 2021-11-12 13:50 ` Alexander Lobakin
  2021-11-12 21:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Lobakin @ 2021-11-12 13:50 UTC (permalink / raw)
  To: Kumar Kartikeya Dwivedi
  Cc: Alexander Lobakin, bpf, Alexei Starovoitov, Andrii Nakryiko

From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Date: Fri, 12 Nov 2021 07:33:01 +0530

> Commit b599015f044d tried to fix a bug where sizeof was incorrectly
> applied to a pointer instead of the array string was being copied to, to
> find the destination buffer size, but ended up using strlen, which is
> still incorrect. However, on closer look ifname_buf has no other use,
> hence directly use optarg.
> 
> Fixes: b599015f044d ("samples/bpf: Fix application of sizeof to pointer")
> Fixes: e531a220cc59 ("samples: bpf: Convert xdp_redirect_cpu to XDP samples helper")
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> ---

Works, thanks!

Reviewed-and-tested-by: Alexander Lobakin <alexandr.lobakin@intel.com>

Thanks,
Al

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

* Re: [PATCH bpf] bpf: Fix incorrect use of strlen in xdp_redirect_cpu
  2021-11-12  2:03 [PATCH bpf] bpf: Fix incorrect use of strlen in xdp_redirect_cpu Kumar Kartikeya Dwivedi
  2021-11-12 13:50 ` Alexander Lobakin
@ 2021-11-12 21:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-11-12 21:10 UTC (permalink / raw)
  To: Kumar Kartikeya Dwivedi; +Cc: bpf, ast, andrii

Hello:

This patch was applied to bpf/bpf.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Fri, 12 Nov 2021 07:33:01 +0530 you wrote:
> Commit b599015f044d tried to fix a bug where sizeof was incorrectly
> applied to a pointer instead of the array string was being copied to, to
> find the destination buffer size, but ended up using strlen, which is
> still incorrect. However, on closer look ifname_buf has no other use,
> hence directly use optarg.
> 
> Fixes: b599015f044d ("samples/bpf: Fix application of sizeof to pointer")
> Fixes: e531a220cc59 ("samples: bpf: Convert xdp_redirect_cpu to XDP samples helper")
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> 
> [...]

Here is the summary with links:
  - [bpf] bpf: Fix incorrect use of strlen in xdp_redirect_cpu
    https://git.kernel.org/bpf/bpf/c/ed95f45142fa

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-11-12 21:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-12  2:03 [PATCH bpf] bpf: Fix incorrect use of strlen in xdp_redirect_cpu Kumar Kartikeya Dwivedi
2021-11-12 13:50 ` Alexander Lobakin
2021-11-12 21:10 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.