mirror of
https://github.com/torvalds/linux.git
synced 2026-09-29 04:22:03 +02:00
nfp: hold IPsec RX state under the XArray lock
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: 57f273adbc ("nfp: add framework to support ipsec offloading")
Reported-by: Changyul Lee <lcy8047@gmail.com>
Signed-off-by: Sang-Hoon Choi <csh0052@gmail.com>
Link: https://patch.msgid.link/179001455912.44752.17153022439349797877.idr-bug-92@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
5b49efa1e1
commit
1a983a4e14
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user