From patchwork Mon Dec 23 16:42:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 22734 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B15F620540 for ; Mon, 23 Dec 2013 16:42:35 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id at1sf24454938iec.11 for ; Mon, 23 Dec 2013 08:42:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=UBWFMDyiJADJz2rJ1ykWUJP3qvSXLBabRhtmJspRs1Q=; b=kN90VcrudBDfP7wISAhM2xA4v6TNfdouZPYtA84RjTXkFYMx4s34OWHutbr43ppIrC 8+oEM/+WS/zLY+6Ioao1SN1G781kDz+eSFsgFFDgQ6z6FC/p2iVuVv0Nh78v9+/NQRXj HNfaxTmoYBWCcq4ECC5rYvOWtIBjO9tUzGWUwml5DLYfkfN6cd50SwTEFl5VpTEqm3rJ rJb6OwRc8XDmo21LZ3UMRDvEvM5jnxbj+ZRkRrVfySB2nNgGrif4c01lpSVPsBngXNPt mZciotpSJrzqJUxaytDX+5jx5t7iTY3eyPRYN+YM2RoWllLR+H/FT3FfxDkxHSyPBsMy WDpw== X-Gm-Message-State: ALoCoQnDfEDvs62SvHsTcD7jtEuLK4AQhmTes9W3n76gLc9X4sOZQrWA2vpZD44lE8eE8PJCz7Il X-Received: by 10.182.60.37 with SMTP id e5mr1148170obr.30.1387816954542; Mon, 23 Dec 2013 08:42:34 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.2.41 with SMTP id 9ls1596792qer.99.gmail; Mon, 23 Dec 2013 08:42:34 -0800 (PST) X-Received: by 10.52.38.33 with SMTP id d1mr6531538vdk.4.1387816954434; Mon, 23 Dec 2013 08:42:34 -0800 (PST) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id gs2si4995406vdc.148.2013.12.23.08.42.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 23 Dec 2013 08:42:34 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id la4so2958715vcb.15 for ; Mon, 23 Dec 2013 08:42:34 -0800 (PST) X-Received: by 10.52.244.15 with SMTP id xc15mr147606vdc.52.1387816954319; Mon, 23 Dec 2013 08:42:34 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp239876ved; Mon, 23 Dec 2013 08:42:33 -0800 (PST) X-Received: by 10.14.204.135 with SMTP id h7mr383743eeo.104.1387816952833; Mon, 23 Dec 2013 08:42:32 -0800 (PST) Received: from mail-ee0-f41.google.com (mail-ee0-f41.google.com [74.125.83.41]) by mx.google.com with ESMTPS id j47si20864536eeo.53.2013.12.23.08.42.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 23 Dec 2013 08:42:32 -0800 (PST) Received-SPF: neutral (google.com: 74.125.83.41 is neither permitted nor denied by best guess record for domain of taras.kondratiuk@linaro.org) client-ip=74.125.83.41; Received: by mail-ee0-f41.google.com with SMTP id t10so2471552eei.0 for ; Mon, 23 Dec 2013 08:42:32 -0800 (PST) X-Received: by 10.14.107.3 with SMTP id n3mr3597560eeg.67.1387816952241; Mon, 23 Dec 2013 08:42:32 -0800 (PST) Received: from condor-x220.synapse.com ([195.238.93.36]) by mx.google.com with ESMTPSA id j46sm47078184eew.18.2013.12.23.08.42.31 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 23 Dec 2013 08:42:31 -0800 (PST) From: Taras Kondratiuk To: Russell King Cc: patches@linaro.org, linaro-networking@linaro.org, linaro-kernel@lists.linaro.org, Taras Kondratiuk , Ben Dooks , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] ARM: traps: fix opcode endianness when read from user memory Date: Mon, 23 Dec 2013 18:42:07 +0200 Message-Id: <1387816927-4313-1-git-send-email-taras.kondratiuk@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: taras.kondratiuk@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Currently code has an inverted logic: opcode from user memory is swapped to a proper endianness only in case of read error. While normally opcode should be swapped only if it was read correctly from user memory. Signed-off-by: Ben Dooks Signed-off-by: Taras Kondratiuk --- arch/arm/kernel/traps.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index 7940241..36a844e 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -425,9 +425,10 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs) instr2 = __mem_to_opcode_thumb16(instr2); instr = __opcode_thumb32_compose(instr, instr2); } - } else if (get_user(instr, (u32 __user *)pc)) { + } else { + if (get_user(instr, (u32 __user *)pc)) + goto die_sig; instr = __mem_to_opcode_arm(instr); - goto die_sig; } if (call_undef_hook(regs, instr) == 0)