[SRU][J:linux-gcp/J:linux-gke][PATCH v3 06/13] idpf: fix corrupted frames and skb leaks in singleq mode
Ian Whitfield
ian.whitfield at canonical.com
Tue Apr 1 16:22:05 UTC 2025
From: Alexander Lobakin <aleksander.lobakin at intel.com>
BugLink: https://bugs.launchpad.net/bugs/2093622
idpf_ring::skb serves only for keeping an incomplete frame between
several NAPI Rx polling cycles, as one cycle may end up before
processing the end of packet descriptor. The pointer is taken from
the ring onto the stack before entering the loop and gets written
there after the loop exits. When inside the loop, only the onstack
pointer is used.
For some reason, the logics is broken in the singleq mode, where the
pointer is taken from the ring each iteration. This means that if a
frame got fragmented into several descriptors, each fragment will have
its own skb, but only the last one will be passed up the stack
(containing garbage), leaving the rest leaked.
Then, on ifdown, rxq::skb is being freed only in the splitq mode, while
it can point to a valid skb in singleq as well. This can lead to a yet
another skb leak.
Just don't touch the ring skb field inside the polling loop, letting
the onstack skb pointer work as expected: build a new skb if it's the
first frame descriptor and attach a frag otherwise. On ifdown, free
rxq::skb unconditionally if the pointer is non-NULL.
Fixes: a5ab9ee0df0b ("idpf: add singleq start_xmit and napi poll")
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel at intel.com>
Reviewed-by: Michal Kubiak <michal.kubiak at intel.com>
Reviewed-by: Simon Horman <horms at kernel.org>
Reviewed-by: Eric Dumazet <edumazet at google.com>
Signed-off-by: Alexander Lobakin <aleksander.lobakin at intel.com>
Tested-by: Scott Register <scott.register at intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen at intel.com>
(cherry picked from commit fea7b71b8751a0bfa7fdf9977e5782f061f71589)
Signed-off-by: Ian Whitfield <ian.whitfield at canonical.com>
---
drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c | 1 -
drivers/net/ethernet/intel/idpf/idpf_txrx.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
index ef634d57c78d..a1f2526097ff 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
@@ -1051,7 +1051,6 @@ static int idpf_rx_singleq_clean(struct idpf_queue *rx_q, int budget)
}
idpf_rx_sync_for_cpu(rx_buf, fields.size);
- skb = rx_q->skb;
if (skb)
idpf_rx_add_frag(rx_buf, skb, fields.size);
else
diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
index e0412ed1018e..9590bb40abba 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_txrx.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
@@ -397,7 +397,7 @@ static void idpf_rx_desc_rel(struct idpf_queue *rxq, bool bufq, s32 q_model)
if (!rxq)
return;
- if (!bufq && idpf_is_queue_model_split(q_model) && rxq->skb) {
+ if (rxq->skb) {
dev_kfree_skb_any(rxq->skb);
rxq->skb = NULL;
}
--
2.43.0
More information about the kernel-team
mailing list