linux-user: fix fork()
PATCH 1/1 linux-user: fix fork()
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.
--- linux-user/syscall.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
linux-user/syscall.c +3 -2
@@ -7680,7 +7680,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ;#ifdef TARGET_NR_forkcase 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_vforkcase 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
Signature · 1 line
2.9.3
Quoted 36 lines · 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_forkandTARGET_NR_vfork, QEMU callsdo_fork()with SIGCHLD instead ofTARGET_SIGCHLD.Signed-off-by Laurent Vivier <[email protected]>--- linux-user/syscall.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)linux-user/syscall.c +1
-1@@ -7680,7 +7680,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ;#ifdef TARGET_NR_forkcase 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
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 10497
Quoted 9 lines
linux-user/syscall.c +2
-1@@ -10490,7 +10490,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_vforkcase 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
thanks
-- PMM
Quoted 11 lines · 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; }
Quoted 7 lines
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_forkandTARGET_NR_vfork, QEMU callsdo_fork()with SIGCHLD instead ofTARGET_SIGCHLD.Signed-off-by Laurent Vivier <[email protected]>
Quoted 28 lines
--- linux-user/syscall.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)linux-user/syscall.c +3
-2@@ -7680,7 +7680,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ;#ifdef TARGET_NR_forkcase 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_vforkcase 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