Re: [PATCH] random: fix add_hwgenerator_randomness entropy accounting

From: Jan Varho
Date: Mon Apr 04 2022 - 11:30:01 EST


On Mon, Apr 4, 2022 at 6:20 PM Jason A. Donenfeld <Jason@xxxxxxxxx> wrote:
> > Fix by not crediting entropy if any input was consumed for fast init.
> Yea, I'd seen this and wasn't really sure what the correct fix was. My
> recent addition of `&& entropy < POOL_MIN_BITS` is a step in the right
> direction of making your fix the desirable path, since it makes it less
> likely that we'd wind up throwing away "good" entropy. So maybe it's
> time we do that.

Yes, but since it's a hwrng, hopefully it will supply more soon.

And like you say, the new condition makes it less likely to happen.

> This is untested, but if you want to test it and submit it at v2, I
> think it might be an okay incarnation of the lazy approach.

I thought about doing it that way, but the return value allows
checking that any input was actually used instead of fast init
completing in the mean time.

If you want I can do that.