[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0710261329450.27706@blonde.wat.veritas.com>
Date: Fri, 26 Oct 2007 13:30:42 +0100 (BST)
From: Hugh Dickins <hugh@...itas.com>
To: Jiri Kosina <jikos@...os.cz>
cc: Andrew Morton <akpm@...ux-foundation.org>,
Sami Farin <safari-kernel@...ari.iki.fi>,
Linux kernel Mailing List <linux-kernel@...r.kernel.org>,
Jiri Kosina <jkosina@...e.cz>,
Arjan van de Ven <arjan@...radead.org>
Subject: Re: [PATCH] [RFC] brk randomization: compute RLIMIT_DATA properly
(was Re: x86: randomize brk() and RLIMIT_DATA)
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@...e.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@...e.cz>
Acked-by: Hugh Dickins <hugh@...itas.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);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists