[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191023191725.67dg3vwkpodmbrqv@treble>
Date: Wed, 23 Oct 2019 14:17:25 -0500
From: Josh Poimboeuf <jpoimboe@...hat.com>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: Cyrill Gorcunov <gorcunov@...il.com>,
LKML <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>, linux-mm@...ck.org,
Catalin Marinas <catalin.marinas@....com>, x86@...nel.org
Subject: Re: [PATCH] x86/dumpstack/64: Don't evaluate exception stacks before
setup
On Wed, Oct 23, 2019 at 08:05:49PM +0200, Thomas Gleixner wrote:
> Cyrill reported the following crash:
>
> BUG: unable to handle page fault for address: 0000000000001ff0
> #PF: supervisor read access in kernel mode
> RIP: 0010:get_stack_info+0xb3/0x148
>
> It turns out that if the stack tracer is invoked before the exception stack
> mappings are initialized in_exception_stack() can erroneously classify an
> invalid address as an address inside of an exception stack:
>
> begin = this_cpu_read(cea_exception_stacks); <- 0
> end = begin + sizeof(exception stacks);
>
> i.e. any address between 0 and end will be considered as exception stack
> address and the subsequent code will then try to derefence the resulting
> stack frame at a non mapped address.
>
> end = begin + (unsigned long)ep->size;
> ==> end = 0x2000
>
> regs = (struct pt_regs *)end - 1;
> ==> regs = 0x2000 - sizeof(struct pt_regs *) = 0x1ff0
>
> info->next_sp = (unsigned long *)regs->sp;
> ==> Crashes due to accessing 0x1ff0
>
> Prevent this by checking the validity of the cea_exception_stack base
> address and bailing out if it is zero.
>
> Fixes: afcd21dad88b ("x86/dumpstack/64: Use cpu_entry_area instead of orig_ist")
> Reported-by: Cyrill Gorcunov <gorcunov@...il.com>
> Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
> Tested-by: Cyrill Gorcunov <gorcunov@...il.com>
> Cc: stable@...r.kernel.org
Acked-by: Josh Poimboeuf <jpoimboe@...hat.com>
--
Josh
Powered by blists - more mailing lists