From: Max Kunzelmann <maxdev@posteo.de>
To: netdev@vger.kernel.org
Cc: stephen@networkplumber.org, dsahern@gmail.com,
Max Kunzelmann <maxdev@posteo.de>,
Benny Baumann <BenBE@geshi.org>,
Robert Geislinger <github@crpykng.de>
Subject: [PATCH iproute2] libnetlink: validate nlmsg header length first
Date: Tue, 7 Nov 2023 01:20:55 +0000 [thread overview]
Message-ID: <20231107012147.668074-1-maxdev@posteo.de> (raw)
Validate the nlmsg header length before accessing the nlmsg payload
length.
Fixes: 892a25e286fb ("libnetlink: break up dump function")
Signed-off-by: Max Kunzelmann <maxdev@posteo.de>
Reviewed-by: Benny Baumann <BenBE@geshi.org>
Reviewed-by: Robert Geislinger <github@crpykng.de>
---
lib/libnetlink.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index 7edcd285..01648229 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -727,13 +727,15 @@ int rtnl_dump_request_n(struct rtnl_handle *rth, struct nlmsghdr *n)
static int rtnl_dump_done(struct nlmsghdr *h,
const struct rtnl_dump_filter_arg *a)
{
- int len = *(int *)NLMSG_DATA(h);
+ int len;
if (h->nlmsg_len < NLMSG_LENGTH(sizeof(int))) {
fprintf(stderr, "DONE truncated\n");
return -1;
}
+ len = *(int *)NLMSG_DATA(h);
+
if (len < 0) {
errno = -len;
--
2.42.0
next reply other threads:[~2023-11-07 1:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-07 1:20 Max Kunzelmann [this message]
2023-11-13 16:40 ` [PATCH iproute2] libnetlink: validate nlmsg header length first patchwork-bot+netdevbpf
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=20231107012147.668074-1-maxdev@posteo.de \
--to=maxdev@posteo.de \
--cc=BenBE@geshi.org \
--cc=dsahern@gmail.com \
--cc=github@crpykng.de \
--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).