Skip to contentSkip to conversation

random: use init_utsname() instead of utsname()

PATCH In review Jason A. Donenfeld 2 participants 2 messages Sep 27, 2022 Random number driver

lore
Share & tools
lore

Jason A. Donenfeld

author maintainer
#0 lore raw

PATCH 1/1 random: use init_utsname() instead of utsname()

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().

---
 drivers/char/random.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/random.c +1 -1
index 0598450c72aa..eab334a425a1 100644
@@ -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();
Signature · 1 line
2.37.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Jason A. Donenfeld

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().

Signature · 1 line
Kees Cook