* [Qemu-devel] [PATCH] linux-user: fix fork()
@ 2017-02-16 17:37 Laurent Vivier
2017-02-16 17:42 ` Peter Maydell
2017-02-17 22:58 ` Philippe Mathieu-Daudé
0 siblings, 2 replies; 3+ messages in thread
From: Laurent Vivier @ 2017-02-16 17:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Riku Voipio, Laurent Vivier
Since commit 5ea2fc8 ("linux-user: Sanity check clone flags"),
trying to run fork() fails with old distro on some architectures.
This is the case with HP-PA and Debian 5 (Lenny).
It fails on:
if ((flags & CSIGNAL) != TARGET_SIGCHLD) {
return -TARGET_EINVAL;
}
because flags is 17, whereas on HP-PA, SIGCHLD is 18.
17 is the SIGCHLD value of my host (x86_64).
It appears that for TARGET_NR_fork and TARGET_NR_vfork, QEMU calls
do_fork() with SIGCHLD instead of TARGET_SIGCHLD.
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/syscall.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f569f82..4d85355 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7680,7 +7680,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
break;
#ifdef TARGET_NR_fork
case TARGET_NR_fork:
- ret = get_errno(do_fork(cpu_env, SIGCHLD, 0, 0, 0, 0));
+ ret = get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0));
break;
#endif
#ifdef TARGET_NR_waitpid
@@ -10490,7 +10490,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#endif
#ifdef TARGET_NR_vfork
case TARGET_NR_vfork:
- ret = get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | SIGCHLD,
+ ret = get_errno(do_fork(cpu_env,
+ CLONE_VFORK | CLONE_VM | TARGET_SIGCHLD,
0, 0, 0, 0));
break;
#endif
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: fix fork()
2017-02-16 17:37 [Qemu-devel] [PATCH] linux-user: fix fork() Laurent Vivier
@ 2017-02-16 17:42 ` Peter Maydell
2017-02-17 22:58 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2017-02-16 17:42 UTC (permalink / raw)
To: Laurent Vivier; +Cc: QEMU Developers, Riku Voipio
On 16 February 2017 at 17:37, Laurent Vivier <laurent@vivier.eu> wrote:
> Since commit 5ea2fc8 ("linux-user: Sanity check clone flags"),
> trying to run fork() fails with old distro on some architectures.
>
> This is the case with HP-PA and Debian 5 (Lenny).
>
> It fails on:
>
> if ((flags & CSIGNAL) != TARGET_SIGCHLD) {
> return -TARGET_EINVAL;
> }
>
> because flags is 17, whereas on HP-PA, SIGCHLD is 18.
> 17 is the SIGCHLD value of my host (x86_64).
>
> It appears that for TARGET_NR_fork and TARGET_NR_vfork, QEMU calls
> do_fork() with SIGCHLD instead of TARGET_SIGCHLD.
>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
> linux-user/syscall.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index f569f82..4d85355 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -7680,7 +7680,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> break;
> #ifdef TARGET_NR_fork
> case TARGET_NR_fork:
> - ret = get_errno(do_fork(cpu_env, SIGCHLD, 0, 0, 0, 0));
> + ret = get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0));
> break;
> #endif
> #ifdef TARGET_NR_waitpid
> @@ -10490,7 +10490,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> #endif
> #ifdef TARGET_NR_vfork
> case TARGET_NR_vfork:
> - ret = get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | SIGCHLD,
> + ret = get_errno(do_fork(cpu_env,
> + CLONE_VFORK | CLONE_VM | TARGET_SIGCHLD,
> 0, 0, 0, 0));
> break;
> #endif
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: fix fork()
2017-02-16 17:37 [Qemu-devel] [PATCH] linux-user: fix fork() Laurent Vivier
2017-02-16 17:42 ` Peter Maydell
@ 2017-02-17 22:58 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-02-17 22:58 UTC (permalink / raw)
To: Laurent Vivier; +Cc: qemu-devel, Peter Maydell, Riku Voipio
On 02/16/2017 02:37 PM, Laurent Vivier wrote:
> Since commit 5ea2fc8 ("linux-user: Sanity check clone flags"),
> trying to run fork() fails with old distro on some architectures.
>
> This is the case with HP-PA and Debian 5 (Lenny).
>
> It fails on:
>
> if ((flags & CSIGNAL) != TARGET_SIGCHLD) {
> return -TARGET_EINVAL;
> }
>
> because flags is 17, whereas on HP-PA, SIGCHLD is 18.
> 17 is the SIGCHLD value of my host (x86_64).
>
> It appears that for TARGET_NR_fork and TARGET_NR_vfork, QEMU calls
> do_fork() with SIGCHLD instead of TARGET_SIGCHLD.
>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> linux-user/syscall.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index f569f82..4d85355 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -7680,7 +7680,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> break;
> #ifdef TARGET_NR_fork
> case TARGET_NR_fork:
> - ret = get_errno(do_fork(cpu_env, SIGCHLD, 0, 0, 0, 0));
> + ret = get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0));
> break;
> #endif
> #ifdef TARGET_NR_waitpid
> @@ -10490,7 +10490,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> #endif
> #ifdef TARGET_NR_vfork
> case TARGET_NR_vfork:
> - ret = get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | SIGCHLD,
> + ret = get_errno(do_fork(cpu_env,
> + CLONE_VFORK | CLONE_VM | TARGET_SIGCHLD,
> 0, 0, 0, 0));
> break;
> #endif
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-02-17 22:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-16 17:37 [Qemu-devel] [PATCH] linux-user: fix fork() Laurent Vivier
2017-02-16 17:42 ` Peter Maydell
2017-02-17 22:58 ` Philippe Mathieu-Daudé
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.