Re: [patch V3 4/6] x86/pkru: Make PKRU=0 actually work

From: Borislav Petkov
Date: Tue Jun 08 2021 - 16:06:22 EST


On Tue, Jun 08, 2021 at 09:15:42PM +0200, Thomas Gleixner wrote:
> But if nothing touched the FPU between T1 scheduling out and back in,
> then the fpregs_state is still valid which means switch_fpu_return()
> does nothing and just clears TIF_NEED_FPU_LOAD. Back to user space with
> DEFAULT_PKRU loaded. -> FAIL #2!

Ah ok.

> Why? It was clearly wrong and I can reproduce it with a hack which
> forces a schedule to a kernel thread and it fails all the way back to
> user space.

Oh, I was speculating about some weird luserspace's behavior of clearing
PKRU and then relying on the buggy behavior of getting PKRU restored to
DEFAULT_PKRU.

I know, it is nuts but it is user-visible change. And yeah, probably
nothing does that...

> I chased that because I observed sporadic failures when forcing PKRU to
> init state and then observed the default key being written. I had some
> extra trace_printks there to analyze something completely different :)

As you do. :-)

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette