Re: "BUG: Invalid wait context" in invalidate_batched_entropy

From: Sebastian Andrzej Siewior
Date: Fri Jan 28 2022 - 12:02:43 EST


On 2022-01-28 17:28:47 [+0100], Jason A. Donenfeld wrote:
> Hi Sebastian,
Hi Jason,

> Gotcha. Surely, then, Andy's patch at least goes some of the way
> toward fixing this, since it outright _removes_ a spinlock_t. There is
> still the other spinlock_t that you want removed, I realize, though
> this doesn't appear to be the one from Jonathan's bug report. It
> sounds like Andy's patch might be one side of the fix, and your patch
> the other?

Only if we want to keep that lock a raw_spinlock_t. And this change
extends your IRQ-off region. Before I was only worried about that one
lock and all the callers. Now we have a little more possibilities.

>From looking at get_random_u32(), the whole worst case includes the
whole of extract_crng(). So we have the possible call chain
crng_reseed() -> crng_finalize_init() and here we have
wake_up_interruptible() and kill_fasync() which both can't be called
with disabled interrupts.

> Jason

Sebastian