From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
andrew+netdev@lunn.ch, horms@kernel.org,
Jakub Kicinski <kuba@kernel.org>,
daniel@iogearbox.net, bobbyeshleman@gmail.com, joe@dama.to,
razor@blackwall.org, sdf@fomichev.me, dw@davidwei.uk
Subject: [PATCH net-next] netdev: check for nla_put_u32() failures
Date: Sat, 8 Aug 2026 17:06:09 -0700 [thread overview]
Message-ID: <20260809000609.327659-1-kuba@kernel.org> (raw)
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 <kuba@kernel.org>
---
v2:
- don't handle, just WARN
v1: https://lore.kernel.org/20260609190804.1137085-2-kuba@kernel.org
CC: daniel@iogearbox.net
CC: bobbyeshleman@gmail.com
CC: joe@dama.to
CC: razor@blackwall.org
CC: sdf@fomichev.me
CC: dw@davidwei.uk
---
net/core/netdev-genl.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
index c0a86f3ae33b..fa9edfdb32c2 100644
--- a/net/core/netdev-genl.c
+++ b/net/core/netdev-genl.c
@@ -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);
--
2.55.0
next reply other threads:[~2026-08-09 0:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-09 0:06 Jakub Kicinski [this message]
2026-08-09 21:09 ` [PATCH net-next] netdev: check for nla_put_u32() failures Daniel Borkmann
2026-08-10 6:31 ` Nikolay Aleksandrov
2026-08-10 20:39 ` Joe Damato
2026-08-10 23:50 ` patchwork-bot+netdevbpf
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=20260809000609.327659-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=bobbyeshleman@gmail.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dw@davidwei.uk \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=joe@dama.to \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=razor@blackwall.org \
--cc=sdf@fomichev.me \
/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 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.