random32: make prandom_u32() less predictable
This is the cleanup of the latest series of prandom_u32 experimentations
consisting in using SipHash instead of Tausworthe to produce the randoms
used by the network stack. The changes to the files were kept minimal,
and the controversial commit that used to take noise from the fast_pool
(f227e3ec3b5c) was reverted. Instead, a dedicated "net_rand_noise" per_cpu
variable is fed from various sources of activities (networking, scheduling)
to perturb the SipHash state using fast, non-trivially predictable data,
instead of keeping it fully deterministic. The goal is essentially to make
any occasional memory leakage or brute-force attempt useless.
The resulting code was verified to be very slightly faster on x86_64 than
what is was with the controversial commit above, though this remains barely
above measurement noise. It was also tested on i386 and arm, and build-
tested only on arm64.
The whole discussion around this is archived here:
random32: add a selftest for the prandom32 code
Given that this code is new, let's add a selftest for it as well.
It doesn't rely on fixed sets, instead it picks 1024 numbers and
verifies that they're not more correlated than desired.
Cc: George Spelvin <email@example.com>
Cc: Amit Klein <firstname.lastname@example.org>
Cc: Eric Dumazet <email@example.com>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Andy Lutomirski <firstname.lastname@example.org>
Cc: Kees Cook <email@example.com>
Cc: Thomas Gleixner <firstname.lastname@example.org>
Cc: Peter Zijlstra <email@example.com>
Cc: Linus Torvalds <firstname.lastname@example.org>
Cc: Florian Westphal <email@example.com>
Cc: Marc Plumb <firstname.lastname@example.org>
Signed-off-by: Willy Tarreau <email@example.com>
1 file changed