lkml.org 
[lkml]   [2004]   [Dec]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Concurrent access to /dev/urandom
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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:08    [W:0.068 / U:4.552 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site