From: Dave Seddon <dave.seddon.ca@gmail.com>
To: netdev@vger.kernel.org
Cc: Dave Seddon <dave.seddon.ca@gmail.com>,
Stephen Hemminger <stephen@networkplumber.org>,
David Ahern <dsahern@kernel.org>
Subject: [PATCH iproute2] libnetlink: zero padding in addattr_l()
Date: Mon, 9 Nov 2026 15:23:54 -0800 [thread overview]
Message-ID: <20261109232354.3061365-1-dave.seddon.ca@gmail.com> (raw)
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
reply other threads:[~2026-11-09 23:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261109232354.3061365-1-dave.seddon.ca@gmail.com \
--to=dave.seddon.ca@gmail.com \
--cc=dsahern@kernel.org \
--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