[<prev] [next>] [day] [month] [year] [list]
Message-Id: <4dda3f4c193e1da7ac77ee50860111243cd63065.1628352013.git.aclaudi@redhat.com>
Date: Sat, 7 Aug 2021 18:57:38 +0200
From: Andrea Claudi <aclaudi@...hat.com>
To: netdev@...r.kernel.org
Cc: stephen@...workplumber.org, dsahern@...il.com, haliu@...hat.com
Subject: [PATCH iproute2] lib: bpf_legacy: fix potential NULL-pointer dereference
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@...hat.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
Powered by blists - more mailing lists