commit c547c77ee4d0408907847f64c403df1bf2f9c7a0
tree ffbc35f7dcbf7b1b57f220c1e1a555bed24a6089
parent 38b5b036b91248be8033d42dd0778b1c75c5af58
author Andi Kleen <[EMAIL PROTECTED]> 1164741179 +0100
committer Andi Kleen <[EMAIL PROTECTED]> 1164741179 +0100

[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: Andi Kleen <[EMAIL PROTECTED]>

 arch/x86_64/kernel/traps.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index a153d0a..0d65b22 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -242,12 +242,19 @@ static int dump_trace_unwind(struct unwi
  * 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,
                struct stacktrace_ops *ops, void *data)
 {
        const unsigned cpu = smp_processor_id();
        unsigned long *irqstack_end = (unsigned long 
*)cpu_pda(cpu)->irqstackptr;
        unsigned used = 0;
+       struct thread_info *tinfo;
 
        if (!tsk)
                tsk = current;
@@ -370,7 +377,8 @@ void dump_trace(struct task_struct *tsk,
        /*
         * 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
 }
 EXPORT_SYMBOL(dump_trace);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to