Commit eaf22826 authored by Steffen Klassert's avatar Steffen Klassert

Revert "xfrm: policy: Read seqcount outside of rcu-read side in xfrm_policy_lookup_bytype"

This reverts commit d7b04089.

This commit tried to fix a locking bug introduced by commit 77cc278f
("xfrm: policy: Use sequence counters with associated lock"). As it
turned out, this patch did not really fix the bug. A proper fix
for this bug is applied on top of this revert.
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
parent 7c1a80e8
...@@ -2092,15 +2092,12 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type, ...@@ -2092,15 +2092,12 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type,
if (unlikely(!daddr || !saddr)) if (unlikely(!daddr || !saddr))
return NULL; return NULL;
rcu_read_lock();
retry: retry:
do {
sequence = read_seqcount_begin(&xfrm_policy_hash_generation); sequence = read_seqcount_begin(&xfrm_policy_hash_generation);
rcu_read_lock();
chain = policy_hash_direct(net, daddr, saddr, family, dir); chain = policy_hash_direct(net, daddr, saddr, family, dir);
if (read_seqcount_retry(&xfrm_policy_hash_generation, sequence)) { } while (read_seqcount_retry(&xfrm_policy_hash_generation, sequence));
rcu_read_unlock();
goto retry;
}
ret = NULL; ret = NULL;
hlist_for_each_entry_rcu(pol, chain, bydst) { hlist_for_each_entry_rcu(pol, chain, bydst) {
...@@ -2131,15 +2128,11 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type, ...@@ -2131,15 +2128,11 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type,
} }
skip_inexact: skip_inexact:
if (read_seqcount_retry(&xfrm_policy_hash_generation, sequence)) { if (read_seqcount_retry(&xfrm_policy_hash_generation, sequence))
rcu_read_unlock();
goto retry; goto retry;
}
if (ret && !xfrm_pol_hold_rcu(ret)) { if (ret && !xfrm_pol_hold_rcu(ret))
rcu_read_unlock();
goto retry; goto retry;
}
fail: fail:
rcu_read_unlock(); rcu_read_unlock();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment