patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Jerin Jacob <jerin.jacob@caviumnetworks.com>
To: marcin.wilk@caviumnetworks.com
Cc: maciej.czekaj@caviumnetworks.com, dev@dpdk.org, stable@dpdk.org
Subject: Re: [dpdk-stable] [PATCH] net/thunderx: fix access an array out of bounds
Date: Tue, 11 Apr 2017 15:30:44 +0530	[thread overview]
Message-ID: <20170411100043.GB9935@jerin> (raw)
In-Reply-To: <1491575921-24883-1-git-send-email-marcin.wilk@caviumnetworks.com>

-----Original Message-----
> Date: Fri,  7 Apr 2017 16:38:41 +0200
> From: marcin.wilk@caviumnetworks.com
> To: jerin.jacob@caviumnetworks.com, maciej.czekaj@caviumnetworks.com
> Cc: dev@dpdk.org, stable@dpdk.org, Marcin Wilk
>  <marcin.wilk@caviumnetworks.com>
> Subject: [PATCH] net/thunderx: fix access an array out of bounds
> X-Mailer: git-send-email 2.7.4
> 
> From: Marcin Wilk <marcin.wilk@caviumnetworks.com>
> 
> Trying to assign more queues to stats struct break only from one loop
> when the maximum size is reached. Outside loop interation is continued.
> This leads to access an array out of bounds.
> 
> Fixes: 21e3fb0050b9 ("net/thunderx: add final bits for secondary queue support")
> 
> Signed-off-by: Marcin Wilk <marcin.wilk@caviumnetworks.com>
> ---
>  drivers/net/thunderx/nicvf_ethdev.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
> index 6c3670a..40d6671 100644
> --- a/drivers/net/thunderx/nicvf_ethdev.c
> +++ b/drivers/net/thunderx/nicvf_ethdev.c
> @@ -251,6 +251,7 @@ nicvf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
>  	uint16_t rx_start, rx_end;
>  	uint16_t tx_start, tx_end;
>  	size_t i;
> +	bool breakout = false;
>  
>  	/* RX queue indices for the first VF */
>  	nicvf_rx_range(dev, nic, &rx_start, &rx_end);
> @@ -289,8 +290,10 @@ nicvf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
>  
>  		/* Reading per RX ring stats */
>  		for (qidx = rx_start; qidx <= rx_end; qidx++) {
> -			if (qidx == RTE_ETHDEV_QUEUE_STAT_CNTRS)

IMO, adding the qidx >= RTE_ETHDEV_QUEUE_STAT_CNTRS is much simpler than
breakout logic.

With that change:
Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

> +			if (qidx == RTE_ETHDEV_QUEUE_STAT_CNTRS) {
> +				breakout = true;
>  				break;
> +			}
>  
>  			nicvf_hw_get_rx_qstats(snic, &rx_qstats,
>  					       qidx % MAX_RCV_QUEUES_PER_QS);
> @@ -302,14 +305,18 @@ nicvf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
>  		nicvf_tx_range(dev, snic, &tx_start, &tx_end);
>  		/* Reading per TX ring stats */
>  		for (qidx = tx_start; qidx <= tx_end; qidx++) {
> -			if (qidx == RTE_ETHDEV_QUEUE_STAT_CNTRS)
> +			if (qidx == RTE_ETHDEV_QUEUE_STAT_CNTRS) {
> +				breakout = true;
>  				break;
> +			}
>  
>  			nicvf_hw_get_tx_qstats(snic, &tx_qstats,
>  					       qidx % MAX_SND_QUEUES_PER_QS);
>  			stats->q_obytes[qidx] = tx_qstats.q_tx_bytes;
>  			stats->q_opackets[qidx] = tx_qstats.q_tx_packets;
>  		}
> +		if (breakout)
> +			break;
>  	}
>  
>  	nicvf_hw_get_stats(nic, &port_stats);
> -- 
> 2.7.4
> 

  reply	other threads:[~2017-04-11 10:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-07 14:38 marcin.wilk
2017-04-11 10:00 ` Jerin Jacob [this message]
2017-04-11 12:35 ` [dpdk-stable] [PATCH v2] " marcin.wilk
2017-04-11 13:15   ` Ferruh Yigit

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=20170411100043.GB9935@jerin \
    --to=jerin.jacob@caviumnetworks.com \
    --cc=dev@dpdk.org \
    --cc=maciej.czekaj@caviumnetworks.com \
    --cc=marcin.wilk@caviumnetworks.com \
    --cc=stable@dpdk.org \
    /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;
as well as URLs for NNTP newsgroup(s).