On Sun, Aug 9, 2020 at 2:10 PM Marc Plumb <lkml.mpl...@gmail.com> wrote: > > However, I think I'm starting to see your underlying assumptions. > You're thinking that raw noise data are the only truly unpredictable > thing so you think that adding it is a defense against attacks like > foreshadow/spectre/meltdown. You aren't entirely wrong -- if there was > a fast noise source then it might be a good option. Just if the noise > source is slow, you're just causing far more damage to a far more > critical crypto function to get very little benefit.
The only truly good noise source we have is any CPU native randomness. Sadly, that is usually never really "fast". But we do use that for any actual real /dev/random reading. We still whiten it through our hashing, and we mix it in rather than use the raw CPU hw-provided values (because not everybody trusts the CPU vendors either), but /dev/random will most certainly take advantage of it as one source of noise. (Honesty in advertising: you can also use other interfaces that don't bother with the remixing, and _will_ just return the raw CPU randomness). So if you make the (imho reasonable) assumption that you're running on a modern enough CPU, and that the CPU hw randomness is of reasonable quality, then you never need to worry about /dev/random. Every single time you extract something from one of the pools, I think we mix in that CPU randomness if it's available. But the CPU randomness is too slow for the prandom code to use at extraction time. It's on the order of a couple of hundred to a couple of thousand cycles. That's peanuts for /dev/random, but quite a lot for prandom. In fact, at the slow end it is slow enough that you don't want to do it at any fast granularity (ie not "every interrupt"), it's the "when reseeding once a second" kind of slow. arm64 has randomness too these days too, but that's only of the "really slow, useful for seeding" variety. And I'm not sure which (if any) CPU implementations out there actually do it yet. Anyway, I suspect /dev/random has been over-engineered (I think we have something like three layers of mixing bits _and_ the CPU randomness _and_ all the interrupt randomness), and prandom may have been left alone too much. Linus