News for hackers. Stuff that matters.
Re:Really Fixing Getrandom() by ChrisSD on Friday October 18, 2019 @07:57AM (#21290543)
Using CPU jitter is a clever solution. I hope it stands up to scrutiny.

> but mixing entropy from the hardware with other sources is considered to be safe by most, even if the hardware generator is somehow suspect.

To be clear, it's a property of bitwise xor that it preserves entropy. If you xor a random bit with 1 you still have a random bit.

Re:Really Fixing Getrandom() by devit on Friday October 18, 2019 @08:06AM (#21290611)
Assuming they are independent random variables, since e.g. X xor (not X) is constant.
Re:Really Fixing Getrandom() by dooglius on Friday October 18, 2019 @08:22AM (#21290723)
Well, that's not entirely true, even if two random bits are independent, xor-ing them only gives you one random bit. What actually happens in Linux is that each new input of random bits gets pushed through a cryptographic hash, before being xor'd.
Re:Really Fixing Getrandom() by ChrisSD on Friday October 18, 2019 @09:08AM (#21291039)
From replies it seems my two sentences weren't as clear as I thought. I'll try to refine it:

A property of bitwise xoring random variable `x` with a constant (or otherwise non-random but independent) value is that the entropy of `x` is preserved in the result.

Re:Really Fixing Getrandom() by WAHa_06x36 on Sunday October 20, 2019 @07:24AM (#21303479)
However, xoring two arbitrary random variables is NOT guaranteed to preserve entropy. Preserving entropy only happens under certain specific conditions.
Re:Really Fixing Getrandom() by ChrisSD on Sunday October 20, 2019 @08:49PM (#21308441)
Under what circumstances would xoring `x` and `y` not produce a result with entropy at least as great as `x`?
Re:Really Fixing Getrandom() by WAHa_06x36 on Monday October 21, 2019 @07:23AM (#21310964)
In the very obvious cases where x == y, or x == not y, or x == y + 1, or many other correlations.
Re:Really Fixing Getrandom() by ChrisSD on Monday October 21, 2019 @12:04PM (#21313834)
Only if y is known to be dependent on x. If y is random but just so happens to be `not x` or `== x` then that won't make the result any less random.

0 is as random a number as 529890873740477 is.

Re:Really Fixing Getrandom() by WAHa_06x36 on Tuesday October 22, 2019 @11:35AM (#21324840)
Single numbers don't really have entropy at all, so that is not something it even makes sense to talk about.
Re:Really Fixing Getrandom() by tptacek on Friday October 18, 2019 @10:47AM (#21291817)
CPU jitter randomness is an old idea, and not especially well thought of.
Re:Really Fixing Getrandom() by Diederich on Friday October 18, 2019 @10:58AM (#21291916)
If you have a moment, can you expand on that or provide a link? Especially for the last part. Thanks.

This is well outside of my wheelhouse, so please pardon a naive inquiry.

Re:Really Fixing Getrandom() by toast0 on Friday October 18, 2019 @08:51PM (#21296150)
These timing measurements by nature are going to have a small range of possible values --- the size of the range is going to likely be system specific, and for some systems, there may be only a few possible outcomes.
Re:Really Fixing Getrandom() by clarry on Saturday October 19, 2019 @07:03AM (#21297879)
And that's enough. One bit is enough, less than one bit of randomness is enough if you can just repeat the process enough times.
Re:Really Fixing Getrandom() by toast0 on Saturday October 19, 2019 @12:24PM (#21299242)
How are we to know how much entropy the process provides our system? The patch in the article counts one bit per timer interrupt, but there may be much less than that. If the tsc clock and the timer clock are linked, and the system is totally blocked on entropy, it seems plausible that the tsc reads will be predictable/repeatable beyond maybe the first value.
Re:Really Fixing Getrandom() by clarry on Saturday October 19, 2019 @04:12PM (#21300517)
If you've ever tried to measure cycle-accurate timings for algorithms, you might've noticed that even relatively simple and short instruction streams have variance.

Whether tsc clock and timer clock are linked or not is completely irrelevant, since the timer clock is only used to 1) credit entropy 2) possibly introduce additional jitter. The value of TSC when the timer interrupt runs is not used as entropy at all so even if that were 100% predictable, it doesn't matter.

It only matters that you do have jitter (between calls to schedule() and random_get_entropy()), and I have a hard time imagining a modern system with a high-res TSC where calling schedule() with active timers in a loop (with branches) would not have any jitter at all. You probably have way more entropy than one bit per jiffy; I think the counter is very conservative.

Notice that while entropy is credited only once per tick, actual TSC values are mixed into the entropy pool on every iteration of the loop that calls schedule().

Re:Really Fixing Getrandom() by uasm on Friday October 18, 2019 @08:54AM (#21290945)
> "Using CPU jitter is a clever solution. I hope it stands up to scrutiny."

How safe is it to use CPU jitter in a virtual machine?

Re:Really Fixing Getrandom() by jfindley on Friday October 18, 2019 @09:08AM (#21291038)
Safe as in safe from host interference? Not at all. But if your VM is running on a malicious host, you have bigger problems honestly.
Re:Really Fixing Getrandom() by stefan_ on Friday October 18, 2019 @10:44AM (#21291790)
This is kind of the ongoing joke here, yeah?

Like HN users will gladly spend hours discussing the merits of various random number generation schemes, why that Intel HWRNG is probably backdoored and we should all be very afraid, all the while running their micro-services on the cloud where their entropy is literally spoon-fed from the hypervisor. SMC call into code-you-can't-see and back comes pure entropy (trust us)!

Re:Really Fixing Getrandom() by pjc50 on Friday October 18, 2019 @10:54AM (#21291887)
Yes, although there's two kinds of VM safety people might care about. By using a VM you accept that the bare metal owner can look into it if they want to and you have to trust them not to. However, that doesn't mean accepting attacks from other customers - which was what all the Spectre/Meltdown risk was primarily about.