Re: Concurrent access to /dev/urandom

Matt Mackall
2004-12-09T04:55:41Z

On Thu, Dec 09, 2004 at 10:46:30AM +0800, andyliu wrote:
> hi Ted
>
> i think this is better than use the spin lock.
> but i think maybe there should put an #ifdef SMP :)
> just like
>
> #ifdef CONFIG_SMP
> tmp[0] = 0x67452301 ^ smp_processor_id();
> tmp[1] = 0xefcdab89 ^ (__u32) current;
> tmp[2] = 0x98badcfe ^ preempt_count();
> #endif
>
> is it needed?

The race can be hit with get_random_bytes on UP if we get
interrupted/preempted between hashing and mixing. Which is why
preempt_count is useful..

--
Mathematics is the supreme nostalgia of our time.