DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Wenyu Su <PriceClaptrap@hotmail.com>
To: "shaibran@amazon.com" <shaibran@amazon.com>,
	"evgenys@amazon.com" <evgenys@amazon.com>,
	"amitbern@amazon.com" <amitbern@amazon.com>,
	"atrwajee@amazon.com" <atrwajee@amazon.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	"stable@dpdk.org" <stable@dpdk.org>,
	Jan Medala <jan.medala@outlook.com>
Subject: [PATCH] net/ena: fix out-of-bounds Tx prefetch
Date: Sun, 22 Nov 2026 21:47:23 +0000	[thread overview]
Message-ID: <20261122214722.48761-1-priceclaptrap@hotmail.com> (raw)

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")
Cc: stable@dpdk.org
Signed-off-by: Wenyu Su <priceclaptrap@hotmail.com>
---
 .mailmap                     | 1 +
 drivers/net/ena/ena_ethdev.c | 4 ++--
 drivers/net/ena/ena_ethdev.h | 1 -
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/.mailmap b/.mailmap
index a0096fb97a..b0ac17ea0c 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1874,6 +1874,7 @@ Wentao Cui <wentaoc@mellanox.com>
 Wenwu Ma <wenwux.ma@intel.com>
 Wenxiang Qian <leonwxqian@gmail.com>
 Wenxuan Wu <wenxuanx.wu@intel.com>
+Wenyu Su <priceclaptrap@hotmail.com>
 Wenzhuo Lu <wenzhuo.lu@intel.com>
 Weqaar Janjua <weqaar.a.janjua@intel.com>
 Wiktor Pilarczyk <wiktor.pilarczyk@intel.com>
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index c2d0194e51..7ea6deea70 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -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... */
diff --git a/drivers/net/ena/ena_ethdev.h b/drivers/net/ena/ena_ethdev.h
index b204b07767..bd25cff8ca 100644
--- a/drivers/net/ena/ena_ethdev.h
+++ b/drivers/net/ena/ena_ethdev.h
@@ -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
-- 
2.39.5 (Apple Git-154)


             reply	other threads:[~2026-11-22 21:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22 21:47 Wenyu Su [this message]
2026-11-23 18:57 ` [PATCH] net/ena: fix out-of-bounds Tx prefetch Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261122214722.48761-1-priceclaptrap@hotmail.com \
    --to=priceclaptrap@hotmail.com \
    --cc=amitbern@amazon.com \
    --cc=atrwajee@amazon.com \
    --cc=dev@dpdk.org \
    --cc=evgenys@amazon.com \
    --cc=jan.medala@outlook.com \
    --cc=shaibran@amazon.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox