News for hackers. Stuff that matters.
Re:Linux RNG RFC Patch: implement getrandom() in vDSO by zx2c4 on Friday July 29, 2022 @01:19PM (#32279563)
It's kind of wild, yea. I'd rather not do it. But if it's between unsafe userspace implementations and this thing, this thing is better. Maybe people will decide they don't care about hyperspeed card shuffling or whatever else. But if they do, this is an attempt to provide it safely.
Re:Linux RNG RFC Patch: implement getrandom() in vDSO by nneonneo on Friday July 29, 2022 @01:28PM (#32279668)
I guess my biggest concern here is the notion that vDSO is going to manage the state in user space, if I understand correctly. That seems like a big footgun.

If I call the getrandom system call, and it succeeds, I am (pretty much) guaranteed that the results are properly random no matter what state my userspace program might be in.

With vDSO, it seems we lose this critical guarantee. If a memory corruption occurs, or my process’s memory contents can be disclosed somehow (easier to do against a userspace process than against the kernel!), I don’t have truly random numbers anymore. Using a superficially similar API to the system call for this seems like a really bad idea.

Re:Linux RNG RFC Patch: implement getrandom() in vDSO by zx2c4 on Friday July 29, 2022 @01:35PM (#32279746)
> If a memory corruption occurs, or my process’s memory contents can be disclosed somehow (easier to do against a userspace process than against the kernel!), I don’t have truly random numbers anymore.

Yea, that's definitely a downside of sorts. Jeffrey Walton mentioned that in the glibc discussion a few days ago: https://lore.kernel.org/linux-crypto/CAH8yC8n2FM9uXimT71Ej0m...

A mitigating factor might be that if your process memory leaks, then the secrets generated leak anyway, no matter what generated them, so maybe not as large of a difference. But of course a generator leaking means future secrets potentially leak too. I suppose frequent reseeds could mitigate this, just as they do for potential leaks in the kernel.

But anyway, I agree that compromising application memory is somewhat more possible than compromising kernel memory, though both obviously happen.

Re:Linux RNG RFC Patch: implement getrandom() in vDSO by saagarjha on Friday July 29, 2022 @01:32PM (#32279715)
If you have memory corruption in your process, what makes you confident your program state will let you do something useful with the randomness you get back from getrandom()?
Re:Linux RNG RFC Patch: implement getrandom() in vDSO by nneonneo on Friday July 29, 2022 @01:43PM (#32279834)
I guess my concern is with “silent” memory corruption, e.g. someone putting in a “bzero(state, …)” by accident and winding up with deterministic randomness. Sure, they could also just as well do a “bzero(randombuf, …)” before using it but that’s much easier to detect (and in my head, somewhat harder to do by accident).

Silly mistakes like the Debian randomness bug come to mind - a program can be totally well-behaved even in the face of a glaring entropy failure, in a way that’s hard for developers to detect.

Re:Linux RNG RFC Patch: implement getrandom() in vDSO by saagarjha on Friday July 29, 2022 @02:29PM (#32280284)
I guess? I mean, I see "something overflowed on the stack and into my randomness buffer" as being similarly common and about as undetectable. That's not to say we shouldn't invest in making APIs that are harder to misuse even if you hold them incorrectly, but I'm not sure the benefits are very compelling here.
Re:Linux RNG RFC Patch: implement getrandom() in vDSO by sophacles on Friday July 29, 2022 @04:26PM (#32281397)
The vDSO page is mapped without write though, just r and x.
Re:Linux RNG RFC Patch: implement getrandom() in vDSO by deathanatos on Friday July 29, 2022 @02:10PM (#32280102)
> hyperspeed card shuffling

The article mentions this case too. getrandom() on my system seems to return the required amount of random bits to perform a shuffle of a deck in less time than my clock seems to have precision for; … that's … too slow?

Re:Linux RNG RFC Patch: implement getrandom() in vDSO by AlotOfReading on Friday July 29, 2022 @02:55PM (#32280518)
There are cases where you want tons of random numbers (e.g. monte carlo) and the line between "good enough" and "disastrously bad" is often unclear. Providing cryptographic random numbers is the only possible API that's both safe and generic.

As the post says, it's worth entertaining the idea of having the kernel provide a blessed way for userspace to do that, though I admit I've never personally seen a scenario where RNG was truly the bottleneck. But it'd still be nice to kill all the custom RNGs out there.

Re:Linux RNG RFC Patch: implement getrandom() in vDSO by kzrdude on Friday July 29, 2022 @05:55PM (#32282225)
Don't you always want a reproducible random sequence for such simulations? I.e you use getrandom for the initial seed only, record it, and do the rest of your RNG state in userspace code?
Re:Linux RNG RFC Patch: implement getrandom() in vDSO by AlotOfReading on Saturday July 30, 2022 @05:45AM (#32285505)
It's a nice property, but a lot of people skip it because of the tradeoffs. I'm also sure there are lots of use cases I'm not aware of where you don't want reproducibility.