public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* RE: [PATCH] get_random_bytes returns the same on every boot
@ 2004-07-26 13:57 Eble, Dan
  2004-07-26 19:31 ` Balint Marton
  2004-07-27 18:01 ` Balint Marton
  0 siblings, 2 replies; 10+ messages in thread
From: Eble, Dan @ 2004-07-26 13:57 UTC (permalink / raw)
  To: Balint Marton; +Cc: linux-kernel, netdev

Balint Marton wrote:
> At boot time, get_random_bytes always returns the same 
> random data, as if there were a constant random seed.
> packet with always the same transaction ID. (If you have 
> more than one computers, and they are booting at the
> same time, then this is a big problem)

If many systems are booting at the same time, is seeding with the system
time really an appropriate solution?  Shouldn't some system-specific
value also contribute to the randomization?

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [PATCH] get_random_bytes returns the same on every boot
@ 2004-07-22 22:52 Balint Marton
  2004-07-22 23:28 ` Patrick McHardy
  2004-08-02 22:42 ` David Wagner
  0 siblings, 2 replies; 10+ messages in thread
From: Balint Marton @ 2004-07-22 22:52 UTC (permalink / raw)
  To: linux-kernel

Hi, 

At boot time, get_random_bytes always returns the same random data, as if
there were a constant random seed. For example, if I use the kernel level
ip autoconfiguration with dhcp, the kernel will create a dhcp request
packet with always the same transaction ID. (If you have more than one
computers, and they are booting at the same time, then this is a big
problem)

That happens, because only the primary entropy pool is initialized with
the system time, in function rand_initialize. The secondary pool is only
cleared. In this early stage of booting, there is usually no user
interaction, or usable disk interrupts, so the kernel can't add any real
random bytes to the primary pool. And altough the system time is in the
primary pool, the kernel does not consider it real random data, so you
can't read from the primary pool, before at least a part of it will be
filled with some real randomness (interrupt timing).
Therefore all random data will come from the secondary pool, and the
kernel cannot reseed the secondary pool, because there is no real 
randomness in the primary one.

The solution is simple: Initialize not just the primary, but also the 
secondary pool with the system time. My patch worked for me with 
2.6.8-rc2, but it was not tested too long. 

--- linux-2.6.8-rc2.orig/drivers/char/random.c	2004-06-16 07:18:57.000000000 +0200
+++ linux-2.6.8-rc2/drivers/char/random.c	2004-07-22 21:06:28.000000000 +0200
@@ -1537,6 +1537,7 @@
 	clear_entropy_store(random_state);
 	clear_entropy_store(sec_random_state);
 	init_std_data(random_state);
+	init_std_data(sec_random_state);
 #ifdef CONFIG_SYSCTL
 	sysctl_init_random(random_state);
 #endif

bye, 
	Cus

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

end of thread, other threads:[~2004-08-03 20:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <2kUHO-6hJ-15@gated-at.bofh.it>
2004-07-27 17:43 ` [PATCH] get_random_bytes returns the same on every boot Andi Kleen
2004-07-27 19:25   ` Balint Marton
2004-07-26 13:57 Eble, Dan
2004-07-26 19:31 ` Balint Marton
2004-07-27 18:01 ` Balint Marton
  -- strict thread matches above, loose matches on Subject: below --
2004-07-22 22:52 Balint Marton
2004-07-22 23:28 ` Patrick McHardy
2004-08-02 22:42 ` David Wagner
2004-08-03 17:47   ` Jack Lloyd
2004-08-03 20:53     ` Jesper Juhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox