Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 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>

+2
+2
net/xfrm/xfrm_policy.c
··· 4290 4290 #endif 4291 4291 xfrm_policy_flush(net, XFRM_POLICY_TYPE_MAIN, false); 4292 4292 4293 + synchronize_rcu(); 4294 + 4293 4295 WARN_ON(!list_empty(&net->xfrm.policy_all)); 4294 4296 4295 4297 for (dir = 0; dir < XFRM_POLICY_MAX; dir++) {