Revert "xfrm: Fix RCU vs hash_resize_mutex lock inversion"
This reverts commit f08b2d078c
which is
commit 2580d3f40022642452dd8422bfb8c22e54cf84bb upstream.
It breaks the abi and should not be needed for Android systems.
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I13a6e3459cc2c7fb31b4cbc1185a9b463fc61c6e
This commit is contained in:
@@ -75,7 +75,6 @@ struct netns_xfrm {
|
||||
#endif
|
||||
spinlock_t xfrm_state_lock;
|
||||
seqcount_t xfrm_state_hash_generation;
|
||||
seqcount_spinlock_t xfrm_policy_hash_generation;
|
||||
|
||||
spinlock_t xfrm_policy_lock;
|
||||
struct mutex xfrm_cfg_mutex;
|
||||
|
@@ -155,6 +155,7 @@ static struct xfrm_policy_afinfo const __rcu *xfrm_policy_afinfo[AF_INET6 + 1]
|
||||
__read_mostly;
|
||||
|
||||
static struct kmem_cache *xfrm_dst_cache __ro_after_init;
|
||||
static __read_mostly seqcount_mutex_t xfrm_policy_hash_generation;
|
||||
|
||||
static struct rhashtable xfrm_policy_inexact_table;
|
||||
static const struct rhashtable_params xfrm_pol_inexact_params;
|
||||
@@ -584,7 +585,7 @@ static void xfrm_bydst_resize(struct net *net, int dir)
|
||||
return;
|
||||
|
||||
spin_lock_bh(&net->xfrm.xfrm_policy_lock);
|
||||
write_seqcount_begin(&net->xfrm.xfrm_policy_hash_generation);
|
||||
write_seqcount_begin(&xfrm_policy_hash_generation);
|
||||
|
||||
odst = rcu_dereference_protected(net->xfrm.policy_bydst[dir].table,
|
||||
lockdep_is_held(&net->xfrm.xfrm_policy_lock));
|
||||
@@ -595,7 +596,7 @@ static void xfrm_bydst_resize(struct net *net, int dir)
|
||||
rcu_assign_pointer(net->xfrm.policy_bydst[dir].table, ndst);
|
||||
net->xfrm.policy_bydst[dir].hmask = nhashmask;
|
||||
|
||||
write_seqcount_end(&net->xfrm.xfrm_policy_hash_generation);
|
||||
write_seqcount_end(&xfrm_policy_hash_generation);
|
||||
spin_unlock_bh(&net->xfrm.xfrm_policy_lock);
|
||||
|
||||
synchronize_rcu();
|
||||
@@ -1244,7 +1245,7 @@ static void xfrm_hash_rebuild(struct work_struct *work)
|
||||
} while (read_seqretry(&net->xfrm.policy_hthresh.lock, seq));
|
||||
|
||||
spin_lock_bh(&net->xfrm.xfrm_policy_lock);
|
||||
write_seqcount_begin(&net->xfrm.xfrm_policy_hash_generation);
|
||||
write_seqcount_begin(&xfrm_policy_hash_generation);
|
||||
|
||||
/* make sure that we can insert the indirect policies again before
|
||||
* we start with destructive action.
|
||||
@@ -1353,7 +1354,7 @@ static void xfrm_hash_rebuild(struct work_struct *work)
|
||||
|
||||
out_unlock:
|
||||
__xfrm_policy_inexact_flush(net);
|
||||
write_seqcount_end(&net->xfrm.xfrm_policy_hash_generation);
|
||||
write_seqcount_end(&xfrm_policy_hash_generation);
|
||||
spin_unlock_bh(&net->xfrm.xfrm_policy_lock);
|
||||
|
||||
mutex_unlock(&hash_resize_mutex);
|
||||
@@ -2094,9 +2095,9 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type,
|
||||
rcu_read_lock();
|
||||
retry:
|
||||
do {
|
||||
sequence = read_seqcount_begin(&net->xfrm.xfrm_policy_hash_generation);
|
||||
sequence = read_seqcount_begin(&xfrm_policy_hash_generation);
|
||||
chain = policy_hash_direct(net, daddr, saddr, family, dir);
|
||||
} while (read_seqcount_retry(&net->xfrm.xfrm_policy_hash_generation, sequence));
|
||||
} while (read_seqcount_retry(&xfrm_policy_hash_generation, sequence));
|
||||
|
||||
ret = NULL;
|
||||
hlist_for_each_entry_rcu(pol, chain, bydst) {
|
||||
@@ -2127,7 +2128,7 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type,
|
||||
}
|
||||
|
||||
skip_inexact:
|
||||
if (read_seqcount_retry(&net->xfrm.xfrm_policy_hash_generation, sequence))
|
||||
if (read_seqcount_retry(&xfrm_policy_hash_generation, sequence))
|
||||
goto retry;
|
||||
|
||||
if (ret && !xfrm_pol_hold_rcu(ret))
|
||||
@@ -4122,7 +4123,6 @@ static int __net_init xfrm_net_init(struct net *net)
|
||||
/* Initialize the per-net locks here */
|
||||
spin_lock_init(&net->xfrm.xfrm_state_lock);
|
||||
spin_lock_init(&net->xfrm.xfrm_policy_lock);
|
||||
seqcount_spinlock_init(&net->xfrm.xfrm_policy_hash_generation, &net->xfrm.xfrm_policy_lock);
|
||||
mutex_init(&net->xfrm.xfrm_cfg_mutex);
|
||||
|
||||
rv = xfrm_statistics_init(net);
|
||||
@@ -4167,6 +4167,7 @@ void __init xfrm_init(void)
|
||||
{
|
||||
register_pernet_subsys(&xfrm_net_ops);
|
||||
xfrm_dev_init();
|
||||
seqcount_mutex_init(&xfrm_policy_hash_generation, &hash_resize_mutex);
|
||||
xfrm_input_init();
|
||||
|
||||
#ifdef CONFIG_XFRM_ESPINTCP
|
||||
|
Reference in New Issue
Block a user