From: Eli Britstein Date: Thu, 21 Oct 2021 13:20:02 +0000 (+0300) Subject: app/testpmd: fix packet burst spreading stats X-Git-Url: http://git.droids-corp.org/?p=dpdk.git;a=commitdiff_plain;h=6a8b64fd5e9e8f5572ea4d9de40a1cff23498246 app/testpmd: fix packet burst spreading stats 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 . 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 Reviewed-by: Matan Azrad Acked-by: Ferruh Yigit --- diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 6d5bbc8240..2b835a27bc 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1879,7 +1879,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 bf3669134a..071e4e7d63 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. */