]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
xfrm: Wait for RCU readers during policy netns exit
authorSteffen Klassert <steffen.klassert@secunet.com>
Thu, 2 Apr 2026 11:31:04 +0000 (13:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Apr 2026 11:30:40 +0000 (13:30 +0200)
commit33a3149dd81a1e2f52b80ee1e0fc380b39f3d028
tree3ae139957915d28cdb72f7865af45562d78dd921
parentc99bcb566ce963bb094371185c5e0b021ab85854
xfrm: Wait for RCU readers during policy netns exit

[ Upstream commit 069daad4f2ae9c5c108131995529d5f02392c446 ]

xfrm_policy_fini() frees the policy_bydst hash tables after flushing the
policy work items and deleting all policies, but it does not wait for
concurrent RCU readers to leave their read-side critical sections first.

The policy_bydst tables are published via rcu_assign_pointer() and are
looked up through rcu_dereference_check(), so netns teardown must also
wait for an RCU grace period before freeing the table memory.

Fix this by adding synchronize_rcu() before freeing the policy hash tables.

Fixes: e1e551bc5630 ("xfrm: policy: prepare policy_bydst hash for rcu lookups")
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/xfrm/xfrm_policy.c