]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
x86: avoid dereferencing beyond stack + THREAD_SIZE
authorDavid Rientjes <rientjes@google.com>
Tue, 7 Oct 2008 21:15:11 +0000 (14:15 -0700)
committerIngo Molnar <mingo@elte.hu>
Sun, 12 Oct 2008 09:18:59 +0000 (11:18 +0200)
It's possible for get_wchan() to dereference past task->stack + THREAD_SIZE
while iterating through instruction pointers if fp equals the upper boundary,
causing a kernel panic.

Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/process_64.c

index 2a8ccb9238b4719036aef70780b282e60f58acdd..b6b508ea71106f414deed5d11a9f43bbc8f6eb02 100644 (file)
@@ -754,12 +754,12 @@ unsigned long get_wchan(struct task_struct *p)
        if (!p || p == current || p->state == TASK_RUNNING)
                return 0;
        stack = (unsigned long)task_stack_page(p);
-       if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE)
+       if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
                return 0;
        fp = *(u64 *)(p->thread.sp);
        do {
                if (fp < (unsigned long)stack ||
-                   fp > (unsigned long)stack+THREAD_SIZE)
+                   fp >= (unsigned long)stack+THREAD_SIZE)
                        return 0;
                ip = *(u64 *)(fp+8);
                if (!in_sched_functions(ip))