Netdev List
 help / color / mirror / Atom feed
From: Bobby Eshleman <bobbyeshleman@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
	pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org,
	dw@davidwei.uk, daniel@iogearbox.net, razor@blackwall.org,
	sdf@fomichev.me, dtatulea@nvidia.com, bobbyeshleman@meta.com
Subject: Re: [PATCH net-next 1/4] netdev: check for nla_put_u32() failures
Date: Tue, 9 Jun 2026 12:24:00 -0700	[thread overview]
Message-ID: <aihoUMwR+/1kyQ3Z@devvm29614.prn0.facebook.com> (raw)
In-Reply-To: <20260609190804.1137085-2-kuba@kernel.org>

On Tue, Jun 09, 2026 at 12:08:01PM -0700, Jakub Kicinski 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 <kuba@kernel.org>
> ---
>  net/core/netdev-genl.c | 21 ++++++++++++++++++---
>  1 file changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
> index b4d48f3672a5..a10d353d5eab 100644
> --- a/net/core/netdev-genl.c
> +++ b/net/core/netdev-genl.c
> @@ -1091,7 +1091,10 @@ 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);
> +	err = nla_put_u32(rsp, NETDEV_A_DMABUF_ID, binding->id);
> +	if (err)
> +		goto err_unbind;
> +
>  	genlmsg_end(rsp, hdr);
>  
>  	err = genlmsg_reply(rsp, info);
> @@ -1227,7 +1230,10 @@ 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);
> +	err = nla_put_u32(rsp, NETDEV_A_DMABUF_ID, binding->id);
> +	if (err)
> +		goto err_unbind;
> +
>  	genlmsg_end(rsp, hdr);
>  
>  	if (bind_dev != netdev)
> @@ -1237,6 +1243,8 @@ int netdev_nl_bind_tx_doit(struct sk_buff *skb, struct genl_info *info)
>  
>  	return genlmsg_reply(rsp, info);
>  
> +err_unbind:
> +	net_devmem_unbind_dmabuf(binding);
>  err_unlock_bind_dev:
>  	if (bind_dev != netdev)
>  		netdev_unlock(bind_dev);
> @@ -1394,7 +1402,12 @@ 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);
> +	err = nla_put_u32(rsp, NETDEV_A_QUEUE_ID, queue_id);
> +	if (err) {
> +		WARN_ON_ONCE(1); /* we can't delete the queue, ID must fit in */
> +		goto err_unlease;
> +	}
> +
>  	genlmsg_end(rsp, hdr);
>  
>  	netdev_unlock(dev_lease);
> @@ -1404,6 +1417,8 @@ int netdev_nl_queue_create_doit(struct sk_buff *skb, struct genl_info *info)
>  
>  	return genlmsg_reply(rsp, info);
>  
> +err_unlease:
> +	netdev_rx_queue_unlease(rxq, rxq_lease);
>  err_unlock_dev_lease:
>  	netdev_unlock(dev_lease);
>  err_put_netns:
> -- 
> 2.54.0
> 
> 

Reviewed-by: Bobby Eshleman <bobbyeshleman@meta.com>

  reply	other threads:[~2026-06-09 19:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-09 19:08 [PATCH net-next 0/4] netdev: address a handful of nit picks Jakub Kicinski
2026-06-09 19:08 ` [PATCH net-next 1/4] netdev: check for nla_put_u32() failures Jakub Kicinski
2026-06-09 19:24   ` Bobby Eshleman [this message]
2026-06-09 19:52   ` Daniel Borkmann
2026-06-09 19:56   ` Joe Damato
2026-06-09 19:08 ` [PATCH net-next 2/4] netdev: correct error code in netdev_nl_queue_fill_lease() Jakub Kicinski
2026-06-09 19:16   ` Bobby Eshleman
2026-06-09 19:48   ` Daniel Borkmann
2026-06-09 19:57   ` Joe Damato
2026-06-09 19:08 ` [PATCH net-next 3/4] netdev: avoid skipping objects on race with device disappearance Jakub Kicinski
2026-06-09 19:48   ` Daniel Borkmann
2026-06-09 19:59   ` Bobby Eshleman
2026-06-09 20:15     ` Bobby Eshleman
2026-06-09 21:19       ` Jakub Kicinski
2026-06-09 22:04         ` Bobby Eshleman
2026-06-09 19:08 ` [PATCH net-next 4/4] netdev: don't use dev->flags for IFF_UP Jakub Kicinski
2026-06-09 19:49   ` Daniel Borkmann
2026-06-09 19:54   ` Joe Damato
2026-06-09 20:00   ` Bobby Eshleman

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=aihoUMwR+/1kyQ3Z@devvm29614.prn0.facebook.com \
    --to=bobbyeshleman@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bobbyeshleman@meta.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dtatulea@nvidia.com \
    --cc=dw@davidwei.uk \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox