public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hui Huang <Hui.Huang@Sun.COM>
To: Andrea Arcangeli <andrea@novell.com>
Cc: linux-kernel@vger.kernel.org, Andrew Morton <akpm@osdl.org>
Subject: Re: heap-stack-gap for 2.6
Date: Mon, 27 Sep 2004 23:25:40 -0700	[thread overview]
Message-ID: <415903E4.1030808@sun.com> (raw)
In-Reply-To: <20040925162252.GN3309@dualathlon.random>

Andrea Arcangeli wrote:
> This patch enforces a gap between heap and stack, both on the mmap side
> (for heap) and on the growsdown page faults for stack. the gap is in
> page units and it's sysctl configurable. Against CVS head.
> 
> This is needed for some critical app, that wants an higher degree of
> protection against potential stack overflows from the kernel. This is
> mostly a 32bit matter of course, since on 32bit those apps are using
> a few gigs of heap and they get as near as they can to the stack (but if
> something goes wrong a page fault must happen).
> 
> 
> the default value of 1 avoids userspace apps like java to break,

Ok, I'm a JVM guy and I worked on heap-stack-gap issue many moons ago.
The reason that heap-stack-gap on SuSE Linux used to crash Java is
because we are explicitly setting up a guard page to prevent heap-stack
collision (a stack guard is also required in order to throw stack
overflow exception). So in a java program, prev_vma in your patch does
not point to regular heap memory but the guard page. The hidden gap
would cause SIGSEGV to occur before the thread actually hits the guard,
that confused JVM. We had to work around it by reading the gap size from
/proc.

I'd recommend adding an extra check to see if prev_vma is read/write,
and ignoring heap-stack-gap if prev_vma is guard page. Having a hidden
gap does not offer any extra protection, it only confuses an application
if it manages stack guard.

regards,
-hui
                                                                    but
> those apps will of course set by hand in the rc.d scripts a much higher
> value. 1 is a sane default, if you want to tweak the default with
> mainline inclusion that's fine with me. the sysctl can always be
> disabled by setting it to 0 and then nobody will notice.
> 
> feature is fully enabled on x86* and ppc*. No idea about the ia64 and
> s390x layouts but they've presumably a lot more address space not to
> care about this (this is primarly needed on 32bit apps). 
> 
> I didn't check the topdown model, in theory it should be extended to
> cover that too, this is only working for the legacy model right now
> because those apps aren't going to use topdown anyways.
> 

  parent reply	other threads:[~2004-09-28  6:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-25 16:22 heap-stack-gap for 2.6 Andrea Arcangeli
2004-09-25 23:57 ` Rik van Riel
2004-09-26  0:40   ` Andrea Arcangeli
2004-09-27  8:09 ` Arjan van de Ven
2004-09-27 13:09   ` Andrea Arcangeli
2004-09-28 19:43     ` Arjan van de Ven
2004-09-28 22:19       ` Andrea Arcangeli
2004-09-29  6:05         ` Arjan van de Ven
2004-09-29 14:11           ` Andrea Arcangeli
2004-09-29 14:24             ` Alan Cox
2004-09-29 15:44               ` Andrea Arcangeli
2004-09-29 14:25             ` Arjan van de Ven
2004-09-29 14:53               ` Andrea Arcangeli
2004-09-29 15:01                 ` Arjan van de Ven
2004-09-29 15:40                   ` Andrea Arcangeli
2004-09-28  6:25 ` Hui Huang [this message]
2004-09-28 14:19   ` Andrea Arcangeli
2004-09-29  8:42     ` Hui Huang
2004-09-29 14:23       ` Andrea Arcangeli
2004-09-29 22:01         ` Hui Huang
2004-10-12  0:51           ` Andrea Arcangeli

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=415903E4.1030808@sun.com \
    --to=hui.huang@sun.com \
    --cc=akpm@osdl.org \
    --cc=andrea@novell.com \
    --cc=linux-kernel@vger.kernel.org \
    /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