Skip to contentSkip to conversation

libnetlink: validate nlmsg header length first

PATCH Applied Max Kunzelmann 2 participants 2 messages Nov 7, 2023 – Nov 13, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libnetlink: validate nlmsg header length first

Validate the nlmsg header length before accessing the nlmsg payload length.

Fixes 892a25e286fb ("libnetlink: break up dump function")
---
 lib/libnetlink.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/libnetlink.c +3 -1
index 7edcd285..01648229 100644
@@ -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;
 
Signature · 1 line
2.42.0
#1 lore raw
This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:

Hello:

This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:

Quoted 10 lines · On Tue, 7 Nov 2023 01:20:55 +0000 you wrote:

Validate the nlmsg header length before accessing the nlmsg payload length.

Fixes 892a25e286fb ("libnetlink: break up dump function")

[...]

Here is the summary with links:
- [iproute2] libnetlink: validate nlmsg header length first
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=78eebdbc7d2f

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html