[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20100208161014.7C6D.A69D9226@jp.fujitsu.com>
Date: Mon, 8 Feb 2010 16:11:47 +0900 (JST)
From: KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>
To: Americo Wang <xiyou.wangcong@...il.com>
Cc: kosaki.motohiro@...fujitsu.com,
Michael Neuling <mikey@...ling.org>,
Anton Blanchard <anton@...ba.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
Oleg Nesterov <oleg@...hat.com>,
James Morris <jmorris@...ei.org>, Ingo Molnar <mingo@...e.hu>,
linux-fsdevel@...r.kernel.org, stable@...nel.org,
linux-kernel@...r.kernel.org, linuxppc-dev@...abs.org,
Serge Hallyn <serue@...ibm.com>,
Paul Mackerras <paulus@...ba.org>, benh@...nel.crashing.org,
miltonm@....com, aeb@....nl
Subject: Re: [PATCH] Restrict stack space reservation to rlimit
> On Mon, Feb 8, 2010 at 2:05 PM, KOSAKI Motohiro
> <kosaki.motohiro@...fujitsu.com> 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@...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