From patchwork Mon Jun 26 09:25:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 9808959 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 3E46060209 for ; Mon, 26 Jun 2017 09:26:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D69A2625B for ; Mon, 26 Jun 2017 09:26:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 300D22847D; Mon, 26 Jun 2017 09:26:02 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A25662625B for ; Mon, 26 Jun 2017 09:26:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=66aNKQWB12fkJYnizJcGC8ZlHrQh5OM98vVsFkEIF4E=; b=YUv O7+3KYOMG4oFUhDvO+2S+S7h4+yGjCV4Rx0oEW3rIjSk5MZc9b1H6mdMBG2tBQYFcINKG5V+3ZQkf AWlDp1vBtNh6MOuXzclYMMoCXNr/9uL/ra7lQfNpNsu3oa2GYfiQFX/Rs4Ym8qYorkJU17VUaeQlh YNekzaJB0fvuQNzHrhjtWKl+hodrVp3ij00BBL2OZhX5UUUlwAKOjFBXQFb57fCAd8IQDmlE5l+fi ot+iG20IRwd4lmcs5nY+qA36CQw30cXbFk8tECwNe5MWYmXZWNGne2NCiqWrRNhE9nALnz9RMR8Vf hcHerCGOUbHFCCIflkzB4GDTHzP12lw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dPQHP-000061-4M; Mon, 26 Jun 2017 09:25:59 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dPQHM-0008Sc-Ev for linux-arm-kernel@lists.infradead.org; Mon, 26 Jun 2017 09:25:58 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5034E80D; Mon, 26 Jun 2017 02:25:36 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B1BAD3F587; Mon, 26 Jun 2017 02:25:35 -0700 (PDT) From: Dave Martin To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH v2] arm64: signal: Make parse_user_sigframe() independent of rt_sigframe layout Date: Mon, 26 Jun 2017 10:25:24 +0100 Message-Id: <1498469124-10308-1-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170626_022556_539699_952650C8 X-CRM114-Status: GOOD ( 12.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Yury Norov MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP ILP32 support uses the same struct sigcontext as the native ABI (i.e., LP64), but a different layout for the rest of the signal frame (since siginfo_t and ucontext_t are both ABI-dependent). Since the purpose of parse_user_sigframe() is really to parse sigcontext and not the whole signal frame, the function does not need to depend on the layout of rt_sigframe -- the only purpose of the rt_sigframe pointer is for use as a base to measure the signal frame size. So, this patch renames the function to make it clear that only the sigcontext is really being parsed, and makes the sigframe base pointer generic. A macro is defined to provide a suitable duck-typed interface that can be used with both sigframe definitions. Suggested-by: Yury Norov Signed-off-by: Dave Martin --- arch/arm64/kernel/signal.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index e47cd3a..f040893 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -223,16 +223,16 @@ struct user_ctxs { struct fpsimd_context __user *fpsimd; }; -static int parse_user_sigframe(struct user_ctxs *user, - struct rt_sigframe __user *sf) +static int __parse_user_sigcontext(struct user_ctxs *user, + struct sigcontext __user const *sc, + void __user const *sigframe_base) { - struct sigcontext __user *const sc = &sf->uc.uc_mcontext; struct _aarch64_ctx __user *head; char __user *base = (char __user *)&sc->__reserved; size_t offset = 0; size_t limit = sizeof(sc->__reserved); bool have_extra_context = false; - char const __user *const sfp = (char const __user *)sf; + char const __user *const sfp = (char const __user *)sigframe_base; user->fpsimd = NULL; @@ -366,6 +366,9 @@ static int parse_user_sigframe(struct user_ctxs *user, return -EINVAL; } +#define parse_user_sigcontext(user, sf) \ + __parse_user_sigcontext(user, &(sf)->uc.uc_mcontext, sf) + static int restore_sigframe(struct pt_regs *regs, struct rt_sigframe __user *sf) { @@ -391,7 +394,7 @@ static int restore_sigframe(struct pt_regs *regs, err |= !valid_user_regs(®s->user_regs, current); if (err == 0) - err = parse_user_sigframe(&user, sf); + err = parse_user_sigcontext(&user, sf); if (err == 0) err = restore_fpsimd_context(user.fpsimd);