Re: Concurrent access to /dev/urandom

From: Matt Mackall
Date: Wed Dec 08 2004 - 23:57:07 EST


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.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/