Re: [PATCH] random: make try_to_generate_entropy() more robust

From: Thomas Gleixner
Date: Sat Oct 19 2019 - 06:13:59 EST


On Sat, 19 Oct 2019, Ingo Molnar wrote:
> * Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> > On Fri, Oct 18, 2019 at 4:42 PM JÃrn Engel <joern@xxxxxxxxxxxxxxx> wrote:
>
> But from a softirq or threaded irq context that 'interrupted' regs
> context might potentially be NULL.
>
> NULL isn't a good thing to pass to mix_pool_bytes(), because the first
> use of 'in' (='bytes') in _mix_pool_bytes() is a dereference without a
> NULL check AFAICS:
>
> w = rol32(*bytes++, input_rotate);
>
> So at minimum I'd only mix this entropy into the pool if 'regs' is
> non-zero. This would automatically do the right thing and not crash the
> kernel on weird irq execution models such as threaded-only or -rt.

You don't even need threaded-only or RT. The timer is fired in the softirq
which very well can happen from thread context in mainline.

Thanks,

tglx