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

From: Ingo Molnar
Date: Wed Nov 20 2019 - 08:16:34 EST



* Jann Horn <jannh@xxxxxxxxxx> wrote:

> On Wed, Nov 20, 2019 at 12:24 PM Borislav Petkov <bp@xxxxxxxxx> wrote:
> > On Wed, Nov 20, 2019 at 12:18:59PM +0100, Ingo Molnar wrote:
> > > How was this maximum string length of '90' derived? In what way will
> > > that have to change if someone changes the message?
> >
> > That was me counting the string length in a dirty patch in a previous
> > thread. We probably should say why we decided for a certain length and
> > maybe have a define for it.
>
> Do you think something like this would be better?
>
> char desc[sizeof(GPFSTR) + 50 + 2*sizeof(unsigned long) + 1] = GPFSTR;

I'd much prefer this for, because it's a big honking warning for people
to not just assume things but double check the limits.

I.e. this mild obfuscation of the array size *helps* code quality in the
long run :-)

Thanks,

Ingo