diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2015-05-16 21:16:28 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-06-22 17:03:24 -0700 |
commit | cf8befcc1a5538b035d478424efcc2d50e66928e (patch) | |
tree | fdb4217cf0e596fb9793e2f3314ea2c4ed1a8179 /net | |
parent | 7888409c58518263096b5b7f953c08b85868e3fc (diff) |
netlink: Disable insertions/removals during rehash
[ Upstream commit: Not applicable ]
The current rhashtable rehash code is buggy and can't deal with
parallel insertions/removals without corrupting the hash table.
This patch disables it by partially reverting
c5adde9468b0714a051eac7f9666f23eb10b61f7 ("netlink: eliminate
nl_sk_hash_lock").
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/netlink/af_netlink.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index e98dc53f30ce..0e9c28dc86b7 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -1052,7 +1052,7 @@ static int netlink_insert(struct sock *sk, u32 portid) struct netlink_table *table = &nl_table[sk->sk_protocol]; int err; - lock_sock(sk); + mutex_lock(&table->hash.mutex); err = -EBUSY; if (nlk_sk(sk)->portid) @@ -1074,7 +1074,7 @@ static int netlink_insert(struct sock *sk, u32 portid) } err: - release_sock(sk); + mutex_unlock(&table->hash.mutex); return err; } @@ -1083,10 +1083,12 @@ static void netlink_remove(struct sock *sk) struct netlink_table *table; table = &nl_table[sk->sk_protocol]; + mutex_lock(&table->hash.mutex); if (rhashtable_remove(&table->hash, &nlk_sk(sk)->node)) { WARN_ON(atomic_read(&sk->sk_refcnt) == 1); __sock_put(sk); } + mutex_unlock(&table->hash.mutex); netlink_table_grab(); if (nlk_sk(sk)->subscriptions) { |