aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm/xfrm_user.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2010-03-30 20:17:05 -0400
committerDavid S. Miller <davem@davemloft.net>2010-04-01 22:41:35 -0400
commitea2dea9dacc256fe927857feb423872051642ae7 (patch)
tree507da54eb46680b833ead15c3e74f9312cf10c22 /net/xfrm/xfrm_user.c
parentc8bf4d04f970fafb3430d332533e1cf103f2a018 (diff)
xfrm: remove policy lock when accessing policy->walk.dead
All of the code considers ->dead as a hint that the cached policy needs to get refreshed. The read side can just drop the read lock without any side effects. The write side needs to make sure that it's written only exactly once. Only possible race is at xfrm_policy_kill(). This is fixed by checking result of __xfrm_policy_unlink() when needed. It will always succeed if the policy object is looked up from the hash list (so some checks are removed), but it needs to be checked if we are trying to unlink policy via a reference (appropriate checks added). Since policy->walk.dead is written exactly once, it no longer needs to be protected with a write lock. Signed-off-by: Timo Teras <timo.teras@iki.fi> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/xfrm/xfrm_user.c')
-rw-r--r--net/xfrm/xfrm_user.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index da5ba86181de..a267fbdda525 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1770,13 +1770,9 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
1770 if (xp == NULL) 1770 if (xp == NULL)
1771 return -ENOENT; 1771 return -ENOENT;
1772 1772
1773 read_lock(&xp->lock); 1773 if (unlikely(xp->walk.dead))
1774 if (xp->walk.dead) {
1775 read_unlock(&xp->lock);
1776 goto out; 1774 goto out;
1777 }
1778 1775
1779 read_unlock(&xp->lock);
1780 err = 0; 1776 err = 0;
1781 if (up->hard) { 1777 if (up->hard) {
1782 uid_t loginuid = NETLINK_CB(skb).loginuid; 1778 uid_t loginuid = NETLINK_CB(skb).loginuid;