From: Joshua Washington <joshwash@google.com>
To: Joshua Washington <joshwash@google.com>,
Xiaoyun Li <xiaoyun.li@intel.com>,
Junfeng Guo <junfengg@nvidia.com>
Cc: dev@dpdk.org, stable@dpdk.org,
"Jasper Tran O'Leary" <jtranoleary@google.com>
Subject: [PATCH 04/12] net/gve: fix integer truncation in GQI QPL Tx path
Date: Thu, 3 Dec 2026 15:26:27 -0800 [thread overview]
Message-ID: <20261203232637.1044501-5-joshwash@google.com> (raw)
In-Reply-To: <20261203232637.1044501-1-joshwash@google.com>
In the GQ QPL Tx path, header length and payload length are computed as
uint32_t, but gve_tx_alloc_from_fifo() takes a uint16_t length. A
packet or TSO payload of 65536 bytes or greater truncates the higher
order bits, causing the FIFO to allocate a smaller size before copying
the full 32-bit length and overflowing the FIFO.
Additionally, GQI Tx descriptors only support 16-bit packet and segment
lengths, and packets exceeding sw_ring or FIFO capacity previously
stalled the queue indefinitely on backpressure checks.
Widen the length parameter of gve_tx_alloc_from_fifo() from uint16_t to
uint32_t, and validate each packet up front before consuming ring or
FIFO resources. Drop, free, and count in invalid_pkts and errors any
packet that is empty, exceeds UINT16_MAX bytes, lacks TSO headers or
payload (hlen == 0 || pkt_len <= hlen), exceeds sw_ring capacity
(nb_segs > nb_tx_desc - 1), or requires more FIFO space than fifo_size.
Fixes: a46583cf43c8 ("net/gve: support Rx/Tx")
Cc: stable@dpdk.org
Signed-off-by: Joshua Washington <joshwash@google.com>
Reviewed-by: Jasper Tran O'Leary <jtranoleary@google.com>
---
drivers/net/gve/gve_tx.c | 59 ++++++++++++++++++++++++++++++----------
1 file changed, 45 insertions(+), 14 deletions(-)
diff --git a/drivers/net/gve/gve_tx.c b/drivers/net/gve/gve_tx.c
index bf778a86e6..aa4fba07fd 100644
--- a/drivers/net/gve/gve_tx.c
+++ b/drivers/net/gve/gve_tx.c
@@ -233,7 +233,7 @@ gve_tx_reclaim_fifo_qpl(struct gve_tx_queue *txq, uint32_t tx_tail,
}
static inline uint64_t
-gve_tx_alloc_from_fifo(struct gve_tx_queue *txq, uint16_t tx_id, uint16_t len)
+gve_tx_alloc_from_fifo(struct gve_tx_queue *txq, uint16_t tx_id, uint32_t len)
{
uint32_t head = txq->fifo_head;
uint32_t size = txq->fifo_size;
@@ -268,6 +268,34 @@ gve_tx_alloc_from_fifo(struct gve_tx_queue *txq, uint16_t tx_id, uint16_t len)
return fifo_addr;
}
+static inline bool
+gve_tx_validate_pkt_limits_qpl(const struct gve_tx_queue *txq,
+ const struct rte_mbuf *tx_pkt,
+ uint64_t ol_flags, uint32_t hlen)
+{
+ uint32_t fifo_needed;
+
+ if (unlikely(tx_pkt->pkt_len == 0 || tx_pkt->pkt_len > UINT16_MAX))
+ return false;
+
+ if (unlikely(tx_pkt->nb_segs > txq->nb_tx_desc - 1))
+ return false;
+
+ if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
+ if (unlikely(hlen == 0 || tx_pkt->pkt_len <= hlen))
+ return false;
+ fifo_needed = RTE_ALIGN(hlen, RTE_CACHE_LINE_SIZE) +
+ RTE_ALIGN(tx_pkt->pkt_len - hlen, RTE_CACHE_LINE_SIZE);
+ } else {
+ fifo_needed = RTE_ALIGN(tx_pkt->pkt_len, RTE_CACHE_LINE_SIZE);
+ }
+
+ if (unlikely(fifo_needed > txq->fifo_size))
+ return false;
+
+ return true;
+}
+
static inline uint16_t
gve_tx_burst_qpl(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
{
@@ -303,6 +331,22 @@ gve_tx_burst_qpl(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
tx_pkt = *tx_pkts++;
ol_flags = tx_pkt->ol_flags;
+ tx_offload.l2_len = tx_pkt->l2_len;
+ tx_offload.l3_len = tx_pkt->l3_len;
+ tx_offload.l4_len = tx_pkt->l4_len;
+ tx_offload.tso_segsz = tx_pkt->tso_segsz;
+
+ hlen = ol_flags & RTE_MBUF_F_TX_TCP_SEG ?
+ (uint32_t)(tx_offload.l2_len + tx_offload.l3_len + tx_offload.l4_len) :
+ tx_pkt->pkt_len;
+
+ if (unlikely(!gve_tx_validate_pkt_limits_qpl(txq, tx_pkt, ol_flags, hlen))) {
+ txq->stats.invalid_pkts++;
+ txq->stats.errors++;
+ rte_pktmbuf_free(tx_pkt);
+ continue;
+ }
+
if (txq->sw_nb_free < tx_pkt->nb_segs) {
gve_tx_clean_swr_qpl(txq);
if (txq->sw_nb_free < tx_pkt->nb_segs)
@@ -317,25 +361,12 @@ gve_tx_burst_qpl(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
if (txq->nb_free < nb_used)
goto end_of_tx;
- tx_offload.l2_len = tx_pkt->l2_len;
- tx_offload.l3_len = tx_pkt->l3_len;
- tx_offload.l4_len = tx_pkt->l4_len;
- tx_offload.tso_segsz = tx_pkt->tso_segsz;
-
first = tx_pkt;
txd = &txr[tx_id];
- hlen = ol_flags & RTE_MBUF_F_TX_TCP_SEG ?
- (uint32_t)(tx_offload.l2_len + tx_offload.l3_len + tx_offload.l4_len) :
- tx_pkt->pkt_len;
if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
uint32_t data_len, need;
- if (unlikely(tx_pkt->pkt_len <= hlen)) {
- rte_pktmbuf_free(tx_pkt);
- txq->stats.errors++;
- continue;
- }
data_len = tx_pkt->pkt_len - hlen;
need = RTE_ALIGN(hlen, RTE_CACHE_LINE_SIZE) +
RTE_ALIGN(data_len, RTE_CACHE_LINE_SIZE);
--
2.56.1.915.g69d5ec7298-goog
next prev parent reply other threads:[~2026-12-03 23:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 23:26 [PATCH 00/12] net/gve: stability fixes and DQO scattered Rx support Joshua Washington
2026-12-03 23:26 ` [PATCH 01/12] net/gve: disable queue start and stop Joshua Washington
2026-12-03 23:26 ` [PATCH 02/12] net/gve: free partially received GQI Rx packet Joshua Washington
2026-12-03 23:26 ` [PATCH 03/12] net/gve: fix integer underflow in GQI Rx path Joshua Washington
2026-12-03 23:26 ` Joshua Washington [this message]
2026-12-03 23:26 ` [PATCH 05/12] net/gve: do not count unsent DQO Tx packets as oerrors Joshua Washington
2026-12-03 23:26 ` [PATCH 06/12] net/gve: disable unsupported TCP LRO offload Joshua Washington
2026-12-03 23:26 ` [PATCH 07/12] net/gve: drop multi-seg Rx packets if scatter is off Joshua Washington
2026-12-03 23:26 ` [PATCH 08/12] net/gve: reject non-power-of-2 ring sizes on DQO Joshua Washington
2026-12-03 23:26 ` [PATCH 09/12] net/gve: properly handle RSS realloc failures Joshua Washington
2026-12-03 23:26 ` [PATCH 10/12] net/gve: reject unsupported flow attributes and item masks Joshua Washington
2026-12-03 23:26 ` [PATCH 11/12] net/gve: fix mbuf leak on GQI Rx queue start Joshua Washington
2026-12-03 23:26 ` [PATCH 12/12] net/gve: support scattered Rx for DQO Joshua Washington
2026-12-04 19:13 ` [PATCH 00/12] net/gve: stability fixes and DQO scattered Rx support 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=20261203232637.1044501-5-joshwash@google.com \
--to=joshwash@google.com \
--cc=dev@dpdk.org \
--cc=jtranoleary@google.com \
--cc=junfengg@nvidia.com \
--cc=stable@dpdk.org \
--cc=xiaoyun.li@intel.com \
/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