From: Florian Westphal Date: Fri, 7 Mar 2025 11:47:54 +0000 (+0100) Subject: xfrm: state: make xfrm_state_lookup_byaddr lockless X-Git-Tag: v6.15-rc1~160^2~15^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e460eefbd4469420349bdcb81b331a46211717a;p=thirdparty%2Fkernel%2Flinux.git xfrm: state: make xfrm_state_lookup_byaddr lockless This appears to be an oversight back when the state lookup was converted to RCU, I see no reason why we need to hold the state lock here. __xfrm_state_lookup_byaddr already uses xfrm_state_hold_rcu helper to obtain a reference, so just replace the state lock with rcu. Signed-off-by: Florian Westphal Signed-off-by: Steffen Klassert --- diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 7b10286711441..07545944a5369 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -2313,12 +2313,12 @@ xfrm_state_lookup_byaddr(struct net *net, u32 mark, struct xfrm_hash_state_ptrs state_ptrs; struct xfrm_state *x; - spin_lock_bh(&net->xfrm.xfrm_state_lock); + rcu_read_lock(); xfrm_hash_ptrs_get(net, &state_ptrs); x = __xfrm_state_lookup_byaddr(&state_ptrs, mark, daddr, saddr, proto, family); - spin_unlock_bh(&net->xfrm.xfrm_state_lock); + rcu_read_unlock(); return x; } EXPORT_SYMBOL(xfrm_state_lookup_byaddr);