net/ena: fix out-of-bounds Tx prefetch
PATCH 1/1 net/ena: fix out-of-bounds Tx prefetch
The Tx prefetch uses the descriptor ring mask to index the caller-provided packet array. This can read beyond the end of the array near the end of a burst.
Only prefetch when the lookahead index is within the burst.
Fixes 1173fca25af9 ("ena: add polling-mode driver")
Signed-off-by Wenyu Su <[email protected]>
--- .mailmap | 1 + drivers/net/ena/ena_ethdev.c | 4 ++-- drivers/net/ena/ena_ethdev.h | 1 - 3 files changed, 3 insertions(+), 3 deletions(-)
.mailmap +1 -0
@@ -1874,6 +1874,7 @@ Wentao Cui <[email protected]> Wenwu Ma <[email protected]> Wenxiang Qian <[email protected]> Wenxuan Wu <[email protected]> +Wenyu Su <[email protected]> Wenzhuo Lu <[email protected]> Weqaar Janjua <[email protected]> Wiktor Pilarczyk <[email protected]>
drivers/net/ena/ena_ethdev.c +2 -2
@@ -3425,8 +3425,8 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,if (ena_xmit_mbuf (tx_ring, tx_pkts[sent_idx]))break ; tx_ring->pkts_without_db = true; -rte_prefetch0 (tx_pkts[ENA_IDX_ADD_MASKED (sent_idx,4 , - tx_ring->size_mask)]); +if (likely ((sent_idx +4 ) < nb_pkts)) +rte_prefetch0 (tx_pkts[sent_idx +4 ]); }/* If there are ready packets to be xmitted... */
drivers/net/ena/ena_ethdev.h +0 -1
@@ -60,7 +60,6 @@#define ENA_MAX_CUSTOMER_METRICS 6#define ENA_IDX_NEXT_MASKED (idx, mask) (((idx) + 1) & (mask)) -#define ENA_IDX_ADD_MASKED (idx, n, mask) (((idx) + (n)) & (mask))#define ENA_HASH_KEY_SIZE 40
Signature · 1 line
2.39.5 (Apple Git-154)
Quoted 10 lines · On Sun, 22 Nov 2026 21:47:23 +0000 Wenyu Su <[email protected]> wrote:
The Tx prefetch uses the descriptor ring mask to index the caller-provided packet array. This can read beyond the end of the array near the end of a burst.
Only prefetch when the lookahead index is within the burst.
Fixes 1173fca25af9 ("ena: add polling-mode driver")Signed-off-by Wenyu Su <[email protected]>---
Looks right, applied to next-net for 27.03