Re: [PATCH] x86: fix user address masking non-canonical speculation issue
From: Kirill A. Shutemov
Date: Thu Oct 24 2024 - 08:32:52 EST
On Thu, Oct 24, 2024 at 01:08:22PM +0200, Borislav Petkov wrote:
> > @@ -2389,6 +2390,15 @@ void __init arch_cpu_finalize_init(void)
> > alternative_instructions();
> >
> > if (IS_ENABLED(CONFIG_X86_64)) {
> > + unsigned long USER_PTR_MAX = TASK_SIZE_MAX;
> > +
> > + /*
> > + * Enable this when LAM is gated on LASS support
> > + if (cpu_feature_enabled(X86_FEATURE_LAM))
> > + USER_PTR_MAX = (1ul << 63) - PAGE_SIZE;
> > + */
> > + runtime_const_init(ptr, USER_PTR_MAX);
>
> Looking at Documentation/arch/x86/x86_64/mm.rst, 5 level page tables define
> USR_PTR_MAX as 0x00ffffffffffffff, i.e., bits [55:0].
>
> So I guess that USER_PTR_MAX needs to look at X86_FEATURE_LA57, no?
X86_FEATURE_LA57 is already handled inside TASK_SIZE_MAX definition.
Although, it might be worth updating end of userspace VA in mm.rst with
-PAGE_SIZE.
--
Kiryl Shutsemau / Kirill A. Shutemov