From: Frank Heckenbach <f.heckenbach@fh-soft.de>
To: linux-kernel@vger.kernel.org
Subject: brk() should check randomize_va_space rather then CONFIG_COMPAT_BRK
Date: Sun, 27 Feb 2011 08:37:55 +0100 [thread overview]
Message-ID: <1298792275.19234.928360@goedel.fjf.gnu.de> (raw)
The brk() syscall checks CONFIG_COMPAT_BRK to decide whether the brk
area starts just after the end of the code+bss.
Since CONFIG_COMPAT_BRK can be overridden by
/proc/sys/kernel/randomize_va_space, it should rather check this
variable (which is initialized in mm/memory.c from
CONFIG_COMPAT_BRK), see the patch below.
I've tested it with an old libc5 binary: Without the patch, if the
kernel was configured without CONFIG_COMPAT_BRK, the first malloc()
fails with any setting of randomize_va_space. With the patch
applied, the program runs correctly with randomize_va_space < 2, but
not with randomize_va_space == 2, as it should be.
--- linux-2.6.37.2/mm/mmap.c.orig 2011-02-25 00:09:00.000000000 +0100
+++ linux-2.6.37.2/mm/mmap.c 2011-02-26 01:13:53.000000000 +0100
@@ -252,11 +252,11 @@
down_write(&mm->mmap_sem);
-#ifdef CONFIG_COMPAT_BRK
- min_brk = mm->end_code;
-#else
- min_brk = mm->start_brk;
-#endif
+ if (randomize_va_space < 2)
+ min_brk = mm->end_code;
+ else
+ min_brk = mm->start_brk;
+
if (brk < min_brk)
goto out;
next reply other threads:[~2011-02-27 12:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-27 7:37 Frank Heckenbach [this message]
2011-02-28 14:29 ` Jiri Kosina
2011-02-28 14:31 ` Jiri Kosina
2011-03-01 5:33 ` Frank Heckenbach
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=1298792275.19234.928360@goedel.fjf.gnu.de \
--to=f.heckenbach@fh-soft.de \
--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
all inboxes | Powered by JetHome®