Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758386AbYCAO0f (ORCPT ); Sat, 1 Mar 2008 09:26:35 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751912AbYCAO0Z (ORCPT ); Sat, 1 Mar 2008 09:26:25 -0500 Received: from mail.codesourcery.com ([65.74.133.4]:43080 "EHLO mail.codesourcery.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751548AbYCAO0Y (ORCPT ); Sat, 1 Mar 2008 09:26:24 -0500 X-Greylist: delayed 400 seconds by postgrey-1.27 at vger.kernel.org; Sat, 01 Mar 2008 09:26:24 EST Message-ID: <47C96659.80306@codesourcery.com> Date: Sat, 01 Mar 2008 09:21:13 -0500 From: "Carlos O'Donell" Organization: CodeSourcery User-Agent: Mozilla-Thunderbird 2.0.0.9 (X11/20080110) MIME-Version: 1.0 To: Linus Torvalds CC: Michael Kerrisk , Peter Zijlstra , aaw , Andrew Morton , Alan Cox , linux-kernel , drepper@redhat.com, mtk.manpages@gmail.com, Geoff Clare Subject: Re: [RFC/PATCH] RLIMIT_ARG_MAX References: <1204119455.6242.403.camel@lappy> <1204305244.6243.111.camel@lappy> <1204307756.6243.121.camel@lappy> <47C84C6C.2000201@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2121 Lines: 68 Linus Torvalds wrote: > On Fri, 29 Feb 2008, Linus Torvalds wrote: >> I do agree that we should at least make the "MAX(stacksize/4, 128k)" >> change for backwards compatibility. > > How about something like this? This is perfect. As the original submitter of the bug my primary interest is in having the regression fixed. > The alternative is to just remove that size check entirely, and depend on > get_user_pages() doing the stack limit check (among all the *other* checks > it does when it does the acct_stack_growth() thing). > > I'd almost prefer that simpler approach, but I don't have any really > strong preferences. Anybody? > > Linus > > --- > fs/exec.c | 10 +++++++++- > 1 files changed, 9 insertions(+), 1 deletions(-) > > diff --git a/fs/exec.c b/fs/exec.c > index a44b142..e91f9cb 100644 > --- a/fs/exec.c > +++ b/fs/exec.c > @@ -173,8 +173,15 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos, > return NULL; > > if (write) { > - struct rlimit *rlim = current->signal->rlim; > unsigned long size = bprm->vma->vm_end - bprm->vma->vm_start; > + struct rlimit *rlim; > + > + /* > + * We've historically supported up to 32 pages of argument > + * strings even with small stacks > + */ > + if (size <= 32*PAGE_SIZE) > + return page; Could you use ARG_MAX as defined in include/linux/limits.h? > > /* > * Limit to 1/4-th the stack size for the argv+env strings. > @@ -183,6 +190,7 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos, > * - the program will have a reasonable amount of stack left > * to work from. > */ > + rlim = current->signal->rlim; > if (size > rlim[RLIMIT_STACK].rlim_cur / 4) { > put_page(page); > return NULL; Cheers, Carlos. -- Carlos O'Donell CodeSourcery carlos@codesourcery.com (650) 331-3385 x716 -- 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/