rhashtable: use get_random_u32 for hash_rnd
authorJason A. Donenfeld <Jason@zx2c4.com>
Thu, 8 Jun 2017 02:47:13 +0000 (22:47 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 20 Jun 2017 02:06:28 +0000 (22:06 -0400)
This is much faster and just as secure. It also has the added benefit of
probably returning better randomness at early-boot on systems with
architectural RNGs.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: Thomas Graf <tgraf@suug.ch>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/rhashtable.c

index d9e7274a04cd98d14456b1bba9ad2e241eae8895..a1eb7c947f4670deb67135f8dcdb9353f5991212 100644 (file)
@@ -235,7 +235,7 @@ static struct bucket_table *bucket_table_alloc(struct rhashtable *ht,
 
        INIT_LIST_HEAD(&tbl->walkers);
 
-       get_random_bytes(&tbl->hash_rnd, sizeof(tbl->hash_rnd));
+       tbl->hash_rnd = get_random_u32();
 
        for (i = 0; i < nbuckets; i++)
                INIT_RHT_NULLS_HEAD(tbl->buckets[i], ht, i);