[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ff8564b5-8b64-4228-84cc-7e3c0156a886@intel.com>
Date: Mon, 17 Nov 2025 11:45:38 -0800
From: Sohil Mehta <sohil.mehta@...el.com>
To: Borislav Petkov <bp@...en8.de>
CC: <x86@...nel.org>, Dave Hansen <dave.hansen@...ux.intel.com>, "Thomas
Gleixner" <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, "Jonathan
Corbet" <corbet@....net>, "H . Peter Anvin" <hpa@...or.com>, Andy Lutomirski
<luto@...nel.org>, Josh Poimboeuf <jpoimboe@...nel.org>, Peter Zijlstra
<peterz@...radead.org>, Ard Biesheuvel <ardb@...nel.org>, "Kirill A .
Shutemov" <kas@...nel.org>, Xin Li <xin@...or.com>, David Woodhouse
<dwmw@...zon.co.uk>, Sean Christopherson <seanjc@...gle.com>, Rick Edgecombe
<rick.p.edgecombe@...el.com>, Vegard Nossum <vegard.nossum@...cle.com>,
Andrew Cooper <andrew.cooper3@...rix.com>, Randy Dunlap
<rdunlap@...radead.org>, Geert Uytterhoeven <geert@...ux-m68k.org>, Kees Cook
<kees@...nel.org>, Tony Luck <tony.luck@...el.com>, Alexander Shishkin
<alexander.shishkin@...ux.intel.com>, <linux-doc@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-efi@...r.kernel.org>
Subject: Re: [PATCH v12 6/8] x86/traps: Communicate a LASS violation in #GP
message
On 11/17/2025 10:29 AM, Borislav Petkov wrote:
>
> Ah ok, that makes sense. That comment still reads weird:
>
I see. The idea with the comment was to clarify why the check is outside
cpu_feature_enabled(X86_FEATURE_LASS). That clearly failed! :)
> 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.
>
You are right. The condition would typically hit only with LASS enabled.
But since we are adding an extra hint for NULL pointers, I figured it
would be helpful even without LASS (even though it is unlikely to happen).
Therefore, the printed message isn't LASS specific either:
Oops: general protection fault, kernel NULL pointer dereference 0x0:
Also, it makes the code a tiny bit prettier (aesthetically, without the
nested if). We now have 4 hints and a check for each:
if (condition1)
return HINT_1;
...
if (condition4)
return HINT_4;
Would this update to the comment help clarify?
/*
* A NULL pointer dereference usually causes a #PF. However, it
* can result in a #GP when LASS is active. Provide the same
* hint in the rare case that the condition is hit without LASS.
*/
if (*addr < PAGE_SIZE)
return GP_NULL_POINTER;
/*
* Assume that LASS caused the exception, because the address is
* canonical and in the user half.
*/
if (cpu_feature_enabled(X86_FEATURE_LASS))
return GP_LASS_VIOLATION;
Though, I won't push for it further. Code clarity is more important than
reducing indentation.
Powered by blists - more mailing lists