From: "Bernard Normier" <bernard@zeroc.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: Concurrent access to /dev/urandom
Date: Tue, 7 Dec 2004 20:56:17 -0500 [thread overview]
Message-ID: <079001c4dcc9$1bec3a60$6401a8c0@centrino> (raw)
In-Reply-To: <20041208012802.GA6293@thunk.org>
In which version of 2.6 did this bug get fixed? I am seeing these duplicates
with 2.6.9-1.667smp (FC3)?
I am just trying to generate UUIDs (without duplicates, obviously).
Thanks,
Bernard
> On Tue, Dec 07, 2004 at 06:41:12PM -0500, Bernard Normier wrote:
>> Reading concurrently /proc/sys/kernel/random/uuid also returns duplicates
>> quite quickly ... which definitely looks like a bug. I included a small
>> python test-case below.
>> Can anybody suggest a work-around, for example a simple way to serialize
>> access to /dev/urandom from multiple threads/processes on the same box?
>
> This has been fixed in 2.6, but not yet in 2.4. Really, this should
> be fixed in the kernel, but if you need to worry about this from the
> perspective of user-level programs that might be running on unfixed
> distribution kernels, the best way to deal with the problem is to use
> /dev/urandom to seed a cryptographic random number generator, and then
> mix in your pid and time/date into the CRNG.
>
> For example (in Pseudo code):
>
> char key[16];
> int counter;
>
> seed_random_number_generator()
> {
> key <- SHA(20 bytes from /dev/random || pid || time(0));
> counter = 0;
> }
>
> get_random_bytes()
> {
> return SHA(counter++ || key);
> }
>
> This by the way is a generally a good thing to do in all cases;
> /dev/urandom is designed to be used to seed a cryptographic random
> generator. If you need a large number of cryptographic random
> numbers, it's much faster to do it in user space than to try to do it
> in the kernel.
>
> - Ted
> -
> 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/
next prev parent reply other threads:[~2004-12-08 1:56 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-27 20:45 Bernard Normier
2004-11-27 20:56 ` Jan Engelhardt
2004-11-27 21:15 ` Bernard Normier
2004-11-27 21:22 ` Jan Engelhardt
2004-11-28 20:58 ` Bernard Normier
2004-12-07 23:41 ` Bernard Normier
2004-12-08 1:28 ` Theodore Ts'o
2004-12-08 1:56 ` Bernard Normier [this message]
2004-12-08 19:21 ` Theodore Ts'o
2004-12-08 20:15 ` Bernard Normier
2004-12-08 21:56 ` Matt Mackall
2004-12-09 1:57 ` Theodore Ts'o
2004-12-09 2:46 ` andyliu
2004-12-09 4:55 ` Matt Mackall
2004-12-09 2:58 ` Matt Mackall
2004-12-09 21:29 ` Matt Mackall
2004-12-10 4:47 ` Matt Mackall
2004-12-10 16:35 ` Theodore Ts'o
2004-12-10 18:28 ` Matt Mackall
2004-12-10 21:28 ` Theodore Ts'o
2004-12-10 22:23 ` Matt Mackall
2004-12-11 0:22 ` Adam Heath
2004-12-11 1:10 ` Matt Mackall
2004-12-11 17:33 ` Theodore Ts'o
2004-12-11 19:58 ` Adam Heath
2004-12-11 20:40 ` Matt Mackall
2004-12-12 16:19 ` Pavel Machek
2004-12-11 0:19 ` Adam Heath
2004-12-09 3:10 ` David Lang
2004-12-09 4:52 ` Matt Mackall
2004-12-09 6:36 ` Theodore Ts'o
2004-11-29 22:47 ` Jon Masters
2004-11-29 23:14 ` Bernard Normier
2004-11-29 23:43 ` Sven-Haegar Koch
2004-11-30 2:31 ` David Schwartz
2004-11-30 4:14 ` Kyle Moffett
2004-11-30 8:23 ` Jan Engelhardt
2004-11-30 18:50 ` David Schwartz
2004-11-29 23:42 ` David Wagner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='079001c4dcc9$1bec3a60$6401a8c0@centrino' \
--to=bernard@zeroc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®