All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org, laurent@vivier.eu,
	mark.cave-ayland@ilande.co.uk, atar4qemu@gmail.com
Subject: Re: [Qemu-devel] [PATCH 1/4] linux-user: Disallow setting newsp for fork
Date: Tue, 31 Jul 2018 11:54:44 +0100	[thread overview]
Message-ID: <87va8v8ykr.fsf@linaro.org> (raw)
In-Reply-To: <20180730201553.32423-2-richard.henderson@linaro.org>


Richard Henderson <richard.henderson@linaro.org> writes:

> Or really, just clone devolving into fork.  This should not ever happen
> in practice.  We do want to reserve calling cpu_clone_regs for the case
> in which we are actually performing a clone.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  linux-user/syscall.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index dfc851cc35..5bf8d13de7 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -6502,10 +6502,14 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
>          pthread_mutex_destroy(&info.mutex);
>          pthread_mutex_unlock(&clone_lock);
>      } else {
> -        /* if no CLONE_VM, we consider it is a fork */
> +        /* If no CLONE_VM, we consider it is a fork.  */
>          if (flags & CLONE_INVALID_FORK_FLAGS) {
>              return -TARGET_EINVAL;
>          }
> +        /* As a fork, setting a new sp does not make sense.  */
> +        if (newsp) {
> +            return -TARGET_EINVAL;
> +        }
>
>          /* We can't support custom termination signals */
>          if ((flags & CSIGNAL) != TARGET_SIGCHLD) {
> @@ -6520,7 +6524,6 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
>          ret = fork();
>          if (ret == 0) {
>              /* Child Process.  */
> -            cpu_clone_regs(env, newsp);
>              fork_end(1);
>              /* There is a race condition here.  The parent process could
>                 theoretically read the TID in the child process before the child


--
Alex Bennée

  reply	other threads:[~2018-07-31 10:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-30 20:15 [Qemu-devel] [PATCH 0/3] linux-user/sparc: Fixes for clone Richard Henderson
2018-07-30 20:15 ` [Qemu-devel] [PATCH 1/4] linux-user: Disallow setting newsp for fork Richard Henderson
2018-07-31 10:54   ` Alex Bennée [this message]
2018-07-30 20:15 ` [Qemu-devel] [PATCH 2/4] linux-user: Pass the parent env to cpu_clone_regs Richard Henderson
2018-07-31 10:45   ` Alex Bennée
2018-07-30 20:15 ` [Qemu-devel] [PATCH 3/4] linux-user/sparc: Fix cpu_clone_regs Richard Henderson
2018-07-30 20:15 ` [Qemu-devel] [PATCH 4/4] linux-user/sparc: Flush register windows before clone Richard Henderson
2018-07-31  7:09 ` [Qemu-devel] [PATCH 0/3] linux-user/sparc: Fixes for clone Alex Bennée

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=87va8v8ykr.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=atar4qemu@gmail.com \
    --cc=laurent@vivier.eu \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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.