Commit 069daad4 authored by Steffen Klassert's avatar Steffen Klassert
Browse files

xfrm: Wait for RCU readers during policy netns exit



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: e1e551bc ("xfrm: policy: prepare policy_bydst hash for rcu lookups")
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
Reviewed-by: default avatarFlorian Westphal <fw@strlen.de>
parent 7081d46d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -4290,6 +4290,8 @@ static void xfrm_policy_fini(struct net *net)
#endif
	xfrm_policy_flush(net, XFRM_POLICY_TYPE_MAIN, false);

	synchronize_rcu();

	WARN_ON(!list_empty(&net->xfrm.policy_all));

	for (dir = 0; dir < XFRM_POLICY_MAX; dir++) {