All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Blanchard <anton@samba.org>
To: linuxppc-dev@ozlabs.org
Subject: [patch 09/10] powerpc: Increase stack gap on 64bit binaries
Date: Sun, 22 Feb 2009 22:50:06 +1100	[thread overview]
Message-ID: <20090222115332.790376340@samba.org> (raw)
In-Reply-To: 20090222114957.213647384@samba.org

On 64bit there is a possibility our stack and mmap randomisation will put
the two close enough such that we can't expand our stack to match the ulimit
specified.

To avoid this, start the upper mmap address at 1GB + 128MB below the top of our
address space, so in the worst case we end up with the same ~128MB hole as in
32bit. This works because we randomise the stack over a 1GB range.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Index: linux-2.6/arch/powerpc/mm/mmap.c
===================================================================
--- linux-2.6.orig/arch/powerpc/mm/mmap.c	2009-02-21 09:52:23.000000000 +1100
+++ linux-2.6/arch/powerpc/mm/mmap.c	2009-02-21 10:36:36.000000000 +1100
@@ -30,9 +30,16 @@
 /*
  * Top of mmap area (just below the process stack).
  *
- * Leave an at least ~128 MB hole.
+ * Leave at least a ~128 MB hole on 32bit applications.
+ *
+ * On 64bit applications we randomise the stack by 1GB so we need to
+ * space our mmap start address by a further 1GB, otherwise there is a
+ * chance the mmap area will end up closer to the stack than our ulimit
+ * requires.
  */
-#define MIN_GAP (128*1024*1024)
+#define MIN_GAP32 (128*1024*1024)
+#define MIN_GAP64 ((128 + 1024)*1024*1024UL)
+#define MIN_GAP ((is_32bit_task()) ? MIN_GAP32 : MIN_GAP64)
 #define MAX_GAP (TASK_SIZE/6*5)
 
 static inline int mmap_is_legacy(void)

-- 

  parent reply	other threads:[~2009-02-22 11:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-22 11:49 [patch 00/10] PowerPC address space randomisation Anton Blanchard
2009-02-22 11:49 ` [patch 01/10] powerpc: Move is_32bit_task Anton Blanchard
2009-02-22 11:49 ` [patch 02/10] powerpc: Use new layout for 64bit binaries Anton Blanchard
2009-02-22 11:50 ` [patch 03/10] powerpc: Rearrange mmap.c Anton Blanchard
2009-02-22 11:50 ` [patch 04/10] powerpc: Randomise mmap start address Anton Blanchard
2009-02-22 11:50 ` [patch 05/10] powerpc: More stack randomisation for 64bit binaries Anton Blanchard
2009-02-22 11:50 ` [patch 06/10] powerpc: Randomise lower bits of stack address Anton Blanchard
2009-02-22 11:50 ` [patch 07/10] powerpc: Randomise the brk region Anton Blanchard
2009-02-22 11:50 ` [patch 08/10] powerpc: Ensure random space between stack and mmaps Anton Blanchard
2009-02-22 11:50 ` Anton Blanchard [this message]
2009-02-22 11:50 ` [patch 10/10] powerpc: Randomise PIEs Anton Blanchard

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=20090222115332.790376340@samba.org \
    --to=anton@samba.org \
    --cc=linuxppc-dev@ozlabs.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 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.