From: Pavel Machek <pavel@ucw.cz>
To: Ingo Molnar <mingo@elte.hu>
Cc: Arjan van de Ven <arjan@infradead.org>,
Hugh Dickins <hugh@veritas.com>, Jiri Kosina <jkosina@suse.cz>,
kernel list <linux-kernel@vger.kernel.org>,
Abel Bernabeu <abel.bernabeu@gmail.com>
Subject: Re: brk randomization breaks columns
Date: Tue, 5 Feb 2008 23:03:42 +0100 [thread overview]
Message-ID: <20080205220342.GB1630@elf.ucw.cz> (raw)
In-Reply-To: <20080205160620.GA28812@elte.hu>
Hi!
> > . Yes, setarch i386 -R /usr/local/bin/uemacs (etc) fixes them, too.
> >
> > What about this?
> >
> > Heap randomization breaks /lib/libc.so.5.4.33, make it possible to
> > randomize normal stuff but leave the heap alone.
>
> certainly looks fine to me, but please also add a .config to make it
> default to 2. The reason is that a good portions of the overflows happen
> on the heap and 99.9% of the Linux users do not run 1996-era glibc
> anymore.
>
> something like CONFIG_COMPAT_BRK=y, which would cause randomize_va_space
> to default to 1, and if a user or distro disables it, it will default to
> 2.
I named it slightly differently, but idea is same. Heap randomization
breaks ancient binaries, so disable it by default.
Signed-off-by: Pavel Machek <pavel@suse.cz>
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 18ed6dd..4b099ea 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1077,7 +1077,7 @@ #endif /* ARCH_HAS_SETUP_ADDITIONAL_PAGE
current->mm->start_stack = bprm->p;
#ifdef arch_randomize_brk
- if (current->flags & PF_RANDOMIZE)
+ if ((current->flags & PF_RANDOMIZE) && (randomize_va_space > 1))
current->mm->brk = current->mm->start_brk =
arch_randomize_brk(current->mm);
#endif
diff --git a/init/Kconfig b/init/Kconfig
index dcc96a8..37c7852 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -541,6 +541,16 @@ config ELF_CORE
help
Enable support for generating core dumps. Disabling saves about 4k.
+config RANDOMIZE_HEAP
+ bool "Randomize heap placement"
+ help
+ Randomizing heap placement makes heap exploits harder, but it also
+ breaks old programs (including anything libc5 based). This only
+ changes default, and can be overriden in runtime by tweaking
+ /proc/sys/kernel/randomize_va_space.
+
+ N is safe choice here.
+
config BASE_FULL
default y
bool "Enable full-sized data structures for core" if EMBEDDED
diff --git a/mm/memory.c b/mm/memory.c
index 4706af1..5134014 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -82,7 +82,12 @@ void * high_memory;
EXPORT_SYMBOL(num_physpages);
EXPORT_SYMBOL(high_memory);
-int randomize_va_space __read_mostly = 1;
+int randomize_va_space __read_mostly =
+#ifdef CONFIG_RANDOMIZE_HEAP
+ 2;
+#else
+ 1;
+#endif
static int __init disable_randmaps(char *s)
{
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
next prev parent reply other threads:[~2008-02-05 22:03 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-04 12:28 brk randomization breaks columns Pavel Machek
2008-02-04 13:01 ` Ingo Molnar
2008-02-04 13:28 ` Pavel Machek
2008-02-04 14:55 ` Jiri Kosina
2008-02-04 20:25 ` Pavel Machek
2008-02-04 14:33 ` Jiri Kosina
2008-02-04 16:12 ` Jiri Kosina
[not found] ` <15577be70802041016m97cddbfk43b9073408bcbce9@mail.gmail.com>
[not found] ` <15577be70802041029o2975ba6do34589bbdc81d1652@mail.gmail.com>
2008-02-04 19:52 ` Fwd: " Pavel Machek
2008-02-04 21:54 ` Abel Bernabeu
2008-02-04 22:48 ` Jiri Kosina
2008-02-04 23:13 ` Abel Bernabeu
2008-02-04 23:39 ` Pavel Machek
2008-02-04 20:31 ` Pavel Machek
2008-02-05 1:57 ` Jiri Kosina
2008-02-05 11:06 ` [regression] " Pavel Machek
2008-02-05 12:50 ` Jiri Kosina
2008-02-05 12:54 ` Ingo Molnar
2008-02-05 13:05 ` Jakub Jelinek
2008-02-05 16:18 ` Pavel Machek
2008-02-05 16:37 ` Ingo Molnar
2008-02-05 16:12 ` Pavel Machek
2008-02-05 13:08 ` Hugh Dickins
2008-02-05 15:00 ` Arjan van de Ven
2008-02-05 15:46 ` Pavel Machek
2008-02-05 15:49 ` Jiri Kosina
2008-02-05 15:55 ` Pavel Machek
2008-02-05 15:49 ` Ingo Molnar
2008-02-05 15:59 ` Pavel Machek
2008-02-05 16:06 ` Ingo Molnar
2008-02-05 22:03 ` Pavel Machek [this message]
2008-02-05 16:58 ` Arjan van de Ven
2008-02-05 17:33 ` Pavel Machek
2008-02-05 22:35 ` Jiri Kosina
2008-02-06 3:24 ` Randy Dunlap
2008-02-05 16:02 ` Pavel Machek
2008-02-05 16:09 ` Ingo Molnar
2008-02-05 22:04 ` Pavel Machek
2008-02-05 18:05 ` Pavel Machek
2008-02-05 20:42 ` Jiri Kosina
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=20080205220342.GB1630@elf.ucw.cz \
--to=pavel@ucw.cz \
--cc=abel.bernabeu@gmail.com \
--cc=arjan@infradead.org \
--cc=hugh@veritas.com \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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