Skip to contentSkip to conversation

net/memif: fix segfault with Tx burst larger than 255

PATCH Applied Joyce Kong 3 participants 4 messages Dec 5, 2023 – Dec 6, 2023 Network drivers

lore
Share & tools
lore

Joyce Kong

author
#0 lore raw

PATCH 1/1 net/memif: fix segfault with Tx burst larger than 255

There will be a segfault when tx burst size is larger than
256. This is because eth_memif_tx uses an index i which is uint8_t to count transmitted nb_pkts. Extend i to uint16_t, the same size as nb_pkts.

Fixes b5613c8f9d0a ("net/memif: add a Tx fast path")
---
 drivers/net/memif/rte_eth_memif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/memif/rte_eth_memif.c +1 -1
index 7cc8c0da91..6f45a00172 100644
@@ -684,7 +684,7 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 		n_free = __atomic_load_n(&ring->head, __ATOMIC_ACQUIRE) - slot;
 	}
 
-	uint8_t i;
+	uint16_t i;
 	struct rte_mbuf **buf_tmp = bufs;
 	mbuf_head = *buf_tmp++;
 	struct rte_mempool *mp = mbuf_head->pool;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · On Tue, 5 Dec 2023 04:05:24 +0000 Joyce Kong <[email protected]> wrote:

There will be a segfault when tx burst size is larger than
256. This is because eth_memif_tx uses an index i which is uint8_t to count transmitted nb_pkts. Extend i to uint16_t, the same size as nb_pkts.

Quoted 7 lines
Fixes b5613c8f9d0a ("net/memif: add a Tx fast path")

---

I wonder if other drivers have same bug?

author
#2 lore raw
Quoted 22 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, December 6, 2023 2:34 AM
To: Joyce Kong <[email protected]>
Cc: Jakub Grajciar <[email protected]>; Morten Brørup <[email protected]>; Ruifeng Wang <[email protected]>; [email protected]; nd <[email protected]>; [email protected]; Liangxing Wang <[email protected]>
Subject: Re: [PATCH v1] net/memif: fix segfault with Tx burst larger than 255

Quoted 7 lines · On Tue, 5 Dec 2023 04:05:24 +0000 Joyce Kong <[email protected]> wrote:

There will be a segfault when tx burst size is larger than 256. This is because eth_memif_tx uses an index i which is uint8_t to count transmitted nb_pkts. Extend i to uint16_t, the same size as nb_pkts.

Fixes b5613c8f9d0a ("net/memif: add a Tx fast path")
Quoted 6 lines
Quoted 4 lines

---

I wonder if other drivers have same bug?

I don't think this is a common bug.
This is a special case as the bug is introduced for whether choosing the memif Tx fast path.

Quoted 2 lines
Acked-by Applied
#3 lore raw
In reply to Stephen Hemminger
Quoted 11 lines · Stephen Hemminger
Quoted 8 lines · On Tue, 5 Dec 2023 04:05:24 +0000 Joyce Kong <[email protected]> wrote:

There will be a segfault when tx burst size is larger than
256. This is because eth_memif_tx uses an index i which is uint8_t to count transmitted nb_pkts. Extend i to uint16_t, the same size as nb_pkts.

Fixes b5613c8f9d0a ("net/memif: add a Tx fast path")
Quoted 9 lines
Quoted 4 lines

---

I wonder if other drivers have same bug?

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