From: Andrea Claudi <aclaudi@redhat.com>
To: netdev@vger.kernel.org
Cc: stephen@networkplumber.org, dsahern@gmail.com, haliu@redhat.com
Subject: [PATCH iproute2] lib: bpf_legacy: fix potential NULL-pointer dereference
Date: Sat, 7 Aug 2021 18:57:38 +0200 [thread overview]
Message-ID: <4dda3f4c193e1da7ac77ee50860111243cd63065.1628352013.git.aclaudi@redhat.com> (raw)
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
reply other threads:[~2021-08-07 16:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4dda3f4c193e1da7ac77ee50860111243cd63065.1628352013.git.aclaudi@redhat.com \
--to=aclaudi@redhat.com \
--cc=dsahern@gmail.com \
--cc=haliu@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).