rhashtable: Fix read-side crash during rehash
authorHerbert Xu <herbert@gondor.apana.org.au>
Fri, 13 Mar 2015 01:54:10 +0000 (12:54 +1100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 13 Mar 2015 03:02:30 +0000 (23:02 -0400)
This patch fixes a typo rhashtable_lookup_compare where we fail
to recompute the hash when looking up the new table.  This causes
elements to be missed and potentially a crash during a resize.

Reported-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
lib/rhashtable.c

index adea791ea3ab85d8ea582256e374d9d692579b4a..fc0d451279f0e0a1c8ac8202f336d6d456aa2aec 100644 (file)
@@ -606,8 +606,8 @@ void *rhashtable_lookup_compare(struct rhashtable *ht, const void *key,
        rcu_read_lock();
 
        tbl = rht_dereference_rcu(ht->tbl, ht);
-       hash = key_hashfn(ht, tbl, key);
 restart:
+       hash = key_hashfn(ht, tbl, key);
        rht_for_each_rcu(he, tbl, hash) {
                if (!compare(rht_obj(ht, he), arg))
                        continue;