mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: Jiri Kosina <jikos@jikos.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Sami Farin <safari-kernel@safari.iki.fi>,
	Linux kernel Mailing List <linux-kernel@vger.kernel.org>,
	Jiri Kosina <jkosina@suse.cz>,
	Arjan van de Ven <arjan@infradead.org>
Subject: Re: [PATCH] [RFC] brk randomization: compute RLIMIT_DATA properly (was Re: x86: randomize brk() and RLIMIT_DATA)
Date: Fri, 26 Oct 2007 13:30:42 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0710261329450.27706@blonde.wat.veritas.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0710261414030.18815@twin.jikos.cz>

On Fri, 26 Oct 2007, Jiri Kosina wrote:
> On Fri, 26 Oct 2007, Hugh Dickins wrote:
> 
> > > -	if (rlim < RLIM_INFINITY && brk - mm->start_data > rlim)
> > > +	if (rlim < RLIM_INFINITY && brk - mm->start_data -
> > > +			(mm->start_brk - mm->end_data) > rlim)
> > I find the order in that test mysterious.
> 
> I agree that the order you proposed is easier to understand on the first 
> sight.
> 
> 
> From: Jiri Kosina <jkosina@suse.cz>
> 
> brk randomization: compute RLIMIT_DATA properly
> 
> In cases of heap area placed at randomly-generated offset from
> mm->end_data (arch_randomize_brk()), we need to subtract the value of the
> offset for setrlimit(RLIMIT_DATA) to work properly -- otherwise we count
> the unoccupied memory between mm->end_data and mm->start_brk as occupied.
> 
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Acked-by: Hugh Dickins <hugh@veritas.com>

> 
> diff --git a/mm/mmap.c b/mm/mmap.c
> index facc1a7..673ac7d 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -251,7 +251,8 @@ asmlinkage unsigned long sys_brk(unsigned long brk)
>  	 * not page aligned -Ram Gupta
>  	 */
>  	rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
> -	if (rlim < RLIM_INFINITY && brk - mm->start_data > rlim)
> +	if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
> +			(mm->end_data - mm->start_data) > rlim)
>  		goto out;
>  
>  	newbrk = PAGE_ALIGN(brk);

  reply	other threads:[~2007-10-26 12:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-25 13:41 x86: randomize brk() and RLIMIT_DATA Sami Farin
2007-10-25 14:13 ` Arjan van de Ven
2007-10-25 14:46   ` Jiri Kosina
2007-10-25 17:19     ` Sami Farin
2007-10-26 10:44       ` [PATCH] [RFC] brk randomization: compute RLIMIT_DATA properly (was Re: x86: randomize brk() and RLIMIT_DATA) Jiri Kosina
2007-10-26 12:02         ` Hugh Dickins
2007-10-26 12:16           ` Jiri Kosina
2007-10-26 12:30             ` Hugh Dickins [this message]
2007-10-26 12:33               ` Jan Engelhardt
2007-10-26 13:24                 ` Hugh Dickins

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.0710261329450.27706@blonde.wat.veritas.com \
    --to=hugh@veritas.com \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@infradead.org \
    --cc=jikos@jikos.cz \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=safari-kernel@safari.iki.fi \
    /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®