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

From: Andi Kleen
Date: Tue Nov 19 2019 - 23:25:38 EST


Jann Horn <jannh@xxxxxxxxxx> writes:

> +
> + if (error_code)
> + pr_alert("GPF is segment-related (see error code)\n");
> + else
> + print_kernel_gp_address(regs);

Is this really correct? There are a lot of instructions that can do #GP
(it's the CPU's equivalent of EINVAL) and I'm pretty sure many of them
don't set an error code, and many don't have operands either.

You would need to make sure the instruction decoder handles these
cases correctly, and ideally that you detect it instead of printing
a bogus address.

-Andi