Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759238AbXJZMcY (ORCPT ); Fri, 26 Oct 2007 08:32:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752343AbXJZMcQ (ORCPT ); Fri, 26 Oct 2007 08:32:16 -0400 Received: from extu-mxob-2.symantec.com ([216.10.194.135]:53645 "EHLO extu-mxob-2.symantec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752655AbXJZMcP (ORCPT ); Fri, 26 Oct 2007 08:32:15 -0400 Date: Fri, 26 Oct 2007 13:30:42 +0100 (BST) From: Hugh Dickins X-X-Sender: hugh@blonde.wat.veritas.com To: Jiri Kosina cc: Andrew Morton , Sami Farin , Linux kernel Mailing List , Jiri Kosina , Arjan van de Ven Subject: Re: [PATCH] [RFC] brk randomization: compute RLIMIT_DATA properly (was Re: x86: randomize brk() and RLIMIT_DATA) In-Reply-To: Message-ID: References: <20071025134124.wc44gdud7ixghfxv@m.safari.iki.fi> <20071025071324.2eac21d6@laptopd505.fenrus.org> <20071025171942.pjff7jbpempfcuri@m.safari.iki.fi> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1616 Lines: 45 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 > > 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 Acked-by: Hugh Dickins > > 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/