From patchwork Wed Jun 8 13:29:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 632284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rPqsn5NNHz9sBf for ; Thu, 9 Jun 2016 00:03:41 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=CLr6h18U; dkim-atps=neutral Received: from localhost ([::1]:57183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAe55-0001Q4-L1 for incoming@patchwork.ozlabs.org; Wed, 08 Jun 2016 10:03:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZO-0004HK-GE for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:30:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAdZK-0005lA-Di for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:30:51 -0400 Received: from mail-lf0-x22c.google.com ([2a00:1450:4010:c07::22c]:33878) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZK-0005kT-5W for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:30:50 -0400 Received: by mail-lf0-x22c.google.com with SMTP id s186so5871183lfs.1 for ; Wed, 08 Jun 2016 06:30:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ytTbCJHxjq2YU6XCFEdrUxLSqaavYSwYXcyu8F7mS10=; b=CLr6h18UGAJn4mQ202fuueKSDx9aCxNEYhCw3Wlx+UeuMuA2LgEt1I6w3FutKCeyhF 1BBGpD+YEPE3JzSFlfA3SHF9n6Zj8OVqy2DWngCqSnk3QktwjoYXP9zEGfqIv4WbMAch O/0PnfYykKtc2uARBCjaVOQawZPsu2EDdTjT8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ytTbCJHxjq2YU6XCFEdrUxLSqaavYSwYXcyu8F7mS10=; b=B1eYApsmFONVLWNDm6WhvhLpU53yRPXn3sVrWPBf1LtKwen8F9KUNN6vJMYs6m6Js8 n++61fiOGFlPrykBs3KH/ReC5WQCuiwkhG6bKjBemuA6Pi4xUkBg7ZxsLfsVtew4wfOe PQCgZoxxViGrUJBsVEOCftuTgsUNyx9584J2GzMLCx8+7sBJG2DRGPMaDG50gRRacW+0 8zBOwVdfIhiXa8dmu3ysFsv4bJ0r7uRJnbm8p8K1OEkX+piDDjZOy0FpDJIsoNwu+GBV HzsLHNgErKwbEjoUtOo8EwgnoEheBvfzjahGg+tg4A4+1JVkWOvvAcB7b/RLuhRSWTzE EsFg== X-Gm-Message-State: ALyK8tK8OrjDgAeLmu5QXjz55kxnnsEwoqASU0F7vonP2ckhsWfVSaPxZ6vcEOI/z1VeYFW2 X-Received: by 10.25.73.137 with SMTP id w131mr3829361lfa.22.1465392647187; Wed, 08 Jun 2016 06:30:47 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id 2sm139854lja.37.2016.06.08.06.30.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jun 2016 06:30:46 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 8 Jun 2016 16:29:58 +0300 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::22c Subject: [Qemu-devel] [PULL 17/44] linux-user: Block signals during sigaction() handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Timothy E Baldwin Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Signed-off-by: Riku Voipio --- 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);