From 5bfce0b74fbd5d53089bb866919d685c47edad9e Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Thu, 25 Jul 2019 14:16:45 +0100 Subject: 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 Reviewed-by: Richard Henderson Tested-by: Laurent Vivier Reviewed-by: Laurent Vivier Message-Id: <20190725131645.19501-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/qemu.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'linux-user/qemu.h') diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 4258e4162d..aac0334627 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -151,6 +151,8 @@ typedef struct TaskState { */ int signal_pending; + /* This thread's sigaltstack, if it has one */ + struct target_sigaltstack sigaltstack_used; } __attribute__((aligned(16))) TaskState; extern char *exec_path; -- cgit 1.4.1