diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2022-09-27 12:35:16 +0300 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2022-09-29 22:37:27 +0300 |
commit | 37608ba315a2b1b548aa5b1064e5559e029cb016 (patch) | |
tree | 8b4b2cd0188f9753c1b35eb0bd1c185bb913237a /kernel/utsname_sysctl.c | |
parent | dd54fd7dfa4574fe350b75a90693dc6552c535e3 (diff) | |
download | linux-37608ba315a2b1b548aa5b1064e5559e029cb016.tar.xz |
utsname: contribute changes to RNG
On some small machines with little entropy, a quasi-unique hostname is
sometimes a relevant factor. I've seen, for example, 8 character
alpha-numeric serial numbers. In addition, the time at which the hostname
is set is usually a decent measurement of how long early boot took. So,
call add_device_randomness() on new hostnames, which feeds its arguments
to the RNG in addition to a fresh cycle counter.
Low cost hooks like this never hurt and can only ever help, and since
this costs basically nothing for an operation that is never a fast path,
this is an overall easy win.
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'kernel/utsname_sysctl.c')
-rw-r--r-- | kernel/utsname_sysctl.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c index 4ca61d49885b..de16bcf14b03 100644 --- a/kernel/utsname_sysctl.c +++ b/kernel/utsname_sysctl.c @@ -8,6 +8,7 @@ #include <linux/export.h> #include <linux/uts.h> #include <linux/utsname.h> +#include <linux/random.h> #include <linux/sysctl.h> #include <linux/wait.h> #include <linux/rwsem.h> @@ -57,6 +58,7 @@ static int proc_do_uts_string(struct ctl_table *table, int write, * theoretically be incorrect if there are two parallel writes * at non-zero offsets to the same sysctl. */ + add_device_randomness(tmp_data, sizeof(tmp_data)); down_write(&uts_sem); memcpy(get_uts(table), tmp_data, sizeof(tmp_data)); up_write(&uts_sem); |