Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752463Ab0BHHLx (ORCPT ); Mon, 8 Feb 2010 02:11:53 -0500 Received: from fgwmail7.fujitsu.co.jp ([192.51.44.37]:43067 "EHLO fgwmail7.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750812Ab0BHHLw (ORCPT ); Mon, 8 Feb 2010 02:11:52 -0500 X-SecurityPolicyCheck-FJ: OK by FujitsuOutboundMailChecker v1.3.1 From: KOSAKI Motohiro To: Americo Wang Subject: Re: [PATCH] Restrict stack space reservation to rlimit Cc: kosaki.motohiro@jp.fujitsu.com, Michael Neuling , Anton Blanchard , Andrew Morton , Linus Torvalds , Alexander Viro , Oleg Nesterov , James Morris , Ingo Molnar , linux-fsdevel@vger.kernel.org, stable@kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org, Serge Hallyn , Paul Mackerras , benh@kernel.crashing.org, miltonm@bga.com, aeb@cwi.nl In-Reply-To: <2375c9f91002072307h4af1ba6dw1b7a598582991dc4@mail.gmail.com> References: <20100208145240.FB58.A69D9226@jp.fujitsu.com> <2375c9f91002072307h4af1ba6dw1b7a598582991dc4@mail.gmail.com> Message-Id: <20100208161014.7C6D.A69D9226@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Mailer: Becky! ver. 2.50.07 [ja] Date: Mon, 8 Feb 2010 16:11:47 +0900 (JST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1464 Lines: 39 > On Mon, Feb 8, 2010 at 2:05 PM, KOSAKI Motohiro > wrote: > >> --- linux-2.6-ozlabs.orig/fs/exec.c > >> +++ linux-2.6-ozlabs/fs/exec.c > >> @@ -627,10 +627,13 @@ int setup_arg_pages(struct linux_binprm > >>                       goto out_unlock; > >>       } > >> > >> +     stack_base = min(EXTRA_STACK_VM_PAGES * PAGE_SIZE, > >> +                      current->signal->rlim[RLIMIT_STACK].rlim_cur - > >> +                        PAGE_SIZE); > > > > This line is a bit unclear why "- PAGE_SIZE" is necessary. > > personally, I like following likes explicit comments. > > > >        stack_expand = EXTRA_STACK_VM_PAGES * PAGE_SIZE; > >        stack_lim = ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur); > > > >        /* Initial stack must not cause stack overflow. */ > >        if (stack_expand + PAGE_SIZE > stack_lim) > >                stack_expand = stack_lim - PAGE_SIZE; > > > > note: accessing rlim_cur require ACCESS_ONCE. > > > > > > Thought? > > It's better to use the helper function: rlimit(). AFAIK, stable tree doesn't have rlimit(). but yes, making two patch (for mainline and for stable) is good opinion. -- 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/