]> git.baikalelectronics.ru Git - kernel.git/commit
random: remove get_random_bytes_arch() and add rng_has_arch_random()
authorJason A. Donenfeld <Jason@zx2c4.com>
Sat, 14 May 2022 11:09:17 +0000 (13:09 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Thu, 19 May 2022 14:54:15 +0000 (16:54 +0200)
commitf3ea07e7a0eb2188a57d1bd3cc46f0f226f9af28
tree0bc8a927e8481e0b62600496e2a6376938e3e12d
parent2248570c88b75a728e0d49159428959f4faa493b
random: remove get_random_bytes_arch() and add rng_has_arch_random()

The RNG incorporates RDRAND into its state at boot and every time it
reseeds, so there's no reason for callers to use it directly. The
hashing that the RNG does on it is preferable to using the bytes raw.

The only current use case of get_random_bytes_arch() is vsprintf's
siphash key for pointer hashing, which uses it to initialize the pointer
secret earlier than usual if RDRAND is available. In order to replace
this narrow use case, just expose whether RDRAND is mixed into the RNG,
with a new function called rng_has_arch_random(). With that taken care
of, there are no users of get_random_bytes_arch() left, so it can be
removed.

Later, if trust_cpu gets turned on by default (as most distros are
doing), this one use of rng_has_arch_random() can probably go away as
well.

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Acked-by: Petr Mladek <pmladek@suse.com> # for vsprintf.c
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
drivers/char/random.c
include/linux/random.h
lib/vsprintf.c