DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/testpmd: fix packet burst spreading stats
@ 2021-10-21  8:03 Eli Britstein
  2021-10-21 12:46 ` Ferruh Yigit
  2021-10-21 13:20 ` [dpdk-dev] [PATCH V2 1/1] " Eli Britstein
  0 siblings, 2 replies; 4+ messages in thread
From: Eli Britstein @ 2021-10-21  8:03 UTC (permalink / raw)
  To: dev
  Cc: Matan Azrad, Asaf Penso, Slava Ovsiienko, Thomas Monjalon,
	xiaoyun.li, anatoly.burakov, Eli Britstein, stable

RX/TX functions (rte_eth_rx_burst/rte_eth_tx_burst) get 'nb_pkts'
argument, which specifies the maximum number to receive/transmit.
It can be 0..nb_pkts, meaning nb_pkts+1 options.
Enlarge the spread stats array by one cell to fix the possible out of
range memory access.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Eli Britstein <elibr@nvidia.com>
Reviewed-by: Matan Azrad <matan@mellanox.com>
---
 app/test-pmd/testpmd.c | 2 +-
 app/test-pmd/testpmd.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index af0e79fe6d..d75451ac7b 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1873,7 +1873,7 @@ pkt_burst_stats_display(const char *rx_tx, struct pkt_burst_stats *pbs)
 	pktnb_stats[0] = 0;
 
 	/* Find the next 2 burst sizes with highest occurrences. */
