From patchwork Thu Sep 22 12:13:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9345203 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 114E6607D0 for ; Thu, 22 Sep 2016 12:33:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 011A02AA64 for ; Thu, 22 Sep 2016 12:33:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E81822AA66; Thu, 22 Sep 2016 12:33:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 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 mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4F6D92AA65 for ; Thu, 22 Sep 2016 12:33:22 +0000 (UTC) Received: from localhost ([::1]:43107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn3Bp-0008GK-Ap for patchwork-qemu-devel@patchwork.kernel.org; Thu, 22 Sep 2016 08:33:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn2uQ-0000BQ-84 for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:15:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn2uO-0006iQ-2b for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:15:21 -0400 Received: from mail-lf0-f53.google.com ([209.85.215.53]:33277) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn2uN-0006hz-N4 for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:15:20 -0400 Received: by mail-lf0-f53.google.com with SMTP id b71so38938135lfg.0 for ; Thu, 22 Sep 2016 05:15:19 -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=PvEd/J52twpeVPXZgp+rGDpmIUm2Nm74RzSwVkeR6UQ=; b=CmvSj1aNJPqerVz85FbynYiLGtU8iLbDLdswqSABjxHDB/QQDW0xe5l8mlj3CQj0Js VtcVSvf8WRozxBdGiO2Y162EO8CDqqa/aeolJLzQoa6B3uEvhdCO9tEhGs02cuBIWVT2 nDrVLjsyfjq7KV70iE7JSALuzCweWFKoNLpN0= 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=PvEd/J52twpeVPXZgp+rGDpmIUm2Nm74RzSwVkeR6UQ=; b=SQyh04EtLxduWRa8gaVsqiHIrLyKGpJjIKM4bIwd0dY8shkjJSWsMovNq7RPkJHl2y gAzsyWYuui4+g3Kh1PYnjacaf0Luaal8o7Lc1+JSFOouFo1XwIRYhTSm0qEf4kc2FYuL FLQ5e1pjDI+XiKpAK8U/qz6fOzUks0hZQAevOmfS0JM0VEJL6wnpyG+3j7xiXw952zLQ jqyEcSV6V16/g44oHjxHNRyC98BIARPc3WjUXruKw3QdQElrXN8s0A7ffIMDQuOAT9wN 9w+IOymgNVfq/6V3hqxI4EC6hs8UbJ069MPoniNW5TQ+irlpgV2SYnElutg3CNs/bXLf zpxA== X-Gm-Message-State: AE9vXwOUibV5Y5VPtkk2k5j1edlGgVeUSk+Z42SoUIM1N4qb7+gpKVjlmsWz/MjqKtInjYPe X-Received: by 10.25.23.68 with SMTP id n65mr797242lfi.150.1474546458974; Thu, 22 Sep 2016 05:14:18 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id u14sm294378lja.11.2016.09.22.05.14.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Sep 2016 05:14:17 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Thu, 22 Sep 2016 15:13:40 +0300 Message-Id: <28298c912e2c379f2b7767b351beeb77f001f27f.1474546244.git.riku.voipio@linaro.org> 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] [fuzzy] X-Received-From: 209.85.215.53 Subject: [Qemu-devel] [PULL 20/26] linux-user: ARM: Give SIGSEGV if signal frame setup fails 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: Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Maydell The 32-bit ARM signal frame setup code was just bailing out on error returns from lock_user_struct calls, without generating the SIGSEGV that should happen here. Wire up error return codes to call force_sigsegv(). Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/signal.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index 892b527..4383696 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -512,8 +512,7 @@ void signal_init(void) } } -#if !((defined(TARGET_ARM) && !defined(TARGET_AARCH64)) || \ - defined(TARGET_X86_64) || defined(TARGET_UNICORE32)) +#if !(defined(TARGET_X86_64) || defined(TARGET_UNICORE32)) /* Force a SIGSEGV if we couldn't write to memory trying to set * up the signal frame. oldsig is the signal we were trying to handle @@ -1789,7 +1788,7 @@ static void setup_frame_v1(int usig, struct target_sigaction *ka, trace_user_setup_frame(regs, frame_addr); if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { - return; + goto sigsegv; } setup_sigcontext(&frame->sc, regs, set->sig[0]); @@ -1802,6 +1801,9 @@ static void setup_frame_v1(int usig, struct target_sigaction *ka, frame_addr + offsetof(struct sigframe_v1, retcode)); unlock_user_struct(frame, frame_addr, 1); + return; +sigsegv: + force_sigsegv(usig); } static void setup_frame_v2(int usig, struct target_sigaction *ka, @@ -1812,7 +1814,7 @@ static void setup_frame_v2(int usig, struct target_sigaction *ka, trace_user_setup_frame(regs, frame_addr); if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { - return; + goto sigsegv; } setup_sigframe_v2(&frame->uc, set, regs); @@ -1821,6 +1823,9 @@ static void setup_frame_v2(int usig, struct target_sigaction *ka, frame_addr + offsetof(struct sigframe_v2, retcode)); unlock_user_struct(frame, frame_addr, 1); + return; +sigsegv: + force_sigsegv(usig); } static void setup_frame(int usig, struct target_sigaction *ka, @@ -1846,7 +1851,7 @@ static void setup_rt_frame_v1(int usig, struct target_sigaction *ka, trace_user_setup_rt_frame(env, frame_addr); if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { - return /* 1 */; + goto sigsegv; } info_addr = frame_addr + offsetof(struct rt_sigframe_v1, info); @@ -1876,6 +1881,9 @@ static void setup_rt_frame_v1(int usig, struct target_sigaction *ka, env->regs[2] = uc_addr; unlock_user_struct(frame, frame_addr, 1); + return; +sigsegv: + force_sigsegv(usig); } static void setup_rt_frame_v2(int usig, struct target_sigaction *ka, @@ -1888,7 +1896,7 @@ static void setup_rt_frame_v2(int usig, struct target_sigaction *ka, trace_user_setup_rt_frame(env, frame_addr); if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { - return /* 1 */; + goto sigsegv; } info_addr = frame_addr + offsetof(struct rt_sigframe_v2, info); @@ -1904,6 +1912,9 @@ static void setup_rt_frame_v2(int usig, struct target_sigaction *ka, env->regs[2] = uc_addr; unlock_user_struct(frame, frame_addr, 1); + return; +sigsegv: + force_sigsegv(usig); } static void setup_rt_frame(int usig, struct target_sigaction *ka,