LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jiri Kosina <jkosina@suse.cz>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@elte.hu>,
	Arjan van de Ven <arjan@infradead.org>,
	Hugh Dickins <hugh@veritas.com>, Pavel Machek <pavel@suse.cz>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] brk: check the lower bound properly
Date: Wed, 6 Feb 2008 14:45:16 +0100 (CET)	[thread overview]
Message-ID: <Pine.LNX.4.64.0802061441010.30955@jikos.suse.cz> (raw)
In-Reply-To: <Pine.LNX.4.64.0802061438150.30955@jikos.suse.cz>

From: Jiri Kosina <jkosina@suse.cz>

brk: check the lower bound properly

There is a check in sys_brk(), that tries to make sure that we do not
underflow the area that is dedicated to brk heap.

The check is however wrong, as it assumes that brk area starts immediately
after the end of the code (+bss), which is wrong for example in
environments with randomized brk start. The proper way is to check whether
the address is not below the start_brk address.

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Arjan van de Ven <arjan@infradead.org>
Acked-by: Hugh Dickins <hugh@veritas.com>
Acked-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

diff --git a/mm/mmap.c b/mm/mmap.c
index 8295577..1c3b48f 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -241,7 +241,7 @@ asmlinkage unsigned long sys_brk(unsigned long brk)
 
 	down_write(&mm->mmap_sem);
 
-	if (brk < mm->end_code)
+	if (brk < mm->start_brk)
 		goto out;
 
 	/*

  reply	other threads:[~2008-02-06 13:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-06 13:45 [PATCH 0/2] brk and randomization fixes Jiri Kosina
2008-02-06 13:45 ` Jiri Kosina [this message]
2008-02-06 13:45 ` [PATCH 2/2] ASLR: add possibility for more fine-grained tweaking Jiri Kosina
2008-02-06 13:49   ` Ingo Molnar
2008-02-06 16:26     ` [PATCH] Document randomize_va_space and CONFIG_COMPAT_BRK (was Re: [PATCH 2/2] ASLR: add possibility for more fine-grained tweaking) Jiri Kosina
2008-02-06 23:10       ` Ingo Molnar
2008-02-07  9:49         ` Jiri Kosina
2008-02-07 14:30         ` Jiri Kosina
2008-02-07 15:01           ` Ingo Molnar
2008-02-07 10:23     ` [PATCH 2/2] ASLR: add possibility for more fine-grained tweaking Geert Uytterhoeven
2008-02-07 10:31       ` Ismail Dönmez
2008-02-07 10:32       ` Ingo Molnar
2008-02-07 10:43         ` Geert Uytterhoeven

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=Pine.LNX.4.64.0802061441010.30955@jikos.suse.cz \
    --to=jkosina@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@infradead.org \
    --cc=hugh@veritas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=pavel@suse.cz \
    --subject='Re: [PATCH 1/2] brk: check the lower bound properly' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).