Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1658277

[PATCH v3 10/13] net/neighbor: use get_random_u32 for 32-bit hash random

From "Jason A. Donenfeld" <Jason@zx2c4.com>
Newsgroups linux.kernel
Subject [PATCH v3 10/13] net/neighbor: use get_random_u32 for 32-bit hash random
Date 2017-06-06 03:00 +0200
Message-ID <tPb0M-1BU-81@gated-at.bofh.it> (permalink)
References <tPb0J-1BU-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Using get_random_u32 here is faster, more fitting of the use case, and
just as cryptographically secure. It also has the benefit of providing
better randomness at early boot, which is when many of these structures
are assigned.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: David Miller <davem@davemloft.net>
---
 net/core/neighbour.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index d274f81fcc2c..9784133b0cdb 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -312,8 +312,7 @@ static struct neighbour *neigh_alloc(struct neigh_table *tbl, struct net_device
 
 static void neigh_get_hash_rnd(u32 *x)
 {
-	get_random_bytes(x, sizeof(*x));
-	*x |= 1;
+	*x = get_random_u32() | 1;
 }
 
 static struct neigh_hash_table *neigh_hash_alloc(unsigned int shift)
-- 
2.13.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3 00/13] Unseeded In-Kernel Randomness Fixes "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-06 03:00 +0200
  [PATCH v3 10/13] net/neighbor: use get_random_u32 for 32-bit hash random "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-06 03:00 +0200
  [PATCH v3 03/13] random: invalidate batched entropy after crng init "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-06 03:00 +0200
  [PATCH v3 09/13] rhashtable: use get_random_u32 for hash_rnd "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-06 03:00 +0200
  [PATCH v3 05/13] security/keys: ensure RNG is seeded before use "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-06 03:00 +0200
    Re: [PATCH v3 05/13] security/keys: ensure RNG is seeded before use David Howells <dhowells@redhat.com> - 2017-06-06 12:10 +0200
      Re: [PATCH v3 05/13] security/keys: ensure RNG is seeded before use "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-06 14:30 +0200
  [PATCH v3 01/13] random: add synchronous API for the urandom pool "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-06 03:00 +0200
  [PATCH v3 11/13] net/route: use get_random_int for random counter "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-06 03:00 +0200
  [PATCH v3 07/13] ceph: ensure RNG is seeded before using "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-06 03:00 +0200
  [PATCH v3 02/13] random: add get_random_{bytes,u32,u64,int,long,once}_wait family "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-06 03:00 +0200
    Re: [PATCH v3 02/13] random: add get_random_{bytes,u32,u64,int,long,once}_wait  family Jeffrey Walton <noloader@gmail.com> - 2017-06-06 07:20 +0200
      Re: [PATCH v3 02/13] random: add get_random_{bytes,u32,u64,int,long,once}_wait  family "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-06 14:30 +0200

csiph-web