All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Dike <jdike@addtoit.com>
To: John Reiser <jreiser@BitWagon.com>
Cc: uml-devel <user-mode-linux-devel@lists.sourceforge.net>
Subject: Re: [uml-devel] should there be os_clone() analogous to os_getpid() ?
Date: Mon, 10 Dec 2007 12:09:25 -0500	[thread overview]
Message-ID: <20071210170925.GA7582@c2.user-mode-linux.org> (raw)
In-Reply-To: <475C56F9.8040902@BitWagon.com>

On Sun, Dec 09, 2007 at 12:58:33PM -0800, John Reiser wrote:
> The actual bug is unnecessary complexity, which slows down development.

We live in an imperfect world.  I'd like to be able to call getpid and
know that I'm always going to get the right answer.  However, I don't
want to have to debug the cases where it doesn't, so the current code
seems like the best arrangement.

> > Where do we care about how clone translates into a system call?
> 
> check_sysemu() in arch/um/os/start_up.c cares that the actual sequence of
> system calls is:
> 	__NR_clone
> 	__NR_getpid  presumably from ptrace_child() calling os_getpid()
> However, when using the clone() from glibc then the actual sequence is:
> 	__NR_clone
> 	[random system calls from glibc]
> 	__NR_getpid  from ptrace_child calling os_getpid()

No, it doesn't.  The only thing is cares about is that the system call
following the kill(pid, SIGSTOP) in ptrace_child is a getpid.  It
cares not at all about the details of the clone.

> > These guys all just want a new process - they don't care how it
> > happens.
> 
> Not so.  userspace() in arch/um/os/skas/process.c relies on
> stack location and signal delivery that is mediated by the combination
> of clone() and ptrace().  userspace() also depends on the carry-over
> of signal handlers, particularly the SIGSEGV ==> SIGUSR1 trampoline.

No, it doesn't.  userspace_tramp sets up its own handlers after the
clone - it doesn't rely on inheriting them, and in fact it can't,
since the stub's SEGV handler makes no sense in the UML kernel.  It
may inherit a signal mask, but as far as I'm concerned, that's a bug.
As far as a stack location goes, that's part of the interface, so
that's just part of creating a new process.

> > Is something in here causing valgrind some trouble?
> 
> Yes.  It is not simple for the current valgrind to "let go" of
> a new child.  [The current valgrind knows how to "let go" only at
> execve().]  The internal logic of valgrind requires that the creation
> of the new process [implemented by clone(,, ~CLONE_VM & ( ),,)] must be done
> with all signals blocked.  Therefore the child side must do a
> sigprocmask() somewhere to unblock, and the uml ptrace()ing is not
> expecting this.

I don't see how this can be causing problems.  If the child side of
valgrind makes some extra system calls before allowing the child to
run, I don't see UML caring about that at all.

Any system call tracing is done only after seeing the child hit itself
with a signal.  Any extra system calls in libc's clone or the child
side valgrind are long over by this point.

				Jeff

-- 
Work email - jdike at linux dot intel dot com

-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

      reply	other threads:[~2007-12-10 17:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-09  4:24 [uml-devel] should there be os_clone() analogous to os_getpid() ? John Reiser
2007-12-09 15:10 ` Jeff Dike
2007-12-09 20:58   ` John Reiser
2007-12-10 17:09     ` Jeff Dike [this message]

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=20071210170925.GA7582@c2.user-mode-linux.org \
    --to=jdike@addtoit.com \
    --cc=jreiser@BitWagon.com \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /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.