netdev: check for nla_put_u32() failures
Subsystems (2)
Jakub Kicinski
maintainerPATCH 1/1 netdev: check for nla_put_u32() failures
Make sure we check if nla_put_u32(id) was successful after creating objects. This is theoretical today, the skbs are large enough to always fit the ID.
---
v2:
- don't handle, just WARN
v1: https://lore.kernel.org/[email protected]
--- net/core/netdev-genl.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
net/core/netdev-genl.c +9 -3
@@ -1119,7 +1119,9 @@ int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info) goto err_unbind; } -nla_put_u32 (rsp,NETDEV_A_DMABUF_ID , binding->id); +/* rsp was allocated large enough */ +WARN_ON_ONCE (nla_put_u32 (rsp,NETDEV_A_DMABUF_ID , binding->id)); +genlmsg_end (rsp, hdr); err =genlmsg_reply (rsp, info);
@@ -1253,7 +1255,9 @@ int netdev_nl_bind_tx_doit(struct sk_buff *skb, struct genl_info *info) goto err_unlock_bind_dev; } -nla_put_u32 (rsp,NETDEV_A_DMABUF_ID , binding->id); +/* rsp was allocated large enough */ +WARN_ON_ONCE (nla_put_u32 (rsp,NETDEV_A_DMABUF_ID , binding->id)); +genlmsg_end (rsp, hdr);if (bind_dev != netdev)
@@ -1420,7 +1424,9 @@ int netdev_nl_queue_create_doit(struct sk_buff *skb, struct genl_info *info)netdev_rx_queue_lease (rxq, rxq_lease); -nla_put_u32 (rsp,NETDEV_A_QUEUE_ID , queue_id); +/* rsp was allocated large enough */ +WARN_ON_ONCE (nla_put_u32 (rsp,NETDEV_A_QUEUE_ID , queue_id)); +genlmsg_end (rsp, hdr);netdev_unlock (dev_lease);
Signature · 1 line
2.55.0
Quoted 5 lines · Jakub Kicinski
Make sure we check if
nla_put_u32(id)was successful after creating objects. This is theoretical today, the skbs are large enough to always fit the ID.Signed-off-by Jakub Kicinski <[email protected]>
Quoted 47 lines · Jakub Kicinski
Make sure we check if
nla_put_u32(id)was successful after creating objects. This is theoretical today, the skbs are large enough to always fit the ID.Signed-off-by Jakub Kicinski <[email protected]>---
v2:
- don't handle, just WARN
v1: https://lore.kernel.org/[email protected]--- net/core/netdev-genl.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)net/core/netdev-genl.c +6
-2@@ -1119,7 +1119,9 @@ int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info) goto err_unbind; } -nla_put_u32 (rsp,NETDEV_A_DMABUF_ID , binding->id); +/* rsp was allocated large enough */ +WARN_ON_ONCE (nla_put_u32 (rsp,NETDEV_A_DMABUF_ID , binding->id)); +genlmsg_end (rsp, hdr); err =genlmsg_reply (rsp, info);@@ -1253,7 +1255,9 @@ int netdev_nl_bind_tx_doit(struct sk_buff *skb, struct genl_info *info) goto err_unlock_bind_dev; } -nla_put_u32 (rsp,NETDEV_A_DMABUF_ID , binding->id); +/* rsp was allocated large enough */ +WARN_ON_ONCE (nla_put_u32 (rsp,NETDEV_A_DMABUF_ID , binding->id)); +genlmsg_end (rsp, hdr);if (bind_dev != netdev)
net/core/netdev-genl.c int netdev_nl_queue_create_doit(struct sk_buff *skb, struct genl_info *info) · line 1432
Quoted 10 lines
net/core/netdev-genl.c +3
-1@@ -1420,7 +1424,9 @@ int netdev_nl_queue_create_doit(struct sk_buff *skb, struct genl_info *info)netdev_rx_queue_lease (rxq, rxq_lease); -nla_put_u32 (rsp,NETDEV_A_QUEUE_ID , queue_id); +/* rsp was allocated large enough */ +WARN_ON_ONCE (nla_put_u32 (rsp,NETDEV_A_QUEUE_ID , queue_id)); +genlmsg_end (rsp, hdr);netdev_unlock (dev_lease);
Quoted 16 lines · Jakub Kicinski
Make sure we check if
nla_put_u32(id)was successful after creating objects. This is theoretical today, the skbs are large enough to always fit the ID.Signed-off-by Jakub Kicinski <[email protected]>---
v2:
- don't handle, just WARN
v1: https://lore.kernel.org/[email protected]
Quoted 4 lines
--- net/core/netdev-genl.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Sat, 8 Aug 2026 17:06:09 -0700 you wrote:
Make sure we check if
nla_put_u32(id)was successful after creating objects. This is theoretical today, the skbs are large enough to always fit the ID.Signed-off-by Jakub Kicinski <[email protected]>---
v2:
- don't handle, just WARN
v1: https://lore.kernel.org/[email protected][...]
Here is the summary with links:
- [net-next] netdev: check for nla_put_u32() failures
https://git.kernel.org/netdev/net-next/c/ae2998ab62e4
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html