From: Piotr Raczynski <piotr.raczynski@intel.com>
To: Nick Child <nnac123@linux.ibm.com>
Cc: <netdev@vger.kernel.org>
Subject: Re: [PATCH net 2/2] netdev: Enforce index cap in netdev_get_tx_queue
Date: Fri, 17 Mar 2023 19:45:14 +0100 [thread overview]
Message-ID: <ZBS1OiIsv/ys/FE8@nimitz> (raw)
In-Reply-To: <20230317181941.86151-2-nnac123@linux.ibm.com>
On Fri, Mar 17, 2023 at 01:19:41PM -0500, Nick Child wrote:
> When requesting a TX queue at a given index, prevent out-of-bounds
> referencing by ensuring that the index is within the allocated number
> of queues.
>
> If there is an out-of-bounds reference then inform the user and return
> a reference to the first tx queue instead.
>
> Fixes: e8a0464cc950 ("netdev: Allocate multiple queues for TX.")
> Signed-off-by: Nick Child <nnac123@linux.ibm.com>
> ---
> include/linux/netdevice.h | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> 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];
Why return first queue here instead of NULL, wouldn't that confuse the
caller instead of return proper (NULL) value?
Piotr.
> + }
> +
> return &dev->_tx[index];
> }
>
> --
> 2.31.1
>
next prev parent reply other threads:[~2023-03-17 18:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-17 18:19 [PATCH net 1/2] net: Catch invalid index in XPS mapping Nick Child
2023-03-17 18:19 ` [PATCH net 2/2] netdev: Enforce index cap in netdev_get_tx_queue Nick Child
2023-03-17 18:45 ` Piotr Raczynski [this message]
2023-03-17 19:01 ` Nick Child
2023-03-21 4:49 ` Jakub Kicinski
2023-03-17 18:37 ` [PATCH net 1/2] net: Catch invalid index in XPS mapping Piotr Raczynski
2023-03-21 4:52 ` Jakub Kicinski
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=ZBS1OiIsv/ys/FE8@nimitz \
--to=piotr.raczynski@intel.com \
--cc=netdev@vger.kernel.org \
--cc=nnac123@linux.ibm.com \
/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.