aboutsummaryrefslogtreecommitdiff
path: root/linux-user/main.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-07-25 14:16:45 +0100
committerLaurent Vivier <laurent@vivier.eu>2019-07-26 19:24:33 +0200
commit5bfce0b74fbd5d53089bb866919d685c47edad9e (patch)
tree7b352053272100d776034988ef56d2241afba8db /linux-user/main.c
parentfff3159900d2b95613a9cb75fc3703e67a674729 (diff)
downloadqemu-5bfce0b74fbd5d53089bb866919d685c47edad9e.zip
qemu-5bfce0b74fbd5d53089bb866919d685c47edad9e.tar.gz
qemu-5bfce0b74fbd5d53089bb866919d685c47edad9e.tar.bz2
linux-user: Make sigaltstack stacks per-thread
The alternate signal stack set up by the sigaltstack syscall is supposed to be per-thread. We were incorrectly implementing it as process-wide. This causes problems for guest binaries that rely on this. Notably the Go runtime does, and so we were seeing crashes caused by races where two guest threads might incorrectly both execute on the same stack simultaneously. Replace the global target_sigaltstack_used with a field sigaltstack_used in the TaskState, and make all the references to the old global instead get a pointer to the TaskState and use the field. Fixes: https://bugs.launchpad.net/qemu/+bug/1696773 Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Tested-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20190725131645.19501-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'linux-user/main.c')
-rw-r--r--linux-user/main.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/linux-user/main.c b/linux-user/main.c
index a59ae94..8ffc525 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -180,6 +180,11 @@ void stop_all_tasks(void)
void init_task_state(TaskState *ts)
{
ts->used = 1;
+ ts->sigaltstack_used = (struct target_sigaltstack) {
+ .ss_sp = 0,
+ .ss_size = 0,
+ .ss_flags = TARGET_SS_DISABLE,
+ };
}
CPUArchState *cpu_copy(CPUArchState *env)