All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Nathan Lynch <nathanl-V7BBcbaFuwjMbYB6QlFGEg@public.gmane.org>
Cc: Linux Containers
	<containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>,
	sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org,
	linux-s390-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/1] implement s390 clone_with_pids syscall
Date: Wed, 11 Nov 2009 12:33:03 -0600	[thread overview]
Message-ID: <20091111183303.GA8761@us.ibm.com> (raw)
In-Reply-To: <1257958793.7132.1068.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>

Quoting Nathan Lynch (nathanl-V7BBcbaFuwjMbYB6QlFGEg@public.gmane.org):
> On Wed, 2009-11-11 at 08:46 -0600, Serge E. Hallyn wrote:
> > Quoting Nathan Lynch (nathanl-V7BBcbaFuwjMbYB6QlFGEg@public.gmane.org):
> > > 
> > > > +	parent_tid_ptr = (int *)kca.parent_tid_ptr;
> > > > +	child_tid_ptr =  (int *)kca.child_tid_ptr;
> > > > +
> > > > +	stack_size = (unsigned long)kca.child_stack_size;
> > > > +	child_stack = (unsigned long)kca.child_stack_base;
> > > > +	if (child_stack)
> > > > +		child_stack += stack_size;
> > > 
> > > Should this calculation not be of the form:
> > > child_stack = arch_dependent_alignment(child_stack + stack_size - 1)
> > > ?
> > > 
> > > Is overflow a concern?
> > > 
> > > Same questions apply to the x86 version.
> > 
> > Hmm...  if the stack isn't valid, the task will just segfault, so
> > it's not dangerous for the kernel, right?  Note that for instance
> > arch/s390/kernel/process.c:SYS_clone() doesn't check the validity
> > of the new stack pointer passed in either.
> 
> clone expects the stack argument to be the desired value of the stack
> pointer in the child.

And doesn't verify it.

> cwp is different in that the clone_args struct
> specifies the base and size of the region the child is to use for stack,
> meaning that the kernel must derive from these a sane value for the
> child's stack pointer (on every arch where the stack grows down).

And with regular clone, the kernel must expect userspace to do that
calculation correctly!  Userspace always still has to do
	base = malloc(size);
	base += size - 1;

> Your current calculation results in an unaligned SP outside of the

Can you send the patch to align it properly? 

> region that the caller has presumably allocated for the child stack.
> How is that useful behavior?

It's useful because stack_size still gets passed through copy_process
to the arch-dependent copy_thread().  That then mostly ignores the
size, but in theory we could start tracking it.

Anyway I'm not totally opposed to expecting stack_top in most
architectures, I just object to your assertion that somehow it
makes more sense for the kernel to expect userspace to do a
valid stack_top calculation than for the kernel to take the
stack_base and stack_size and comput it itself.

-serge
> 

  parent reply	other threads:[~2009-11-11 18:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-10 16:37 [PATCH 1/1] implement s390 clone_with_pids syscall Serge E. Hallyn
     [not found] ` <20091110163708.GA19122-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-11  7:27   ` Nathan Lynch
     [not found]     ` <1257924442.7132.467.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-11-11 14:46       ` Serge E. Hallyn
     [not found]         ` <20091111144600.GA6925-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-11 16:59           ` Nathan Lynch
     [not found]             ` <1257958793.7132.1068.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-11-11 18:33               ` Serge E. Hallyn [this message]
     [not found]                 ` <20091111183303.GA8761-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-11 20:19                   ` Nathan Lynch
     [not found]                     ` <1257970778.7132.1364.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-11-11 20:37                       ` Serge E. Hallyn
     [not found]                         ` <20091111203739.GD8761-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-11 21:53                           ` Nathan Lynch
2009-11-11 21:53                             ` Nathan Lynch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091111183303.GA8761@us.ibm.com \
    --to=serue-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
    --cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
    --cc=linux-s390-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=nathanl-V7BBcbaFuwjMbYB6QlFGEg@public.gmane.org \
    --cc=sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.