Re: [tip: x86/urgent] x86/cpu: Disable CR pinning during CPU bringup
From: Borislav Petkov
Date: Wed Mar 18 2026 - 17:09:38 EST
On Wed, Mar 18, 2026 at 09:47:22PM +0100, Peter Zijlstra wrote:
> On Wed, Mar 18, 2026 at 06:51:10PM -0000, tip-bot2 for Dave Hansen wrote:
> > --- a/arch/x86/kernel/cpu/common.c
> > +++ b/arch/x86/kernel/cpu/common.c
> > @@ -437,6 +437,21 @@ static const unsigned long cr4_pinned_mask = X86_CR4_SMEP | X86_CR4_SMAP | X86_C
> > static DEFINE_STATIC_KEY_FALSE_RO(cr_pinning);
> > static unsigned long cr4_pinned_bits __ro_after_init;
> >
> > +static bool cr_pinning_enabled(void)
> > +{
> > + if (!static_branch_likely(&cr_pinning))
> > + return false;
> > +
> > + /*
> > + * Do not enforce pinning during CPU bringup. It might
> > + * turn on features that are not set up yet, like FRED.
> > + */
> > + if (!cpu_online(smp_processor_id()))
> > + return false;
> > +
> > + return true;
> > +}
>
> Urgh, so this means all an attack needs to do is disable the online bit
> and it gets to poke CR4 bits.
>
> This seems unfortunate.
>
> And sure, randomly clearing the online bit will eventually cause havoc,
> but I suspect you still get plenty time until the system goes wobbly.
My idea was that this is only temporary and then, ontop, we'll do something
like this:
https://lore.kernel.org/r/cb492a37-3517-4738-b435-73311402e820@xxxxxxxxx
I.e., you figure out all the CR4 pinned bits on the BSP *once*, cast them in
stone and then replicate them on the APs when they come up.
I.e., you figure everything out the earliest and then no more switching.
Then all that gunk will disappear, hopefully.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette