From patchwork Wed Jun 28 14:55:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 9814427 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 2FBE060365 for ; Wed, 28 Jun 2017 14:56:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20D4F20090 for ; Wed, 28 Jun 2017 14:56:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13C2728571; Wed, 28 Jun 2017 14:56:24 +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_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM 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 C82B522B26 for ; Wed, 28 Jun 2017 14:56:22 +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=5Pp1ojBKJjSZUjE2NuC9s2dzj/2AgfSZSTq8F74oj+I=; b=eey p3+i3SjcQOfCOq51Bp7rHNXpUXSp4lN+qlijd4+sDVTibmV3iU3mEZqBbWuY5iSqxwNVHhkea1LAs WbFJ3s8C2ZakHXECNdMeCT7hXO4lWKXZDs2tHqcPY4bxZCK3N31zi46Sx2keCJqxqlDiFdQ1HeoNH C3W1RY4RNrQiBA6fxXnLrFnOfmg+zItjvgfiLlA+J9MHCJORm5vMrAIVgzNnrQkFHjbfQfAo0TzXV vX/7ZXHSTMmc+gQhX+17dBwWJ2i7KZSpcuBAbtsk6v1oVr3GXpdAOQ8xekjsNejkW2b62bsG8Dl6s RBJzDQ6Z0+m4hQDyDd0zToA5Ocl7FoQ==; 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 1dQEOC-0003FI-1h; Wed, 28 Jun 2017 14:56:20 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dQEO9-0003Dk-4T for linux-arm-kernel@lists.infradead.org; Wed, 28 Jun 2017 14:56:18 +0000 Received: by mail-wm0-x242.google.com with SMTP id p204so7180342wmg.1 for ; Wed, 28 Jun 2017 07:55:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=atRqzq16iXvn7NkyVzfQtRWSILFMVxMorBFQ4EiXzHk=; b=JIYE3JTUNz7le85SI/3pAAY0OzmDFbKJwBHAfF5h3hAswJ1i53A0OOGt5/u1YFT8/M Tuc/u+P4XaM8OGVa0CIsnXhS6OtHPCQiD82IYq/mSCuEfspchez9bUHpz3avmQmuRSPK 2g2xSHLThw/9tyjMHdFnYL4EoVP2L6AqkaVmKPVAnEc6mxcvyZ14nMgSvBTT3CaR/AEC 4WhBqpL2/WK3+dssq8aJAP8e+Y9sJmJpT9AW6XcWXR71H7vqslB/WmvUG7T/PK0MzdjR kaJgFG6Pbf/DpwHIl13ReobduhOzGwshlZfqH8bvqmlU/T0kA4kZS2OcsqOo0cR77Moo 0hwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=atRqzq16iXvn7NkyVzfQtRWSILFMVxMorBFQ4EiXzHk=; b=tQ4GZjTI9azGCdpWFeRGTHyEokHXks1GFbkELPobGVQjGWQEbp45hVYfiVntV5T4Ss l57wQsazCdR0XPJHBNd7RqqOLeDhOiHM8BZH0yKYexC1d1+sHlk2v93p2UjtgxypmX7y 8K1G+0B18jPwEXjSaez2UNREMPac8zs02quFk+Mo9+YLE4MNR1+tFwr3kE7zKiLYExb/ UkZGhfDRHPN5s24AV/pfSMousSaxZ1NrP/y+7Rm3GWUfH6aYiy+wUw56/ZLysIV/6DhO rK8M4XvnroGIMphkAKKsSwHa6gu45gUHt5E0AuM5RVJjSmul9amhAZdKBgUOuMXQem6d k7fA== X-Gm-Message-State: AKS2vOz9G0BgNcUuws3SsUoz2SPUvJbq7yqARlqtIqiDq4eVeafpR40B LiZkLcogNK9qkA== X-Received: by 10.80.145.174 with SMTP id g43mr8082556eda.179.1498661756917; Wed, 28 Jun 2017 07:55:56 -0700 (PDT) Received: from localhost.localdomain ([91.177.84.115]) by smtp.gmail.com with ESMTPSA id j56sm2103752eda.58.2017.06.28.07.55.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2017 07:55:56 -0700 (PDT) From: Luc Van Oostenryck To: Will Deacon Subject: [PATCH] arm64: fix endianness annotation in call_undef_hook() Date: Wed, 28 Jun 2017 16:55:55 +0200 Message-Id: <20170628145555.24410-1-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.13.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170628_075617_354520_46DC14A8 X-CRM114-Status: GOOD ( 11.90 ) 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: Mark Rutland , Suzuki K Poulose , Marc Zyngier , Andre Przywara , Luc Van Oostenryck , Catalin Marinas , linux-arm-kernel@lists.infradead.org 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 Here we're reading thumb or ARM instructions, which are always stored in memory in little-endian order. These values are thus correctly converted to native order but the intermediate value should be annotated as for little-endian values. Fix this by declaring the intermediate var as __le32 or __le16. Signed-off-by: Luc Van Oostenryck --- arch/arm64/kernel/traps.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 0805b44f9..bdf390ae3 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -344,22 +344,24 @@ static int call_undef_hook(struct pt_regs *regs) if (compat_thumb_mode(regs)) { /* 16-bit Thumb instruction */ - if (get_user(instr, (u16 __user *)pc)) + __le16 instr_le; + if (get_user(instr_le, (__le16 __user *)pc)) goto exit; - instr = le16_to_cpu(instr); + instr = le16_to_cpu(instr_le); if (aarch32_insn_is_wide(instr)) { u32 instr2; - if (get_user(instr2, (u16 __user *)(pc + 2))) + if (get_user(instr_le, (__le16 __user *)(pc + 2))) goto exit; - instr2 = le16_to_cpu(instr2); + instr2 = le16_to_cpu(instr_le); instr = (instr << 16) | instr2; } } else { /* 32-bit ARM instruction */ - if (get_user(instr, (u32 __user *)pc)) + __le32 instr_le; + if (get_user(instr_le, (__le32 __user *)pc)) goto exit; - instr = le32_to_cpu(instr); + instr = le32_to_cpu(instr_le); } raw_spin_lock_irqsave(&undef_lock, flags);