From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6J9X-0002Pg-BB for qemu-devel@nongnu.org; Fri, 27 May 2016 10:54:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6J9V-0005nc-As for qemu-devel@nongnu.org; Fri, 27 May 2016 10:54:18 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:57388) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6J9V-0005mS-47 for qemu-devel@nongnu.org; Fri, 27 May 2016 10:54:17 -0400 From: Peter Maydell Date: Fri, 27 May 2016 15:51:54 +0100 Message-Id: <1464360721-14359-13-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1464360721-14359-1-git-send-email-peter.maydell@linaro.org> References: <1464360721-14359-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH v2 12/19] linux-user: Block signals during sigaction() handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: patches@linaro.org, Riku Voipio , Timothy Edward Baldwin From: Timothy E Baldwin Block signals while emulating sigaction. This is a non-interruptible syscall, and using block_signals() avoids races where the host signal handler is invoked and tries to examine the signal handler data structures while we are updating them. Signed-off-by: Timothy Edward Baldwin Message-id: 1441497448-32489-29-git-send-email-T.E.Baldwin99@members.leeds.ac.uk [PMM: expanded commit message] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- linux-user/signal.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index f489028..b21d6bf 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -640,7 +640,7 @@ out: return ret; } -/* do_sigaction() return host values and errnos */ +/* do_sigaction() return target values and host errnos */ int do_sigaction(int sig, const struct target_sigaction *act, struct target_sigaction *oact) { @@ -649,8 +649,14 @@ int do_sigaction(int sig, const struct target_sigaction *act, int host_sig; int ret = 0; - if (sig < 1 || sig > TARGET_NSIG || sig == TARGET_SIGKILL || sig == TARGET_SIGSTOP) - return -EINVAL; + if (sig < 1 || sig > TARGET_NSIG || sig == TARGET_SIGKILL || sig == TARGET_SIGSTOP) { + return -TARGET_EINVAL; + } + + if (block_signals()) { + return -TARGET_ERESTARTSYS; + } + k = &sigact_table[sig - 1]; if (oact) { __put_user(k->_sa_handler, &oact->_sa_handler); -- 1.9.1