diff options
author | Eric Dumazet <edumazet@google.com> | 2015-12-08 10:22:01 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-12-11 19:22:06 -0500 |
commit | 56f047305dd4b6b61771ac4f523718e4111052a8 (patch) | |
tree | 05de0e01553b3040c009048ee446b849a3f697e1 /net/xfrm | |
parent | b0a8d1a0b6e569b7dd14322ca2df4d576f325908 (diff) |
xfrm: add rcu grace period in xfrm_policy_destroy()
We will soon switch sk->sk_policy[] to RCU protection,
as SYNACK packets are sent while listener socket is not locked.
This patch simply adds RCU grace period before struct xfrm_policy
freeing, and the corresponding rcu_head in struct xfrm_policy.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/xfrm')
-rw-r--r-- | net/xfrm/xfrm_policy.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 18276f0cc32b..f57a5712cedd 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
@@ -303,6 +303,14 @@ struct xfrm_policy *xfrm_policy_alloc(struct net *net, gfp_t gfp) | |||
303 | } | 303 | } |
304 | EXPORT_SYMBOL(xfrm_policy_alloc); | 304 | EXPORT_SYMBOL(xfrm_policy_alloc); |
305 | 305 | ||
306 | static void xfrm_policy_destroy_rcu(struct rcu_head *head) | ||
307 | { | ||
308 | struct xfrm_policy *policy = container_of(head, struct xfrm_policy, rcu); | ||
309 | |||
310 | security_xfrm_policy_free(policy->security); | ||
311 | kfree(policy); | ||
312 | } | ||
313 | |||
306 | /* Destroy xfrm_policy: descendant resources must be released to this moment. */ | 314 | /* Destroy xfrm_policy: descendant resources must be released to this moment. */ |
307 | 315 | ||
308 | void xfrm_policy_destroy(struct xfrm_policy *policy) | 316 | void xfrm_policy_destroy(struct xfrm_policy *policy) |
@@ -312,8 +320,7 @@ void xfrm_policy_destroy(struct xfrm_policy *policy) | |||
312 | if (del_timer(&policy->timer) || del_timer(&policy->polq.hold_timer)) | 320 | if (del_timer(&policy->timer) || del_timer(&policy->polq.hold_timer)) |
313 | BUG(); | 321 | BUG(); |
314 | 322 | ||
315 | security_xfrm_policy_free(policy->security); | 323 | call_rcu(&policy->rcu, xfrm_policy_destroy_rcu); |
316 | kfree(policy); | ||
317 | } | 324 | } |
318 | EXPORT_SYMBOL(xfrm_policy_destroy); | 325 | EXPORT_SYMBOL(xfrm_policy_destroy); |
319 | 326 | ||