# \[PATCH iproute2\] libnetlink: zero padding in addattr\_l()

- Subsystems: LIBRARY CODE, THE REST
- Maintainers: Andrew Morton, Linus Torvalds
- List: netdev
- 2 messages, 2 authors
- Page: https://ratatoskr.run/netdev/2026/11/17900708/t

## \[PATCH iproute2\] libnetlink: zero padding in addattr\_l()

- From: Dave Seddon \<hidden\>
- Date: 2026-11-09 23:23:58 
- Message: https://ratatoskr.run/netdev/2026/11/17900708.md

```text
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
Signed-off-by: Dave Seddon <redacted>
---
Follow-up offered in the rta_addattr_l() v2 notes:
https://lore.kernel.org/netdev/20261109164116.2637408-1-dave.seddon.ca@gmail.com/

 lib/libnetlink.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index c4a8e694..23fbf5f1 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -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;
 }
-- 
2.56.0

```

## Re: \[PATCH iproute2\] libnetlink: zero padding in addattr\_l()

- From: patchwork-bot+netdevbpf@kernel.org
- Date: 2026-11-17 21:00:06 
- Message: https://ratatoskr.run/netdev/2026/11/17955697.md

```text
Hello:

This patch was applied to iproute2/iproute2.git (main)
by Stephen Hemminger [ref]:

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
> Signed-off-by: Dave Seddon <redacted>
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html


```