-	for (nb_pkt = 1; nb_pkt < MAX_PKT_BURST; nb_pkt++) {
+	for (nb_pkt = 1; nb_pkt < MAX_PKT_BURST + 1; nb_pkt++) {
 		nb_burst = pbs->pkt_burst_spread[nb_pkt];
 
 		if (nb_burst == 0)
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index e3995d24ab..5238308ca7 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -96,7 +96,7 @@ enum {
  * that are recorded for each forwarding stream.
  */
 struct pkt_burst_stats {
-	unsigned int pkt_burst_spread[MAX_PKT_BURST];
+	unsigned int pkt_burst_spread[MAX_PKT_BURST + 1];
 };
 
 /** Information for a given RSS type. */
-- 
2.28.0.2311.g225365fb51


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] app/testpmd: fix packet burst spreading stats
  2021-10-21  8:03 [dpdk-dev] [PATCH] app/testpmd: fix packet burst spreading stats Eli Britstein
@ 2021-10-21 12:46 ` Ferruh Yigit
  2021-10-21 13:20 ` [dpdk-dev] [PATCH V2 1/1] " Eli Britstein
  1 sibling, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2021-10-21 12:46 UTC (permalink / raw)
  To: Eli Britstein, dev
  Cc: Matan Azrad, Asaf Penso, Slava Ovsiienko, Thomas Monjalon,
	xiaoyun.li, anatoly.burakov, stable, Honnappa Nagarahalli

On 10/21/2021 9:03 AM, Eli Britstein wrote:
> RX/TX functions (rte_eth_rx_burst/rte_eth_tx_burst) get 'nb_pkts'
> argument, which specifies the maximum number to receive/transmit.
> It can be 0..nb_pkts, meaning nb_pkts+1 options.
> Enlarge the spread stats array by one cell to fix the possible out of
> range memory access.
> 

This looks a valid problem, I guess problem is able to hide this long
because of big MAX_PKT_BURST value in testpmd.

Can you please briefly describe what 'pkt_burst_spread[]' is in the
commit log? That makes easy to understand the problem.

> Fixes: af75078fece3 ("first public release")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Eli Britstein <elibr@nvidia.com>
> Reviewed-by: Matan Azrad <matan@mellanox.com>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH V2 1/1] app/testpmd: fix packet burst spreading stats
  2021-10-21  8:03 [dpdk-dev] [PATCH] app/testpmd: fix packet burst spreading stats Eli Britstein
  2021-10-21 12:46 ` Ferruh Yigit
@ 2021-10-21 13:20 ` Eli Britstein
  2021-10-22  2:25   ` Ferruh Yigit
  1 sibling, 1 reply; 4+ messages in thread
From: Eli Britstein @ 2021-10-21 13:20 UTC (permalink / raw)
  To: dev
  Cc: Matan Azrad, Asaf Penso, Slava Ovsiienko, Thomas Monjalon,
	xiaoyun.li, anatoly.burakov, Ferruh Yigit, Eli Britstein, stable

RX/TX functions (rte_eth_rx_burst/rte_eth_tx_burst) get 'nb_pkts'
argument, which specifies the maximum number to receive/transmit.
It can be 0..nb_pkts, meaning nb_pkts+1 options.
Testpmd can provide statistics of the burst sizes ('set
record-burst-stats on') by incrementing an array cell of index
<burst-size>. This array is mistakenly [MAX_PKT_BURST] size. Receiving
the maximum burst will cause out of bound write.
Enlarge the spread stats array by one cell to fix it.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Eli Britstein <elibr@nvidia.com>
Reviewed-by: Matan Azrad <matan@mellanox.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 app/test-pmd/testpmd.c | 2 +-
 app/test-pmd/testpmd.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index af0e79fe6d..d75451ac7b 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1873,7 +1873,7 @@ pkt_burst_stats_display(const char *rx_tx, struct pkt_burst_stats *pbs)
 	pktnb_stats[0] = 0;
 
 	/* Find the next 2 burst sizes with highest occurrences. */
-	for (nb_pkt = 1; nb_pkt < MAX_PKT_BURST; nb_pkt++) {
+	for (nb_pkt = 1; nb_pkt < MAX_PKT_BURST + 1; nb_pkt++) {
 		nb_burst = pbs->pkt_burst_spread[nb_pkt];
 
 		if (nb_burst == 0)
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index e3995d24ab..5238308ca7 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -96,7 +96,7 @@ enum {
  * that are recorded for each forwarding stream.
  */
 struct pkt_burst_stats {
-	unsigned int pkt_burst_spread[MAX_PKT_BURST];
+	unsigned int pkt_burst_spread[MAX_PKT_BURST + 1];
 };
 
 /** Information for a given RSS type. */
-- 
2.28.0.2311.g225365fb51


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH V2 1/1] app/testpmd: fix packet burst spreading stats
  2021-10-21 13:20 ` [dpdk-dev] [PATCH V2 1/1] " Eli Britstein
@ 2021-10-22  2:25   ` Ferruh Yigit
  0 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2021-10-22  2:25 UTC (permalink / raw)
  To: Eli Britstein, dev
  Cc: Matan Azrad, Asaf Penso, Slava Ovsiienko, Thomas Monjalon,
	xiaoyun.li, anatoly.burakov, stable

On 10/21/2021 2:20 PM, Eli Britstein wrote:
> RX/TX functions (rte_eth_rx_burst/rte_eth_tx_burst) get 'nb_pkts'
> argument, which specifies the maximum number to receive/transmit.
> It can be 0..nb_pkts, meaning nb_pkts+1 options.
> Testpmd can provide statistics of the burst sizes ('set
> record-burst-stats on') by incrementing an array cell of index
> <burst-size>. This array is mistakenly [MAX_PKT_BURST] size. Receiving
> the maximum burst will cause out of bound write.
> Enlarge the spread stats array by one cell to fix it.
> 
> Fixes: af75078fece3 ("first public release")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Eli Britstein <elibr@nvidia.com>
> Reviewed-by: Matan Azrad <matan@mellanox.com>
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/main, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-22  2:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21  8:03 [dpdk-dev] [PATCH] app/testpmd: fix packet burst spreading stats Eli Britstein
2021-10-21 12:46 ` Ferruh Yigit
2021-10-21 13:20 ` [dpdk-dev] [PATCH V2 1/1] " Eli Britstein
2021-10-22  2:25   ` Ferruh Yigit

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).