mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch] x86: avoid dereferencing beyond stack + THREAD_SIZE
@ 2008-10-07 21:15 David Rientjes
  2008-10-08  9:25 ` Ingo Molnar
  0 siblings, 1 reply; 2+ messages in thread
From: David Rientjes @ 2008-10-07 21:15 UTC (permalink / raw)
  To: Andrew Morton; +Cc: H. Peter Anvin, Andi Kleen, linux-kernel

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.

Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Andi Kleen <ak@linux.intel.com>
Signed-off-by: David Rientjes <rientjes@google.com>
---
 arch/x86/kernel/process_64.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -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))

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-10-08  9:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-07 21:15 [patch] x86: avoid dereferencing beyond stack + THREAD_SIZE David Rientjes
2008-10-08  9:25 ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®