Re: [PATCH] mm/tlb: Fix use_mm() vs TLB invalidate

From: Kees Cook
Date: Fri Feb 21 2020 - 18:10:52 EST


On Fri, Feb 21, 2020 at 11:22:16AM -0800, Andy Lutomirski wrote:
>
>
> > On Feb 21, 2020, at 11:19 AM, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > ïOn Fri, Feb 21, 2020 at 3:11 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> >>
> >> + BUG_ON(!(tsk->flags & PF_KTHREAD));
> >> + BUG_ON(tsk->mm != NULL);
> >
> > Stop this craziness.
> >
> > There is absolutely ZERO excuse for this kind of garbage.
> >
> > Making this a BUG_ON() will just cause all the possible debugging info
> > to be thrown away and lost, and you often have a dead machine.
> >
> > For absolutely no good reason.
> >
> > Make it a WARN_ON_ONCE(). If it triggers, everything works the way it
> > always did, but we get notified.
> >
> > Stop with the stupid crazy BUG_ON() crap already. It is actively _bad_
> > for debugging.
> >
> >
>
> In this particular case, if we actually flub this, we are very likely to cause data corruption â weâre about to do user access with the wrong mm.
>
> So I suppose we could switch to init_mm and carry on. *Something* will crash, but it probably wonât corrupt data or take down the machine.

Why not just fail after the WARN -- I wrote the patch for the (very few)
callers to handle the errors, clean up, and carry on.

--
Kees Cook