aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2016-08-09 06:16:06 -0400
committerSteffen Klassert <steffen.klassert@secunet.com>2016-08-10 05:23:23 -0400
commitdf7274eb70b7c8488170ebe8757dd94647a8e1e5 (patch)
tree9c750e4e1ef1315fcc8a8dd517591b97b94cf955 /net/xfrm
parent02efdff7e209859c2755ebe93b3bd0e3d40123ab (diff)
xfrm: state: delay freeing until rcu grace period has elapsed
The hash table backend memory and the state structs are free'd via kfree/vfree. Once we only rely on rcu during lookups we have to make sure no other cpu is currently accessing this before doing the free. Free operations already happen from worker so we can use synchronize_rcu to wait until concurrent readers are done. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/xfrm')
-rw-r--r--net/xfrm/xfrm_state.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 84c1db6254d5..8e373876924f 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -146,6 +146,9 @@ static void xfrm_hash_resize(struct work_struct *work)
146 spin_unlock_bh(&net->xfrm.xfrm_state_lock); 146 spin_unlock_bh(&net->xfrm.xfrm_state_lock);
147 147
148 osize = (ohashmask + 1) * sizeof(struct hlist_head); 148 osize = (ohashmask + 1) * sizeof(struct hlist_head);
149
150 synchronize_rcu();
151
149 xfrm_hash_free(odst, osize); 152 xfrm_hash_free(odst, osize);
150 xfrm_hash_free(osrc, osize); 153 xfrm_hash_free(osrc, osize);
151 xfrm_hash_free(ospi, osize); 154 xfrm_hash_free(ospi, osize);
@@ -369,6 +372,8 @@ static void xfrm_state_gc_task(struct work_struct *work)
369 hlist_move_list(&net->xfrm.state_gc_list, &gc_list); 372 hlist_move_list(&net->xfrm.state_gc_list, &gc_list);
370 spin_unlock_bh(&xfrm_state_gc_lock); 373 spin_unlock_bh(&xfrm_state_gc_lock);
371 374
375 synchronize_rcu();
376
372 hlist_for_each_entry_safe(x, tmp, &gc_list, gclist) 377 hlist_for_each_entry_safe(x, tmp, &gc_list, gclist)
373 xfrm_state_gc_destroy(x); 378 xfrm_state_gc_destroy(x);
374} 379}