From: Nathan Lynch <ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
To: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org
Subject: Re: [PATCH user-cr 2/2] add nsexeccwp to test clone-with-pids
Date: Sun, 15 Nov 2009 17:49:44 -0600 [thread overview]
Message-ID: <1258328984.4031.21.camel@localhost.localdomain> (raw)
In-Reply-To: <20091116111249.GA32340-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
On Mon, 2009-11-16 at 05:12 -0600, Serge E. Hallyn wrote:
> Quoting Nathan Lynch (ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org):
> > On Thu, 2009-11-12 at 23:24 -0600, serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org wrote:
> > > + if (use_clone) {
> > > + int stacksize = 4*getpagesize();
> > > + void *stack = malloc(stacksize);
> > > +
> > > + if (!stack) {
> > > + perror("malloc");
> > > + return -1;
> > > + }
> > > +
> > > + printf("about to clone with %lx\n", flags);
> > > + if (chosen_pid)
> > > + printf("Will choose pid %d\n", chosen_pid);
> > > + flags |= SIGCHLD;
> > > + pid = clone_with_pids(do_child, stack, flags, &pid_set,
> > > + (void *)argv);
> >
> > The stack argument should be adjusted with the usual stack += stacksize
> > - 1 or similar, right?
>
> the clone_with_pids() helper in user-cr/clone_s390x.c (and IIRC the
> x86 one by Suka also) does this implicitly, by doing:
>
> s = child_stack;
> *--s = arg;
> *--s = fn;
> child_stack -= 16
That's setting up arguments for the function to run in the child, and
afaict that code assumes the value of child_stack is the _end_ of the
stack region. The code I quoted above is passing the beginning of the
region (the return value from malloc).
On powerpc the segfaults went away when I made the following change.
diff --git a/nsexeccwp.c b/nsexeccwp.c
index a71d9a4..92eb092 100644
--- a/nsexeccwp.c
+++ b/nsexeccwp.c
@@ -309,8 +309,8 @@ int main(int argc, char *argv[])
if (chosen_pid)
printf("Will choose pid %d\n", chosen_pid);
flags |= SIGCHLD;
- pid = clone_with_pids(do_child, stack, flags, &pid_set,
- (void *)argv);
+ pid = clone_with_pids(do_child, stack + stacksize - 1,
+ flags, &pid_set, (void *)argv);
next prev parent reply other threads:[~2009-11-15 23:49 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-13 5:24 [PATCH linux-cr] implement s390 eclone syscall serue-r/Jw6+rmf7HQT0dZR+AlfA
[not found] ` <1258089886-10034-1-git-send-email-serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-13 5:24 ` [PATCH user-cr 1/2] use v13 of eclone in clone_s390x.c serue-r/Jw6+rmf7HQT0dZR+AlfA
2009-11-13 5:24 ` [PATCH user-cr 2/2] add nsexeccwp to test clone-with-pids serue-r/Jw6+rmf7HQT0dZR+AlfA
[not found] ` <1258089886-10034-3-git-send-email-serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-13 21:08 ` Serge E. Hallyn
2009-11-15 22:45 ` Nathan Lynch
[not found] ` <1258325156.4031.3.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-11-16 11:12 ` Serge E. Hallyn
[not found] ` <20091116111249.GA32340-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-15 23:49 ` Nathan Lynch [this message]
[not found] ` <1258328984.4031.21.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-11-16 18:26 ` Serge E. Hallyn
[not found] ` <20091116182655.GA3777-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-16 23:18 ` Nathan Lynch
[not found] ` <1258413522.4031.1036.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-11-17 4:05 ` Serge E. Hallyn
2009-11-16 14:45 ` Serge E. Hallyn
2009-11-16 23:36 ` [PATCH linux-cr] implement s390 eclone syscall Nathan Lynch
[not found] ` <1258414596.4031.1058.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-11-17 4:03 ` Serge E. Hallyn
[not found] ` <20091117040321.GA32461-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-17 21:33 ` [PATCH linux-cr] fix warnings in i386 sys_eclone Nathan Lynch
-- strict thread matches above, loose matches on Subject: below --
2009-11-10 16:58 [PATCH user-cr 1/2] use Suka's v11 api Serge E. Hallyn
[not found] ` <20091110165839.GA19222-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-10 16:59 ` [PATCH user-cr 2/2] add nsexeccwp to test clone-with-pids Serge E. Hallyn
[not found] ` <20091110165922.GA19263-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-25 18:46 ` Oren Laadan
[not found] ` <4B0D7B87.5020504-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2009-11-25 19:24 ` Serge E. Hallyn
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=1258328984.4031.21.camel@localhost.localdomain \
--to=ntl-e+axbwqsrlaavxtiumwx3w@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
--cc=serue-r/Jw6+rmf7HQT0dZR+AlfA@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox