public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: Ingo Molnar <mingo@elte.hu>,
	linux-kernel Mailing List <linux-kernel@vger.kernel.org>,
	Arjan van de Ven <arjan@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] Fix  max-stack calculators to skip canary
Date: Tue, 22 Apr 2008 10:33:14 -0700	[thread overview]
Message-ID: <1208885594.8636.23.camel@localhost> (raw)
In-Reply-To: <480E1DED.9040104@sandeen.net>

On Tue, 2008-04-22 at 12:18 -0500, Eric Sandeen wrote:
> 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);
> 

Wouldn't it be better to have exactly the same code?
How about using a statement expression macro?

#define DEBUG_STACK_FREE(process) \
({ \
	unsigned long *n = end_of_stack(process); \
	do { 	/* Skip over canary */\
		n++; \
	} while (!*n); \
	(unsigned long)n - (unsigned long)end_of_stack(process); \
})


  reply	other threads:[~2008-04-22 17:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-22  3:44 [PATCH] use canary at end of stack to indicate overruns at oops time Eric Sandeen
2008-04-22  4:20 ` Arjan van de Ven
2008-04-22  8:44 ` Ingo Molnar
2008-04-22 16:44   ` Eric Sandeen
2008-04-22 17:18     ` [PATCH] Fix max-stack calculators to skip canary Eric Sandeen
2008-04-22 17:33       ` Joe Perches [this message]
2008-04-22 18:09         ` Eric Sandeen
2008-04-28 17:28       ` Ingo Molnar
2008-04-22 21:38 ` [PATCH V2] use canary at end of stack to indicate overruns at oops time Eric Sandeen
2008-04-22 22:14   ` Harvey Harrison
2008-04-22 22:28     ` Eric Sandeen
2008-04-28 17:31   ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1208885594.8636.23.camel@localhost \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=sandeen@sandeen.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox