DORMANTno replies

[PATCH iproute2] lib: bpf_legacy: fix potential NULL-pointer dereference

From: Andrea Claudi <hidden>
Date: 2021-08-07 16:59:23
Subsystem: library code, the rest · Maintainers: Andrew Morton, Linus Torvalds

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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help