Re: [PATCH v7 3/4] x86/dumpstack: Introduce die_addr() for die() with #GP fault address

From: Borislav Petkov
Date: Tue Dec 31 2019 - 07:13:48 EST


On Thu, Dec 19, 2019 at 12:11:49AM +0100, Jann Horn wrote:
> diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
> index c8b4ae6aed5b..4c691bb9e0d9 100644
> --- a/arch/x86/kernel/traps.c
> +++ b/arch/x86/kernel/traps.c
> @@ -621,7 +621,10 @@ do_general_protection(struct pt_regs *regs, long error_code)
> "maybe for address",
> gp_addr);


> - die(desc, regs, error_code);

I've added here:

/*
* KASAN is interested only in the non-canonical case, clear it
* otherwise.
*/

> + if (hint != GP_NON_CANONICAL)
> + gp_addr = 0;


otherwise you have:

if (hint != GP_NO_HINT)
...

if (hint != GP_NON_CANONICAL)
...

which is kinda confusing at a first glance and one has to follow the
code into die_addr() to figure out the usage of the address argument.

Thx.

--
Regards/Gruss,
Boris.

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