public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2] ip/iplink: fix off-by-one KIND length in modify()
@ 2026-01-13 11:41 Jan Vaclav
  2026-01-14 18:47 ` Stephen Hemminger
  2026-01-14 19:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Vaclav @ 2026-01-13 11:41 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, Jan Vaclav, Gris Ge

The expected size for IFLA_INFO_KIND in kernel is strlen(kind) + 1.
See `size` in rtnl_link_get_size() in net/core/rtnetlink.c.

Fixes: 1d93483985f0 ("iplink: use netlink for link configuration")
Reported-by: Gris Ge <fge@redhat.com>
Signed-off-by: Jan Vaclav <jvaclav@redhat.com>
---
 ip/iplink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ip/iplink.c b/ip/iplink.c
index 59e8caf4..fce6631d 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -1139,7 +1139,7 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
 
 		linkinfo = addattr_nest(&req.n, sizeof(req), IFLA_LINKINFO);
 		addattr_l(&req.n, sizeof(req), IFLA_INFO_KIND, type,
-			 strlen(type));
+			 strlen(type) + 1);
 
 		lu = get_link_kind(type);
 		if (ulinep && !strcmp(ulinep, "_slave"))
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-01-14 19:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-13 11:41 [PATCH iproute2] ip/iplink: fix off-by-one KIND length in modify() Jan Vaclav
2026-01-14 18:47 ` Stephen Hemminger
2026-01-14 19:00 ` patchwork-bot+netdevbpf

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