News for hackers. Stuff that matters.
Re:/dev/random – a new approach by aidenn0 on Sunday April 24, 2016 @07:49PM (#11561869)
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.
Re:/dev/random – a new approach by ryuuchin on Sunday April 24, 2016 @10:51PM (#11562331)
The 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...

Re:/dev/random – a new approach by aidenn0 on Monday April 25, 2016 @01:54PM (#11565970)
The 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.
Re:/dev/random – a new approach by marvy on Monday April 25, 2016 @07:29PM (#11568224)
It 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?
Re:/dev/random – a new approach by ryuuchin on Monday April 25, 2016 @10:09PM (#11568943)
I'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.
Re:/dev/random – a new approach by dadrian on Sunday April 24, 2016 @10:40PM (#11562316)
The getrandom() system call does this. See http://man7.org/linux/man-pages/man2/getrandom.2.html
Re:/dev/random – a new approach by rwmj on Monday April 25, 2016 @05:15AM (#11563198)
Re:/dev/random – a new approach by nshepperd on Sunday April 24, 2016 @08:43PM (#11561985)
If 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-ra...

Re:/dev/random – a new approach by Natanael_L on Monday April 25, 2016 @05:54AM (#11563308)
You 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.

Re:/dev/random – a new approach by indolering on Monday April 25, 2016 @03:13PM (#11566544)
This 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/

Re:/dev/random – a new approach by raverbashing on Monday April 25, 2016 @05:00AM (#11563149)
Thinking 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

Re:/dev/random – a new approach by loup-vaillant on Monday April 25, 2016 @05:45AM (#11563278)
I'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... http://www.2uo.de/myths-about-urandom/
Re:/dev/random – a new approach by raverbashing on Monday April 25, 2016 @05:58AM (#11563315)
Then 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.

Re:/dev/random – a new approach by loup-vaillant on Monday April 25, 2016 @06:42AM (#11563430)
My memories are foggy, unreliable, and out of date. I did say I was not sure…
Re:/dev/random – a new approach by Tomte on Sunday April 24, 2016 @08:51PM (#11562006)
Not to /dev/urandom, AFAIK. But at least they have the new getrandom syscall.