Re: [PATCH v12 6/8] x86/traps: Communicate a LASS violation in #GP message
From: Borislav Petkov
Date: Mon Nov 17 2025 - 13:31:04 EST
On Mon, Nov 17, 2025 at 09:24:20AM -0800, Sohil Mehta wrote:
> The page fault error messages have similar logic:
>
> if (address < PAGE_SIZE && !user_mode(regs))
> pr_alert("BUG: kernel NULL pointer dereference, address: %px\n",
> (void *)address);
>
> I believe the check is to account for arithmetic or other operations
> that may have happened on the "NULL" pointer before it is dereferenced.
Ah ok, that makes sense. That comment still reads weird:
+ /*
+ * If LASS is active, a NULL pointer dereference generates a #GP
+ * instead of a #PF.
+ */
+ if (*addr < PAGE_SIZE)
It says "if LASS is active" but the check if
(cpu_feature_enabled(X86_FEATURE_LASS)) is below it.
I guess you want to have
if (cpu_feature_enabled(X86_FEATURE_LASS)) {
if (*addr < PAGE_SIZE)
return GP_NULL_POINTER;
else
return GP_LASS_VIOLATION;
}
so that it is perfectly clear.
Then the catch-all GP_CANONICAL will take care of the absurd cases, if we ever
hit them.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette