lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 20 Mar 2023 21:49:46 -0700
From:   Jakub Kicinski <kuba@...nel.org>
To:     Nick Child <nnac123@...ux.ibm.com>
Cc:     netdev@...r.kernel.org
Subject: Re: [PATCH net 2/2] netdev: Enforce index cap in
 netdev_get_tx_queue

On Fri, 17 Mar 2023 13:19:41 -0500 Nick Child wrote:
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 23b0d7eaaadd..fe88b1a7393d 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2482,6 +2482,13 @@ static inline
>  struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev,
>  					 unsigned int index)
>  {
> +	if (unlikely(index >= dev->num_tx_queues)) {
> +		net_warn_ratelimited("%s selects TX queue %d, but number of TX queues is %d\n",
> +				     dev->name, index,
> +				     dev->num_tx_queues);
> +		return &dev->_tx[0];
> +	}
> +

Should we maybe do DEBUG_NET_WARN_ON_ONCE() instead?
It will likely run multiple times per each Tx packet,
so I wonder if we really want to add a branch for what's
effectively defensive programming...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