From patchwork Wed Jun 8 13:29:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 632277 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 3rPqgm1pg6z9sxS for ; Wed, 8 Jun 2016 23:55:00 +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=YzAZwGev; dkim-atps=neutral Received: from localhost ([::1]:57131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdwf-0001ic-VN for incoming@patchwork.ozlabs.org; Wed, 08 Jun 2016 09:54:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZQ-0004JF-Pj for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:30:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAdZL-0005lL-CN for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:30:55 -0400 Received: from mail-lf0-x22a.google.com ([2a00:1450:4010:c07::22a]:35593) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZL-0005kh-4Q for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:30:51 -0400 Received: by mail-lf0-x22a.google.com with SMTP id u74so5849829lff.2 for ; Wed, 08 Jun 2016 06:30:48 -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=03HHSO8VHdGMzvEATJtkdG0p3zZvo4X2UOWnAk4tq8Y=; b=YzAZwGevQTPbtVOA3jvl2r4Z1HKNVgud1WiqXAdpeGYbi/x53mvpqaFDMA4FKArxRe cQiRLPb8c9sJa4HMXvvcs3wHQMWqKyQ/BNuBMqgDKw81RDOMYoUTA+fIl+Gvg8icjFmV PowUYzkGlICDIySVVRhHz8ThXPZzH8FYy2JW0= 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=03HHSO8VHdGMzvEATJtkdG0p3zZvo4X2UOWnAk4tq8Y=; b=mJ9O+jT6m7tb8SD7YbwBWw/Um2QqqAfYEN3GZXFx1JlqmYnTEfqPVv3KKy48Msa0gr w3jgL22Qh03YA2wG3KZsp1Z8Thdac5hfvmttswa/pk5NhFkQIRiLMWtLgVRpAcrexVvb iu/FdBnRIyfltZPZeYRbeYq7/zJFYiqfRmj0CAXwmnZLetP/rjwkvz/NOO1HJPZHgYMK 1efGwEOFGZsET8ZsOSQ3JQRAs8uBHwEOJbMjz+fV7a+9C1LAxVf3QEeHrnQGql7PtmBu JtJZ3gPqfeghNzKUtkN9mhUCJ07qRVaSEJDd/Gq+sa9X64T+lt/003Vh0OCXhWNYjzHU zR7Q== X-Gm-Message-State: ALyK8tIpbZz00XlpsS0QjJqwXA/bx1i0UghFvoq9h/Pe6e/hP9iDbWUdIjwvcsTjtGYPEBpU X-Received: by 10.25.43.70 with SMTP id r67mr3764517lfr.80.1465392648240; Wed, 08 Jun 2016 06:30:48 -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.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jun 2016 06:30:47 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 8 Jun 2016 16:29:59 +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::22a Subject: [Qemu-devel] [PULL 18/44] linux-user: pause() should not pause if signal pending 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 Fix races between signal handling and the pause syscall by reimplementing it using block_signals() and sigsuspend(). (Using safe_syscall(pause) would also work, except that the pause syscall doesn't exist on all architectures.) Signed-off-by: Timothy Edward Baldwin Message-id: 1441497448-32489-28-git-send-email-T.E.Baldwin99@members.leeds.ac.uk [PMM: tweaked commit message] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 639b328..aa5517c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7059,7 +7059,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_pause /* not on alpha */ case TARGET_NR_pause: - ret = get_errno(pause()); + if (!block_signals()) { + sigsuspend(&((TaskState *)cpu->opaque)->signal_mask); + } + ret = -TARGET_EINTR; break; #endif #ifdef TARGET_NR_utime