* /dev/random entropy calcs - patch [not related to net devices]
@ 2001-08-21 22:40 Alex Bligh - linux-kernel
2001-08-21 22:54 ` David Schwartz
0 siblings, 1 reply; 3+ messages in thread
From: Alex Bligh - linux-kernel @ 2001-08-21 22:40 UTC (permalink / raw)
To: linux-kernel; +Cc: Alex Bligh - linux-kernel, Theodore Tso
1. Anyone have a problem with using xtime rather
than jiffies on architectures which don't support cycle
counters? (completely untested patch attached to illustrate)
2. Anyone have any problem changing fs/proc/proc_misc.c to
register /proc/interrupts to be 0600 instead of 0644 to help
prevent entropy attacks that way?
--
Alex Bligh
--- drivers/char/random.c.keep Sat Feb 17 00:02:36 2001
+++ drivers/char/random.c Tue Aug 21 23:19:17 2001
@@ -710,16 +710,27 @@
int entropy = 0;
#if defined (__i386__)
+ /* If possible, use the clock cycle counter */
if ( test_bit(X86_FEATURE_TSC, &boot_cpu_data.x86_capability) ) {
__u32 high;
__asm__(".byte 0x0f,0x31"
:"=a" (time), "=d" (high));
num ^= high;
} else {
- time = jiffies;
+ time = (__u32)(xtime.tv_usec) ^ (__u32)(xtime.tv_sec);
}
#else
- time = jiffies;
+ /* If we can't get the clock cycle counter, get the number
+ * of elapsed microseconds. Note:
+ * - we don't need the xtime spinlock as we are only reading
+ * one half (even then, the odd SMP race is only going to
+ * add to entropy)
+ * - this may indeed wrap; but so could the original cycle
+ * counter, and as us occur less frequently than clock cycles,
+ * it's less of a problem. In any case it would underestimate
+ * entropy on a wrap.
+ */
+ time = (__u32)(xtime.tv_usec) ^ (__u32)(xtime.tv_sec);
#endif
/*
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: /dev/random entropy calcs - patch [not related to net devices]
2001-08-21 22:40 /dev/random entropy calcs - patch [not related to net devices] Alex Bligh - linux-kernel
@ 2001-08-21 22:54 ` David Schwartz
0 siblings, 0 replies; 3+ messages in thread
From: David Schwartz @ 2001-08-21 22:54 UTC (permalink / raw)
To: Alex Bligh - linux-kernel, linux-kernel
> + time = (__u32)(xtime.tv_usec) ^ (__u32)(xtime.tv_sec);
I would prefer:
time = (__u32)xtime.tv_usec | ( (__u32)(xtime.tv_sec)<<20) );
The way you have it, you collide the two least-significant bits,
potentially losing some entropy.
DS
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: /dev/random entropy calcs - patch [not related to net devices]
[not found] <9547398.998437243@_169.254.198.40_>
@ 2001-08-23 1:53 ` Ton Hospel
0 siblings, 0 replies; 3+ messages in thread
From: Ton Hospel @ 2001-08-23 1:53 UTC (permalink / raw)
To: linux-kernel
In article <9547398.998437243@_169.254.198.40_>,
Alex Bligh - linux-kernel <linux-kernel@alex.org.uk> writes:
> 2. Anyone have any problem changing fs/proc/proc_misc.c to
> register /proc/interrupts to be 0600 instead of 0644 to help
> prevent entropy attacks that way?
Yes, i don't want to have to switch to root to read /proc/interrupts
because some people have gone utterly paranoid about an attack that's not
feasable if you reseed your randum numbers normally at boot.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-08-23 1:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-21 22:40 /dev/random entropy calcs - patch [not related to net devices] Alex Bligh - linux-kernel
2001-08-21 22:54 ` David Schwartz
[not found] <9547398.998437243@_169.254.198.40_>
2001-08-23 1:53 ` Ton Hospel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome