]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
x86: avoid dereferencing beyond stack + THREAD_SIZE
authorDavid Rientjes <rientjes@google.com>
Mon, 13 Oct 2008 23:42:12 +0000 (19:42 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 22 Oct 2008 21:13:25 +0000 (14:13 -0700)
commit 60e6258cd43f9b06884f04f0f7cefb9c40f17a32 upstream

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 c6eb5c91e5f607f7fb70758ed65eee667c7d1401..a803de31600e21ce23ae05d1c755cb0a4d3477dd 100644 (file)
@@ -740,12 +740,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))