mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] nfp: hold IPsec RX state under the XArray lock
@ 2026-09-21 18:15 Sang-Hoon Choi
  2026-09-24 17:10 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Sang-Hoon Choi @ 2026-09-21 18:15 UTC (permalink / raw)
  To: netdev
  Cc: Jakub Kicinski, Simon Horman, Andrew Lunn, David S. Miller,
	Eric Dumazet, Paolo Abeni, oss-drivers, linux-kernel,
	Changyul Lee


nfp_net_ipsec_rx() drops the XArray lock before taking a reference to the
xfrm_state it found. The delete path can erase the entry and drop the last
state reference in that interval. RX can then try to increment a zero
refcount after the state has been queued for destruction.

The driver queues firmware invalidation asynchronously; the delete path
does not wait for the command to complete or drain pending RX processing.

The XFRM garbage collector waits for an RCU grace period before freeing
the state. That delays reclamation but does not make acquiring a reference
from zero valid.

Take the xfrm_state reference before releasing the XArray lock so
xa_erase() cannot run between lookup and reference acquisition.

Fixes: 57f273adbcd4 ("nfp: add framework to support ipsec offloading")
Reported-by: Changyul Lee <lcy8047@gmail.com>
Assisted-by: LLM
Signed-off-by: Sang-Hoon Choi <csh0052@gmail.com>
---
Found during source review at mainline
5dd1818b15d98d4a20806cd00b1b40320b06004f. The affected source is unchanged
at 93f51579e7df248780214094418f205253383cc5.

The modified ipsec.o compiled in an x86 allmodconfig build. I have not
tested this with NFP IPsec offload hardware or reproduced the race with a
sanitizer. In particular, firmware invalidation and pending RX processing
have not been exercised together on hardware.

 drivers/net/ethernet/netronome/nfp/crypto/ipsec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/netronome/nfp/crypto/ipsec.c b/drivers/net/ethernet/netronome/nfp/crypto/ipsec.c
index 9e7c285ea..960d7513a 100644
--- a/drivers/net/ethernet/netronome/nfp/crypto/ipsec.c
+++ b/drivers/net/ethernet/netronome/nfp/crypto/ipsec.c
@@ -625,11 +625,12 @@ int nfp_net_ipsec_rx(struct nfp_meta_parsed *meta, struct sk_buff *skb)
 
 	xa_lock(&nn->xa_ipsec);
 	x = xa_load(&nn->xa_ipsec, saidx);
+	if (x)
+		xfrm_state_hold(x);
 	xa_unlock(&nn->xa_ipsec);
 	if (!x)
 		return -EINVAL;
 
-	xfrm_state_hold(x);
 	sp->xvec[sp->len++] = x;
 	sp->olen++;
 	xo = xfrm_offload(skb);

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

* Re: [PATCH net] nfp: hold IPsec RX state under the XArray lock
  2026-09-21 18:15 [PATCH net] nfp: hold IPsec RX state under the XArray lock Sang-Hoon Choi
@ 2026-09-24 17:10 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-09-24 17:10 UTC (permalink / raw)
  To: Sang-Hoon Choi
  Cc: netdev, kuba, horms, andrew+netdev, davem, edumazet, pabeni,
	oss-drivers, linux-kernel, lcy8047

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 22 Sep 2026 03:15:59 +0900 you wrote:
> nfp_net_ipsec_rx() drops the XArray lock before taking a reference to the
> xfrm_state it found. The delete path can erase the entry and drop the last
> state reference in that interval. RX can then try to increment a zero
> refcount after the state has been queued for destruction.
> 
> The driver queues firmware invalidation asynchronously; the delete path
> does not wait for the command to complete or drain pending RX processing.
> 
> [...]

Here is the summary with links:
  - [net] nfp: hold IPsec RX state under the XArray lock
    https://git.kernel.org/netdev/net/c/1a983a4e14c6

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2026-09-24 17:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-21 18:15 [PATCH net] nfp: hold IPsec RX state under the XArray lock Sang-Hoon Choi
2026-09-24 17:10 ` patchwork-bot+netdevbpf

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®