[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191120132830.GB54414@gmail.com>
Date: Wed, 20 Nov 2019 14:28:30 +0100
From: Ingo Molnar <mingo@...nel.org>
To: Borislav Petkov <bp@...en8.de>
Cc: Jann Horn <jannh@...gle.com>, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>,
the arch/x86 maintainers <x86@...nel.org>,
Andrey Ryabinin <aryabinin@...tuozzo.com>,
Alexander Potapenko <glider@...gle.com>,
Dmitry Vyukov <dvyukov@...gle.com>,
kasan-dev <kasan-dev@...glegroups.com>,
kernel list <linux-kernel@...r.kernel.org>,
Andrey Konovalov <andreyknvl@...gle.com>,
Andy Lutomirski <luto@...nel.org>,
Sean Christopherson <sean.j.christopherson@...el.com>,
Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH v3 2/4] x86/traps: Print non-canonical address on #GP
* Borislav Petkov <bp@...en8.de> wrote:
> On Wed, Nov 20, 2019 at 01:30:58PM +0100, Ingo Molnar wrote:
> >
> > * Jann Horn <jannh@...gle.com> wrote:
> >
> > > You mean something like this?
> > >
> > > ========================
> > > diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
> > > index 9b23c4bda243..16a6bdaccb51 100644
> > > --- a/arch/x86/kernel/traps.c
> > > +++ b/arch/x86/kernel/traps.c
> > > @@ -516,32 +516,36 @@ dotraplinkage void do_bounds(struct pt_regs
> > > *regs, long error_code)
> > > * On 64-bit, if an uncaught #GP occurs while dereferencing a non-canonical
> > > * address, return that address.
> > > */
> > > -static unsigned long get_kernel_gp_address(struct pt_regs *regs)
> > > +static bool get_kernel_gp_address(struct pt_regs *regs, unsigned long *addr,
> > > + bool *non_canonical)
> >
> > Yeah, that's pretty much the perfect end result!
>
> Why do we need the bool thing? Can't we rely on the assumption that an
> address of 0 is the error case and use that to determine whether the
> resolving succeeded or not?
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:
in get_addr_ref_32() we could get zero:
linear_addr = (unsigned long)(eff_addr & 0xffffffff) + seg_base;
in get_addr_ref_16() we could get zero too:
linear_addr = (unsigned long)(eff_addr & 0xffff) + seg_base;
Or in particularly exotic crashes we could get zero in get_addr_ref_64()
as well:
linear_addr = (unsigned long)eff_addr + seg_base;
although it's unlikely I suspect.
But the 32-bit case should be plausible enough?
It's also the simplest, most straightforward printout of the decoder
state: we either see an error, or an (address,canonical) pair of values.
Thanks,
Ingo
Powered by blists - more mailing lists