Skip to content

random32: make prandom_u32() less predictable

Willy Tarreau lkml 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest3 patches 0 repliesNew
  2. v12 patches 15 repliesSuperseded

Changes in v4 from the cover letter

- access noise using raw_cpu_read() instead of this_cpu_read()
- fixed build with CONFIG_RANDOM32_SELFTEST
- added a selftest for the prandom32 code

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3random32: make prandom_u32() output unpredictabledrivers/char/random.c include/linux/prandom.h kernel/time/timer.c +1 more+318 -1900 replies
2/3random32: add noise from network and scheduling activityinclude/linux/prandom.h kernel/time/timer.c lib/random32.c +1 more+30 -00 replies
3/3random32: add a selftest for the prandom32 codelib/random32.c+56 -00 replies

Reviews trailers per patch

None of the 3 patches has a Reviewed-by or Acked-by.

PatchSedat Dilek
1/3
2/3T-b
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/3] 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:
https://lore.kernel.org/netdev/[email protected]/

The code is also available for you to pull at:

git://git.kernel.org/pub/scm/linux/kernel/git/wtarreau/prandom.git tags/20201024-v4-5.10

---
v4:
- access noise using raw_cpu_read() instead of this_cpu_read()
- fixed build with CONFIG_RANDOM32_SELFTEST
- added a selftest for the prandom32 code

v3:
This v3 is a rebase on top of 5.9-final, and switches __this_cpu_read() for this_cpu_read() to address a crash on i386+SMP+PREEMPT reported by LKP. Nothing else was changed.

George Spelvin (1):
random32: make prandom_u32() output unpredictable

Willy Tarreau (2):
random32: add noise from network and scheduling activity
random32: add a selftest for the prandom32 code

 drivers/char/random.c   |   1 -
 include/linux/prandom.h |  55 ++++-
 kernel/time/timer.c     |   9 +-
 lib/random32.c          | 525 ++++++++++++++++++++++++++--------------
 net/core/dev.c          |   4 +
 5 files changed, 404 insertions(+), 190 deletions(-)
Signature · 1 line
2.28.0