mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] octeontx2-pf: fix XDP frames freed as skbs on interface down
@ 2026-10-30 20:12 Nicolai Buchwitz
  2026-11-02  4:27 ` Ratheesh Kannoth
  2026-11-02 11:30 ` Daniel Machon
  0 siblings, 2 replies; 4+ messages in thread
From: Nicolai Buchwitz @ 2026-10-30 20:12 UTC (permalink / raw)
  To: Sunil Goutham, Geetha sowjanya, Ratheesh Kannoth,
	Subbaraya Sundeep, Bharat Bhushan, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
	Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
	Stanislav Fomichev, Suman Ghosh
  Cc: netdev, linux-kernel, bpf, Nicolai Buchwitz

On interface down, the TX completion cleanup also runs on the XDP
queues, but treats the pending xdp_frames as skbs. Freeing them with
dev_kfree_skb_any() corrupts page pool memory.

This happens when XDP_TX or redirected packets are still in flight on
ifdown, or when the XDP program is replaced.

Fixes: 94c80f748873 ("octeontx2-pf: use xdp_return_frame() to free xdp buffers")
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
Pre-existing bug, flagged by the clashiko review of my ipsec transmit
fixes for this driver [1], which seems reasonable (and fixable) to me.

The other pre-existing findings there (e.g. the SA lifetime in
cn10k_ipsec_del_state()) may be worth fixing too, but I'll leave those
to the maintainers.

Compile-tested only, I have no octeontx2 hardware.

[1] https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261027-nb-otx2-ipsec-tx-fixes-net-v1-0-2114c4f10c36%40tipi-net.de
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
index 90af9b9044aa0..e3b07e5335fb8 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
@@ -1332,6 +1332,7 @@ void otx2_cleanup_tx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq)
 	struct nix_cqe_tx_s *cqe;
 	struct netdev_queue *txq;
 	int processed_cqe = 0;
+	int xsk_frames = 0;
 	struct sg_list *sg;
 	int qidx;
 
@@ -1348,6 +1349,10 @@ void otx2_cleanup_tx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq)
 
 		if (!cqe)
 			continue;
+		if (cq->cq_type == CQ_XDP) {
+			otx2_xdp_snd_pkt_handler(pfvf, sq, cqe, &xsk_frames);
+			continue;
+		}
 		sg = &sq->sg[cqe->comp.sqe_id];
 		skb = (struct sk_buff *)sg->skb;
 		if (skb) {

---
base-commit: d8a4f4c59da52b7c31ae337243b8473a19a3f819
change-id: 20261028-nb-otx2-xdp-cqe-cleanup-net-5810d40e1d30

Best regards,
--  
Nicolai Buchwitz <nb@tipi-net.de>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] octeontx2-pf: fix XDP frames freed as skbs on interface down
  2026-10-30 20:12 [PATCH net] octeontx2-pf: fix XDP frames freed as skbs on interface down Nicolai Buchwitz
@ 2026-11-02  4:27 ` Ratheesh Kannoth
  2026-11-02 11:30 ` Daniel Machon
  1 sibling, 0 replies; 4+ messages in thread
From: Ratheesh Kannoth @ 2026-11-02  4:27 UTC (permalink / raw)
  To: Nicolai Buchwitz
  Cc: Sunil Goutham, Geetha sowjanya, Subbaraya Sundeep,
	Bharat Bhushan, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
	Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
	Suman Ghosh, netdev, linux-kernel, bpf

On 2026-10-31 at 01:42:03, Nicolai Buchwitz (nb@tipi-net.de) wrote:
> On interface down, the TX completion cleanup also runs on the XDP
> queues, but treats the pending xdp_frames as skbs. Freeing them with
> dev_kfree_skb_any() corrupts page pool memory.
>
> This happens when XDP_TX or redirected packets are still in flight on
> ifdown, or when the XDP program is replaced.
>
> Fixes: 94c80f748873 ("octeontx2-pf: use xdp_return_frame() to free xdp buffers")
> Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
> ---
> Pre-existing bug, flagged by the clashiko review of my ipsec transmit
> fixes for this driver [1], which seems reasonable (and fixable) to me.
>
> The other pre-existing findings there (e.g. the SA lifetime in
> cn10k_ipsec_del_state()) may be worth fixing too, but I'll leave those
> to the maintainers.
>
Thank you.

