5 ms·
Has anybody made a set of patches to give linux the BSD behavior (block until seeded, then never block again)? I run into issues with /dev/random regularly and
by aidenn0 11y ago
Has anybody made a set of patches to give linux the BSD behavior (block until seeded, then never block again)? I run into issues with /dev/random regularly and while I can patch every single application, that feels like playing whack-a-mole compared to patching the kernel.
- nshepperd 11y agoIf you're using udev, you can configure it to make /dev/random a symlink to /dev/urandom (eg. [1]). Sadly that doesn't give you the "block until seeded" behaviour though, and I don't know of any kernel patch doing that yet. 1. http://superuser.com/questions/309840/how-can-i-point-dev-random-to-dev-urandom http://superuser.com/questions/309840/how-can-i-point-dev-ra...
- deleted 11y ago[deleted]
- Natanael_L 11y agoYou could make a script that prevents /dev/urandom from being made available until /r/random stops blocking, to then also simultaneously create that symlink. Edit: on boot, first prevent access to /dev/urandom, then symlink it to /dev/random. Then as soon as /dev/random stops blocking, reverse the direction of the symlink. Same improved security, much simpler to use.
- Tomte 11y agoNot to /dev/urandom, AFAIK. But at least they have the new getrandom syscall.
- dadrian 11y agoThe getrandom() system call does this. See http://man7.org/linux/man-pages/man2/getrandom.2.html http://man7.org/linux/man-pages/man2/getrandom.2.html
- rwmj 11y agoBut glibc hasn't wired it up. https://sourceware.org/bugzilla/show_bug.cgi?id=17252 https://sourceware.org/bugzilla/show_bug.cgi?id=17252
- ryuuchin 11y agoThe solution (currently sans kernel patching) is to just seed /dev/urandom yourself at system startup to avoid the issue of it not being seeded. Don't most distro's do this anyway? After that it's just down to using /dev/urandom[1] or the getrandom syscall (which is the same as using /dev/urandom). Also the getrandom syscall actually has the behavior you're talking about. [1] http://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers/ http://sockpuppet.org/blog/2014/02/25/safely-generate-random...
- aidenn0 11y agoThe point is that I run one kernel but dozens of applications; I feel like I'm playing application whack-a-mole trying to patch the applications, when I could just patch the kernel.
- marvy 11y agoIt seems that you're just complaining that some applications read from /dev/random, but you wish they would read from /dev/urandom. If I understand you correctly, then it seems there exists a simple solution. (Disclaimer: I don't use Linux, or any other Unix. I may not know what I'm talking about.) mv /dev/random /dev/badrandom ln -s /dev/random /dev/urandom # is this the right syntax? Or something like that?
- ryuuchin 11y agoI'm not sure it's that simple. Someone mentioned a solution somewhere in this thread relating to if you're using udev. It still won't give you the block until seeded behavior but my post gave the solution to that (seed it yourself at system start (which most distro's may already do)). It should be possible to give /dev/random the same behavior as /dev/urandom I just haven't really looked into it.
- raverbashing 11y agoThinking out loud here: 1 - try to read from /dev/random. 2 - While 1 has not succeeded, wait and try again 3 - Once it has succeeded, read from /dev/urandom on next reads
- loup-vaillant 11y agoI've heard that reading from /dev/random tends to "steal" entropy from /dev/urandom or something. I'm not sure. But if you only use urandom, you're safe. Here, from a quick search: http://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers/ http://sockpuppet.org/blog/2014/02/25/safely-generate-random... http://www.2uo.de/myths-about-urandom/ http://www.2uo.de/myths-about-urandom/
- raverbashing 11y agoThen you came to a different conclusion than me, because the text say a lot of times to use urandom There's no stealing with entropy. And once random returns a read the RNG is seeded, period.
- loup-vaillant 11y agoMy memories are foggy, unreliable, and out of date. I did say I was not sure…
- indolering 11y agoThis would also quiet a lot of the noise around the entropy estimation blocking in `/dev/random`. I mean, if basically everyone [1] agrees that you should just use `/dev/urandom/` because blocking on entropy estimation is misguided, then why not copy the behavior of every other Unix? [1]: http://www.2uo.de/myths-about-urandom/ http://www.2uo.de/myths-about-urandom/