Skip to contentSkip to conversation

libnetlink: zero padding in addattr_l()

PATCH Applied Dave Seddon 2 participants 2 messages Nov 9 – Nov 17

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

PATCH 1/1 libnetlink: zero padding in addattr_l()

addattr_l() leaves up to three alignment bytes unchanged. Zero them in the helper so padding does not depend on the caller's buffer contents, matching addraw_l() and rta_addattr_l().

Assisted-by Claude:claude-opus-5-5

---
Follow-up offered in the rta_addattr_l() v2 notes:
https://lore.kernel.org/netdev/[email protected]/

 lib/libnetlink.c | 1 +
 1 file changed, 1 insertion(+)
lib/libnetlink.c +1 -0
index c4a8e694..23fbf5f1 100644
@@ -1414,6 +1414,7 @@ int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data,
 	rta->rta_len = len;
 	if (alen)
 		memcpy(RTA_DATA(rta), data, alen);
+	memset((void *)rta + len, 0, RTA_ALIGN(len) - len);
 	n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len);
 	return 0;
 }
Signature · 1 line
2.56.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 8 lines · On Mon, 9 Nov 2026 15:23:54 -0800 you wrote:

addattr_l() leaves up to three alignment bytes unchanged. Zero them in the helper so padding does not depend on the caller's buffer contents, matching addraw_l() and rta_addattr_l().

Assisted-by Claude:claude-opus-5-5

[...]

Here is the summary with links:
- [iproute2] libnetlink: zero padding in addattr_l()

    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=104413f986e9

You are awesome, thank you!

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