News for hackers. Stuff that matters.
Re:The getrandom(2) system call was requested by the LibreSS... by nhaehnle on Thursday July 17, 2014 @07:28PM (#8050836)
Ugh. Whatever happened to not wasting an excessive amount of space? Allocating 4KB for what is essentially a single bit flag seems like a needless waste of space, especially given that we already have syscalls that set up triggers to manipulate individual words in userspace (most prominently, the futex syscall, but there are others).

I suppose that if the state of your PRNG neatly fits into (almost) a multiple of 4KB, it makes sense to allocate that space explicitly and put a guard bit in there, then mark the entire region as INHERIT_ZERO. This has the added benefit of making it less like that PRNG state is leaked somewhere.

Re:The getrandom(2) system call was requested by the LibreSS... by nitrogen on Friday July 18, 2014 @01:41AM (#8051840)
The page size is a minimum of 4KB, so you can't really allocate anything smaller from the OS.
Re:The getrandom(2) system call was requested by the LibreSS... by Someone on Saturday July 19, 2014 @06:49AM (#8057164)
That's the OP's point. His/her question is: why allocate an entire page if, instead, you could have a single bit 'process did not initialize its source of randomness yet' in kernel space per process?

The only advantage I see is that the current solution allows one to implement the random number generator independently of the kernel. Introducing that bit creates a tight coupling.

Re:The getrandom(2) system call was requested by the LibreSS... by nhaehnle on Saturday July 19, 2014 @10:44AM (#8057586)
Actually, there's an even better solution: simply give the kernel a userspace address range which will be zeroed on fork. There's simply no reason at all why this address range should be restricted to exactly 4KB or a multiple thereof (one could imagine the kernel doing some page-table tricks to avoid a full memset() for large areas, but that's an optimization that can be added transparently to an API that supports arbitrary address ranges).

The futex API (including set_tid_address) is precedence for this kind of syscall.