Reviewed-by: Ratheesh Kannoth <rkannoth@marvell.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] octeontx2-pf: fix XDP frames freed as skbs on interface down
  2026-10-30 20:12 [PATCH net] octeontx2-pf: fix XDP frames freed as skbs on interface down Nicolai Buchwitz
  2026-11-02  4:27 ` Ratheesh Kannoth
@ 2026-11-02 11:30 ` Daniel Machon
  2026-11-02 11:44   ` Nicolai Buchwitz
  1 sibling, 1 reply; 4+ messages in thread
From: Daniel Machon @ 2026-11-02 11:30 UTC (permalink / raw)
  To: Nicolai Buchwitz
  Cc: Sunil Goutham, Geetha sowjanya, Ratheesh Kannoth,
	Subbaraya Sundeep, Bharat Bhushan, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
	Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
	Stanislav Fomichev, Suman Ghosh, netdev, linux-kernel, bpf

Hi Nicolai,

> On interface down, the TX completion cleanup also runs on the XDP
> queues, but treats the pending xdp_frames as skbs. Freeing them with
> dev_kfree_skb_any() corrupts page pool memory.
> 
> This happens when XDP_TX or redirected packets are still in flight on
> ifdown, or when the XDP program is replaced.
> 
> Fixes: 94c80f748873 ("octeontx2-pf: use xdp_return_frame() to free xdp buffers")
> Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
> ---
> Pre-existing bug, flagged by the clashiko review of my ipsec transmit
> fixes for this driver [1], which seems reasonable (and fixable) to me.
> 
> The other pre-existing findings there (e.g. the SA lifetime in
> cn10k_ipsec_del_state()) may be worth fixing too, but I'll leave those
> to the maintainers.
> 
> Compile-tested only, I have no octeontx2 hardware.
> 
> [1] https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261027-nb-otx2-ipsec-tx-fixes-net-v1-0-2114c4f10c36%40tipi-net.de
> ---
>  drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
> index 90af9b9044aa0..e3b07e5335fb8 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
> @@ -1332,6 +1332,7 @@ void otx2_cleanup_tx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq)
>  	struct nix_cqe_tx_s *cqe;
>  	struct netdev_queue *txq;
>  	int processed_cqe = 0;
> +	int xsk_frames = 0;
>  	struct sg_list *sg;
>  	int qidx;
>  
> @@ -1348,6 +1349,10 @@ void otx2_cleanup_tx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq)
>  
>  		if (!cqe)
>  			continue;
> +		if (cq->cq_type == CQ_XDP) {
> +			otx2_xdp_snd_pkt_handler(pfvf, sq, cqe, &xsk_frames);

Any reason xsk_frames is never handed to xsk_tx_completed()?

> +			continue;
> +		}
>  		sg = &sq->sg[cqe->comp.sqe_id];
>  		skb = (struct sk_buff *)sg->skb;
>  		if (skb) {
> 
> ---
> base-commit: d8a4f4c59da52b7c31ae337243b8473a19a3f819
> change-id: 20261028-nb-otx2-xdp-cqe-cleanup-net-5810d40e1d30
> 
> Best regards,
> --  
> Nicolai Buchwitz <nb@tipi-net.de>
> 

/Daniel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] octeontx2-pf: fix XDP frames freed as skbs on interface down
  2026-11-02 11:30 ` Daniel Machon
@ 2026-11-02 11:44   ` Nicolai Buchwitz
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolai Buchwitz @ 2026-11-02 11:44 UTC (permalink / raw)
  To: Daniel Machon
  Cc: Sunil Goutham, Geetha sowjanya, Ratheesh Kannoth,
	Subbaraya Sundeep, Bharat Bhushan, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
	Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
	Stanislav Fomichev, Suman Ghosh, netdev, linux-kernel, bpf

On 2.11.2026 12:30, Daniel Machon wrote:

> [...]

>> @@ -1348,6 +1349,10 @@ void otx2_cleanup_tx_cqes(struct otx2_nic 
>> *pfvf, struct otx2_cq_queue *cq)
>> 
>>  		if (!cqe)
>>  			continue;
>> +		if (cq->cq_type == CQ_XDP) {
>> +			otx2_xdp_snd_pkt_handler(pfvf, sq, cqe, &xsk_frames);
> 
> Any reason xsk_frames is never handed to xsk_tx_completed()?

No, just missed that, thanks. I'll send a v2 with this fixed, after 
waiting for
potential feedback from clashiko later today.

> [...]

Regards,
Nicolai

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-02 11:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-30 20:12 [PATCH net] octeontx2-pf: fix XDP frames freed as skbs on interface down Nicolai Buchwitz
2026-11-02  4:27 ` Ratheesh Kannoth
2026-11-02 11:30 ` Daniel Machon
2026-11-02 11:44   ` Nicolai Buchwitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®