]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
x86: avoid dereferencing beyond stack + THREAD_SIZE
authorDavid Rientjes <rientjes@google.com>
Sun, 26 Oct 2008 22:13:59 +0000 (18:13 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 7 Nov 2008 03:05:50 +0000 (19:05 -0800)
commit e1e23bb0513520035ec934fa3483507cb6648b7c upstream

x86: avoid dereferencing beyond stack + THREAD_SIZE

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>
Cc: Chuck Ebbert <cebbert@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/x86/kernel/process_64.c

index e12e0e4dd2566c2959623d4475053c5fcbcd65d3..5a7c5392266194ba430d3d66120b956eaf4cb434 100644 (file)
@@ -729,12 +729,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))