* [PATCH iproute2] lib: bpf_legacy: fix potential NULL-pointer dereference
@ 2021-08-07 16:57 Andrea Claudi
0 siblings, 0 replies; only message in thread
From: Andrea Claudi @ 2021-08-07 16:57 UTC (permalink / raw)
To: netdev; +Cc: stephen, dsahern, haliu
If bpf_map_fetch_name() returns NULL, strlen() hits a NULL-pointer
dereference on outer_map_name.
Fix this checking outer_map_name value, and returning false when NULL,
as already done for inner_map_name before.
Fixes: 6d61a2b55799 ("lib: add libbpf support")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
---
lib/bpf_legacy.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/bpf_legacy.c b/lib/bpf_legacy.c
index d57d2635..372bcecc 100644
--- a/lib/bpf_legacy.c
+++ b/lib/bpf_legacy.c
@@ -3298,6 +3298,9 @@ bool iproute2_is_map_in_map(const char *libbpf_map_name, struct bpf_elf_map *ima
*omap = ctx->maps[j];
outer_map_name = bpf_map_fetch_name(ctx, j);
+ if (!outer_map_name)
+ return false;
+
memcpy(omap_name, outer_map_name, strlen(outer_map_name) + 1);
return true;
--
2.31.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-08-07 16:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-07 16:57 [PATCH iproute2] lib: bpf_legacy: fix potential NULL-pointer dereference Andrea Claudi
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.