Netdev List
 help / color / mirror / Atom feed
* [PATCH iproute2] libnetlink: zero padding in addattr_l()
@ 2026-11-09 23:23 Dave Seddon
  0 siblings, 0 replies; only message in thread
From: Dave Seddon @ 2026-11-09 23:23 UTC (permalink / raw)
  To: netdev; +Cc: Dave Seddon, Stephen Hemminger, David Ahern

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 <dave.seddon.ca@gmail.com>
---
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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-09 23:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-09 23:23 [PATCH iproute2] libnetlink: zero padding in addattr_l() Dave Seddon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox