From patchwork Thu Sep 22 12:13:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 673363 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 3sfxBJ1GtGz9t1b for ; Thu, 22 Sep 2016 22:48:40 +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=j/e9ZIpa; dkim-atps=neutral Received: from localhost ([::1]:43282 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn3Qb-00070z-Jr for incoming@patchwork.ozlabs.org; Thu, 22 Sep 2016 08:48:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53390) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn2uY-0000M6-Cq for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:15:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn2uU-0006mJ-C1 for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:15:30 -0400 Received: from mail-lf0-f49.google.com ([209.85.215.49]:35533) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn2uU-0006m1-4H for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:15:26 -0400 Received: by mail-lf0-f49.google.com with SMTP id l131so65702850lfl.2 for ; Thu, 22 Sep 2016 05:15:26 -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=MBmfDXPeKJbp69SLNFfg/uEcQ0oYoIma7tI5mG2dHGE=; b=j/e9ZIpafjyn7/wA+GmSEU6gCKZ+x75Auy2N7H453/EQS5N2qmg0Nm7WT3VRfR2zDL LCsf/Lc6j5QtHzaPVtoFHhxG1vvYh8zY6vMcXrpxcpxatxVVgT6TTdsW7JdtN1Z6T+E9 z1SHFAgBu6+PGDCVh9BJr8jvKYRft3lg05u/g= 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=MBmfDXPeKJbp69SLNFfg/uEcQ0oYoIma7tI5mG2dHGE=; b=PZIyCskvDtVAoGkYIxmeS3MS5VPS1j7VZbFFxlPfuETtfvI51amiM1J6b/MUuN9N1c VFIiAekcUbeP6FSoLZhq6slD4+/VD32QmUJoFoERlnuYsFlZDrOXhx8qXPaKGGc+Y2Ws 96r6dwprIjbffBUK5kFPgFoaPVoqzwhdamKCfO1yuBi1IhoFq4AwmRV3PR2+0wD8q/Ue n5Vuaj4x+xhEgHeEAYpO9iftx9yWAqHPOIuncX8oNK0PaZN4laQ3k6deN8pxj9169U6/ QeHQCEvjDWxDRUTd4JC+8x8lihNdIl62Nxw3XbUAjpqQCoRpTbSz4Jx6WtDzwT6u7/oj i2Og== X-Gm-Message-State: AE9vXwNupk24dAQABCb7Qo78zwGJJpKAWiYFjR6iGpLchWxvXO8abCgchlZvGvbYabDIYCww X-Received: by 10.46.32.224 with SMTP id g93mr732620lji.38.1474546465315; Thu, 22 Sep 2016 05:14:25 -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.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Sep 2016 05:14:23 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Thu, 22 Sep 2016 15:13:45 +0300 Message-Id: <45eafb4d32ced9ff1dcb3800c89f8beaf47b61cc.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.49 Subject: [Qemu-devel] [PULL 25/26] linux-user: Fix incorrect offset of tuc_stack in ARM do_sigframe_return_v2 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 , Timothy E Baldwin Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Timothy E Baldwin struct target_ucontext_v2 is not at the begining of the signal frame, therefore do_sigaltstack was being passed bogus arguments. As the offset depends on the type of signal frame fixed by passing in the beginning of the context from do_sigreturn_v2 and do_rt_sigreturn_v2. Suggested-by: Peter Maydell Reviewed-by: Peter Maydell Signed-off-by: Timothy Edward Baldwin Signed-off-by: Riku Voipio --- linux-user/signal.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index 900ee35..e4eea69 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -2071,7 +2071,8 @@ static abi_ulong *restore_sigframe_v2_iwmmxt(CPUARMState *env, return (abi_ulong*)(iwmmxtframe + 1); } -static int do_sigframe_return_v2(CPUARMState *env, target_ulong frame_addr, +static int do_sigframe_return_v2(CPUARMState *env, + target_ulong context_addr, struct target_ucontext_v2 *uc) { sigset_t host_set; @@ -2098,8 +2099,11 @@ static int do_sigframe_return_v2(CPUARMState *env, target_ulong frame_addr, } } - if (do_sigaltstack(frame_addr + offsetof(struct target_ucontext_v2, tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT) + if (do_sigaltstack(context_addr + + offsetof(struct target_ucontext_v2, tuc_stack), + 0, get_sp_from_cpustate(env)) == -EFAULT) { return 1; + } #if 0 /* Send SIGTRAP if we're single-stepping */ @@ -2130,7 +2134,10 @@ static long do_sigreturn_v2(CPUARMState *env) goto badframe; } - if (do_sigframe_return_v2(env, frame_addr, &frame->uc)) { + if (do_sigframe_return_v2(env, + frame_addr + + offsetof(struct sigframe_v2, uc), + &frame->uc)) { goto badframe; } @@ -2217,7 +2224,10 @@ static long do_rt_sigreturn_v2(CPUARMState *env) goto badframe; } - if (do_sigframe_return_v2(env, frame_addr, &frame->uc)) { + if (do_sigframe_return_v2(env, + frame_addr + + offsetof(struct rt_sigframe_v2, uc), + &frame->uc)) { goto badframe; }