Skip to contentSkip to conversation

examples/qos_sched: fix buffer overflow on mbuf free

PATCH Applied Bruce Richardson 3 participants 3 messages Mar 8, 2023 – Mar 12, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples/qos_sched: fix buffer overflow on mbuf free

When running the qos_sched app with separated worker and Tx threads, the app would seg-fault after a short time of handling packets. The root cause of this turns out to be an incorrect array index when freeing unsent packets post-Tx. Rather than freeing packets using the "nb_tx" value i.e. where transmission failed, the function was freeing packets using the "nb_pkts" value, i.e. going beyond the number of packets previously received into the buffer.

Fixes 39b25117c40b ("examples/qos_sched: remove Tx buffering")
---
 examples/qos_sched/app_thread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/qos_sched/app_thread.c +1 -1
index 1ea732aa91..059c470afb 100644
@@ -118,7 +118,7 @@ app_tx_thread(struct thread_conf **confs)
 		if (likely(nb_pkts != 0)) {
 			uint16_t nb_tx = rte_eth_tx_burst(conf->tx_port, 0, mbufs, nb_pkts);
 			if (nb_pkts != nb_tx)
-				rte_pktmbuf_free_bulk(&mbufs[nb_pkts], nb_pkts - nb_tx);
+				rte_pktmbuf_free_bulk(&mbufs[nb_tx], nb_pkts - nb_tx);
 		}
 
 		conf_idx++;
Signature · 1 line
2.37.2
Acked-by on v1 1/1
#1 lore raw

examples/qos_sched/app_thread.c

Quoted 32 lines

-----Original Message-----
From: Richardson, Bruce <[email protected]>
Sent: Wednesday, March 8, 2023 2:09 PM
To: [email protected]
Cc: Richardson, Bruce <[email protected]>; Ajmera, Megha <[email protected]>; Dumitrescu, Cristian <[email protected]>
Subject: [PATCH] examples/qos_sched: fix buffer overflow on mbuf free

When running the qos_sched app with separated worker and Tx threads, the app would seg-fault after a short time of handling packets. The root cause of this turns out to be an incorrect array index when freeing unsent packets post-Tx. Rather than freeing packets using the "nb_tx" value i.e. where transmission failed, the function was freeing packets using the "nb_pkts" value, i.e. going beyond the number of packets previously received into the buffer.

Fixes 39b25117c40b ("examples/qos_sched: remove Tx buffering")
---
 examples/qos_sched/app_thread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/qos_sched/app_thread.c +0 -0
index 1ea732aa91..059c470afb 100644
#2 lore raw
Quoted 8 lines
Quoted 8 lines

When running the qos_sched app with separated worker and Tx threads, the app would seg-fault after a short time of handling packets. The root cause of this turns out to be an incorrect array index when freeing unsent packets post-Tx. Rather than freeing packets using the "nb_tx" value i.e. where transmission failed, the function was freeing packets using the "nb_pkts" value, i.e. going beyond the number of packets previously received into the buffer.

Quoted 6 lines
Quoted 4 lines
Fixes 39b25117c40b ("examples/qos_sched: remove Tx buffering")

Applied, thanks.