[PATCH] Fix max-stack calculators to skip canary

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Eric Sandeen
Date: Tuesday, April 22, 2008 - 10:18 am

With the canary on the end of the stack, anything which
looks for 0 to mean unused when calculating max stack
excursions must skip over this non-zero magic number.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

Index: linux-2.6.25/kernel/exit.c
===================================================================
--- linux-2.6.25.orig/kernel/exit.c	2008-04-20 22:34:16.000000000 -0500
+++ linux-2.6.25/kernel/exit.c	2008-04-22 11:38:05.769412824 -0500
@@ -826,6 +826,8 @@ static void check_stack_usage(void)
 	unsigned long *n = end_of_stack(current);
 	unsigned long free;
 
+	n++;	/* skip over canary at end */
+
 	while (*n == 0)
 		n++;
 	free = (unsigned long)n - (unsigned long)end_of_stack(current);
Index: linux-2.6.25/kernel/sched.c
===================================================================
--- linux-2.6.25.orig/kernel/sched.c	2008-04-20 22:34:19.000000000 -0500
+++ linux-2.6.25/kernel/sched.c	2008-04-22 11:48:06.975407495 -0500
@@ -5190,6 +5190,8 @@ void sched_show_task(struct task_struct 
 #ifdef CONFIG_DEBUG_STACK_USAGE
 	{
 		unsigned long *n = end_of_stack(p);
+
+		n++;	/* skip over canary at end */
 		while (!*n)
 			n++;
 		free = (unsigned long)n - (unsigned long)end_of_stack(p);

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Fix max-stack calculators to skip canary, Eric Sandeen, (Tue Apr 22, 10:18 am)
Re: [PATCH] Fix max-stack calculators to skip canary, Joe Perches, (Tue Apr 22, 10:33 am)
Re: [PATCH] Fix max-stack calculators to skip canary, Eric Sandeen, (Tue Apr 22, 11:09 am)
Re: [PATCH] Fix max-stack calculators to skip canary, Ingo Molnar, (Mon Apr 28, 10:28 am)