Re: [PATCH v3 2/4] x86/traps: Print non-canonical address on #GP

From: Borislav Petkov
Date: Wed Nov 20 2019 - 12:37:32 EST


On Wed, Nov 20, 2019 at 08:21:43AM -0800, Sean Christopherson wrote:
> On Wed, Nov 20, 2019 at 02:39:13PM +0100, Borislav Petkov wrote:
> > On Wed, Nov 20, 2019 at 02:28:30PM +0100, Ingo Molnar wrote:
> > > I'd rather we not trust the decoder and the execution environment so much
> > > that it never produces a 0 linear address in a #GP:
> >
> > I was just scratching my head whether I could trigger a #GP with address
> > of 0. But yeah, I agree, let's be really cautious here. I wouldn't want
> > to debug a #GP with a wrong address reported.
>
> It's definitely possible, there are a handful of non-SIMD instructions that
> generate #GP(0) it CPL=0 in 64-bit mode *and* have a memory operand. Some
> of them might even be legitimately encountered in the wild.
>
> - CMPXCHG16B if it's not supported by the CPU.
> - VMXON if CR4 is misconfigured or VMX isn't enabled in FEATURE_CONTROL.
> - MONITOR if ECX has an invalid hint (although MONITOR hardcodes the
> address in DS:RAX and so doesn't have a ModR/M byte).
>
> Undoudbtedly there are other instructions with similar sources of #GP.

Right, we currently put our trust in the insn decoder to handle those
correctly too.

--
Regards/Gruss,
Boris.

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