net/memif: fix segfault with large burst size
PATCH 1/1 net/memif: fix segfault with large burst size
There will be a segfault when Rx burst size is greater than MAX_PKT_BURST of memif. Fix the issue by correcting the wrong mbuf index in eth_memif_rx, which results in accessing invalid memory address.
Bugzilla ID: 1273
--- drivers/net/memif/rte_eth_memif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/memif/rte_eth_memif.c +1 -1
@@ -356,7 +356,7 @@ eth_memif_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) rx_pkts =0 ; pkts = nb_pkts <MAX_PKT_BURST ? nb_pkts :MAX_PKT_BURST ;while (n_slots && rx_pkts < pkts) { - mbuf_head = mbufs[n_rx_pkts]; + mbuf_head = mbufs[rx_pkts]; mbuf = mbuf_head; next_slot1:
Signature · 1 line
2.25.1
Quoted 21 lines · Joyce Kong
There will be a segfault when Rx burst size is greater than
MAX_PKT_BURSTof memif. Fix the issue by correcting the wrong mbuf index ineth_memif_rx, which results in accessing invalid memory address.Bugzilla ID: 1273
Fixes aa17df860891 ("net/memif: add a Rx fast path")Signed-off-by Joyce Kong <[email protected]>Reviewed-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- drivers/net/memif/rte_eth_memif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/memif/rte_eth_memif.c +0
-0
drivers/net/memif/rte_eth_memif.c eth_memif_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) · line 362
Quoted 8 lines
drivers/net/memif/rte_eth_memif.c +1
-1@@ -356,7 +356,7 @@ eth_memif_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) rx_pkts =0 ; pkts = nb_pkts <MAX_PKT_BURST ? nb_pkts :MAX_PKT_BURST ;while (n_slots && rx_pkts < pkts) { - mbuf_head = mbufs[n_rx_pkts]; + mbuf_head = mbufs[rx_pkts]; mbuf = mbuf_head; next_slot1:
Hi Jakub,
Can you please look at this patch?
Thanks,
ferruh
Quoted 5 lines · Joyce Kong
There will be a segfault when Rx burst size is greater than
MAX_PKT_BURSTof memif. Fix the issue by correcting the wrong mbuf index ineth_memif_rx, which results in accessing invalid memory address.
Quoted 8 lines
Bugzilla ID: 1273
Fixes aa17df860891 ("net/memif: add a Rx fast path")Signed-off-by Joyce Kong <[email protected]>Reviewed-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>
Hi Joyce, good catch.
Applied to dpdk-next-net/main, thanks.
For record, if nb_pkts > MAX_PKT_BURST, memif buffer consumed in chunks of MAX_PKT_BURST mbufs, next chunk consumption starts with 'goto next_bulk' call.
For each chunk, MAX_PKT_BURST mbufs allocated and filled, they are accessed by 'n_rx_pkts' index, but 'n_rx_pkts' is overall received mbuf number, so it shouldn't be used as index for that chunk, but 'rx_pkts' should be used which is reset at the beginning of the chunk processing.
For the first chunk using 'n_rx_pkts' or 'rx_pkts' are same, that explains how issue lived till now, as commit log mentions issue can be observed when nb_pkts > MAX_PKT_BURST.