All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] can: netlink: fix IFLA_CAN_BITRATE_MAX attribute sizing
@ 2026-09-04 16:20 Zhu Ling
  2026-09-04 16:28 ` sashiko-bot
  0 siblings, 1 reply; 3+ messages in thread
From: Zhu Ling @ 2026-09-04 16:20 UTC (permalink / raw)
  To: linux-can
  Cc: mkl, mailhol, nsekhar, faiz_abbas, s-anna, fcooper, linux-kernel,
	Zhu Ling, stable

can_fill_info() emits IFLA_CAN_BITRATE_MAX with nla_put(), which consumes
space for both the attribute header and its aligned payload. However,
can_get_size() accounts for the payload only. The resulting underestimate
can make filling the netlink response fail with -EMSGSIZE when the skb has
no remaining slack.

Use nla_total_size() to account for the complete attribute.

Fixes: 2290aefa2e90 ("can: dev: Add support for limiting configured bitrate")
Cc: stable@vger.kernel.org
Signed-off-by: Zhu Ling <zhuling0805@qq.com>
---
 drivers/net/can/dev/netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/dev/netlink.c b/drivers/net/can/dev/netlink.c
index 766d455950f5..ba26c61a82c2 100644
--- a/drivers/net/can/dev/netlink.c
+++ b/drivers/net/can/dev/netlink.c
@@ -822,7 +822,7 @@ static size_t can_get_size(const struct net_device *dev)
 	if (priv->bitrate_const)				/* IFLA_CAN_BITRATE_CONST */
 		size += nla_total_size(sizeof(*priv->bitrate_const) *
 				       priv->bitrate_const_cnt);
-	size += sizeof(priv->bitrate_max);			/* IFLA_CAN_BITRATE_MAX */
+	size += nla_total_size(sizeof(priv->bitrate_max));	/* IFLA_CAN_BITRATE_MAX */
 	size += can_ctrlmode_ext_get_size();			/* IFLA_CAN_CTRLMODE_EXT */
 
 	size += can_data_bittiming_get_size(&priv->fd,

base-commit: 641d03105cc0d2437e32fdeec164f91a4ccef6c4
-- 
2.43.0


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

end of thread, other threads:[~2026-09-04 17:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04 16:20 [PATCH net] can: netlink: fix IFLA_CAN_BITRATE_MAX attribute sizing Zhu Ling
2026-09-04 16:28 ` sashiko-bot
2026-09-04 17:10   ` zhuling0805

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.