net/thunderx: fix stats access out of bounds
authorMarcin Wilk <marcin.wilk@caviumnetworks.com>
Tue, 11 Apr 2017 12:35:13 +0000 (14:35 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 19 Apr 2017 13:37:37 +0000 (15:37 +0200)
Trying to assign more queues to stats struct break only from one loop
when the maximum size is reached. Outside loop iteration is continued.
This leads to access an array out of bounds.

Fixes: 21e3fb0050b9 ("net/thunderx: add final bits for secondary queue support")
Cc: stable@dpdk.org
Signed-off-by: Marcin Wilk <marcin.wilk@caviumnetworks.com>
Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
drivers/net/thunderx/nicvf_ethdev.c

index b0b9c3b..36ff94f 100644 (file)
@@ -258,7 +258,7 @@ 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)
+               if (qidx >= RTE_ETHDEV_QUEUE_STAT_CNTRS)
                        break;
 
                nicvf_hw_get_rx_qstats(nic, &rx_qstats, qidx);
@@ -271,7 +271,7 @@ nicvf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 
        /* 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)
                        break;
 
                nicvf_hw_get_tx_qstats(nic, &tx_qstats, qidx);
@@ -290,7 +290,7 @@ 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)
+                       if (qidx >= RTE_ETHDEV_QUEUE_STAT_CNTRS)
                                break;
 
                        nicvf_hw_get_rx_qstats(snic, &rx_qstats,
@@ -303,7 +303,7 @@ 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)
                                break;
 
                        nicvf_hw_get_tx_qstats(snic, &tx_qstats,