News for hackers. Stuff that matters.
Re:Password generator doesn't generate new password in the s... by amelius on Tuesday December 20, 2022 @08:27AM (#34065539)
Question: how does /dev/urandom ensure that two different users, both reading from the stream, don't get the same output?

(ignoring that they could get the same output by chance)

Re:Password generator doesn't generate new password in the s... by codefined on Tuesday December 20, 2022 @08:33AM (#34065606)
`/dev/urandom` isn't a real file / stream. It's part of the 'everything is a a file' *nix mantra. Even if two users are reading from /dev/urandom simultaneously, they'll each get unique values. The CSPRNG keeps track of a sequence number and so you'll end up with something like [process 0 requests sequence 0, process 1 requests sequence 1, process 1 requests sequence 2, proceess 0 requests sequence 3...].
Re:Password generator doesn't generate new password in the s... by amelius on Tuesday December 20, 2022 @06:49PM (#34074627)
Um, yeah, you sort of rephrased my question into a statement.
Re:Password generator doesn't generate new password in the s... by colanderman on Tuesday December 20, 2022 @08:32AM (#34065596)
There is (or at least was, in 2014) a spinlock to serialize access: https://damonsnyder.com/2014/04/16/linux-dev-urandom-and-con...
Re:Password generator doesn't generate new password in the s... by onei on Tuesday December 20, 2022 @08:38AM (#34065684)
Is that strictly true? I know urandom doesn't block if it lacked entropy, but if it had entropy I was under the impression urandom's output was derived from that instead.
Re:Password generator doesn't generate new password in the s... by colanderman on Tuesday December 20, 2022 @08:43AM (#34065742)
Edited my post to include a link with code references and discussion by kernel devs. The RNG state is protected by a spinlock.
Re:Password generator doesn't generate new password in the s... by ilyt on Tuesday December 20, 2022 @09:09AM (#34066081)
Well, a lot changed since the article. For one the test tool now eats more CPU than RNG.

From my dumb tests (run DD in one, then many threads), the 4 thread run have 4x the performance of single thread one (I have 4 core CPU), while 16 thread one have predictably same-ish total throughput, so if there are any serialization still there it is not noticeable much.