linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] random: use init_utsname() instead of utsname()
@ 2022-09-27  9:29 Jason A. Donenfeld
  2022-09-27 14:17 ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: Jason A. Donenfeld @ 2022-09-27  9:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jason A. Donenfeld, Kees Cook

Rather than going through the current-> indirection for utsname, at this
point in boot, init_utsname()==utsname(), so just use it directly that
way. Additionally, init_utsname() appears to be available nearly always,
so move it into random_init_early().

Suggested-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 drivers/char/random.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 0598450c72aa..eab334a425a1 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -802,6 +802,7 @@ void __init random_init_early(const char *command_line)
 		++i;
 	}
 
+	_mix_pool_bytes(init_utsname(), sizeof(*(init_utsname())));
 	_mix_pool_bytes(command_line, strlen(command_line));
 
 	if (trust_cpu)
@@ -817,7 +818,6 @@ void __init random_init(void)
 	unsigned long entropy = random_get_entropy();
 	ktime_t now = ktime_get_real();
 
-	_mix_pool_bytes(utsname(), sizeof(*(utsname())));
 	_mix_pool_bytes(&now, sizeof(now));
 	_mix_pool_bytes(&entropy, sizeof(entropy));
 	add_latent_entropy();
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] random: use init_utsname() instead of utsname()
  2022-09-27  9:29 [PATCH] random: use init_utsname() instead of utsname() Jason A. Donenfeld
@ 2022-09-27 14:17 ` Kees Cook
  0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2022-09-27 14:17 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: linux-kernel

On Tue, Sep 27, 2022 at 11:29:20AM +0200, Jason A. Donenfeld wrote:
> Rather than going through the current-> indirection for utsname, at this
> point in boot, init_utsname()==utsname(), so just use it directly that
> way. Additionally, init_utsname() appears to be available nearly always,
> so move it into random_init_early().
> 
> Suggested-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>

Reviewed-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-27 14:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-27  9:29 [PATCH] random: use init_utsname() instead of utsname() Jason A. Donenfeld
2022-09-27 14:17 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).