Commit c547c77e authored by Andi Kleen's avatar Andi Kleen Committed by Andi Kleen

[PATCH] x86-64: Use stricter in process stack check for unwinder

Previously it would check for alignment only, which could break
if the stack pointer was unaligned. Now explicitely check if the
stack pointer is in the stack page of the current process.

Ported from i386.
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
parent 38b5b036
...@@ -242,12 +242,19 @@ static int dump_trace_unwind(struct unwind_frame_info *info, void *context) ...@@ -242,12 +242,19 @@ static int dump_trace_unwind(struct unwind_frame_info *info, void *context)
* severe exception (double fault, nmi, stack fault, debug, mce) hardware stack * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
*/ */
static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
{
void *t = (void *)tinfo;
return p > t && p < t + THREAD_SIZE - 3;
}
void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * stack, void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * stack,
struct stacktrace_ops *ops, void *data) struct stacktrace_ops *ops, void *data)
{ {
const unsigned cpu = smp_processor_id(); const unsigned cpu = smp_processor_id();
unsigned long *irqstack_end = (unsigned long *)cpu_pda(cpu)->irqstackptr; unsigned long *irqstack_end = (unsigned long *)cpu_pda(cpu)->irqstackptr;
unsigned used = 0; unsigned used = 0;
struct thread_info *tinfo;
if (!tsk) if (!tsk)
tsk = current; tsk = current;
...@@ -370,7 +377,8 @@ void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s ...@@ -370,7 +377,8 @@ void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s
/* /*
* This handles the process stack: * This handles the process stack:
*/ */
HANDLE_STACK (((long) stack & (THREAD_SIZE-1)) != 0); tinfo = current_thread_info();
HANDLE_STACK (valid_stack_ptr(tinfo, stack));
#undef HANDLE_STACK #undef HANDLE_STACK
} }
EXPORT_SYMBOL(dump_trace); EXPORT_SYMBOL(dump_trace);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment