All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Eric Sandeen <sandeen@redhat.com>
Cc: 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] use canary at end of stack to indicate overruns at oops time
Date: Tue, 22 Apr 2008 10:44:04 +0200	[thread overview]
Message-ID: <20080422084404.GA2388@elte.hu> (raw)
In-Reply-To: <480D5F27.1030101@redhat.com>


* Eric Sandeen <sandeen@redhat.com> wrote:

> Use a canary at the end of the stack to clearly indicate at oops time 
> whether the stack has ever overflowed.
> 
> This is a very simple implementation with a couple of drawbacks:
> 
> 1) a thread may legitimately use exactly up to the last
>    word on the stack
> 
>  -- but the chances of doing this and then oopsing later seem slim

even that narrow case is a bug - an NMI might arrive at exactly that 
point and overflow the stack for real.

> 2) it's possible that the stack usage isn't dense enough
>    that the canary location could get skipped over
> 
>  -- but the worst that happens is that we don't flag the overrun

yeah.

> With the code in place, an intentionally-bloated stack oops does:
> 
> BUG: unable to handle kernel paging request at ffff8103f84cc680
> IP: [<ffffffff810253df>] update_curr+0x9a/0xa8
> PGD 8063 PUD 0 
> Thread overran stack or stack corrupted
> Oops: 0000 [1] SMP 
> CPU 0 
> ...

excellent. I've queued this up, it's definitely an improvement in 
debuggability.

we used to have something comparable in ancient kernels (it was called 
the stack red zone IIRC) - but it was not printed in oopses and we lost 
the feature somewhere anyway.

	Ingo

  parent reply	other threads:[~2008-04-22  8:44 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 [this message]
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
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=20080422084404.GA2388@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sandeen@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.