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: 3397361 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B6E3F9F375 for ; Mon, 23 Dec 2013 16:43:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A1A60202A7 for ; Mon, 23 Dec 2013 16:43:07 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DB02A20257 for ; Mon, 23 Dec 2013 16:43:02 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vv8ap-0003OO-HB; Mon, 23 Dec 2013 16:42:59 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vv8an-0003HK-6g; Mon, 23 Dec 2013 16:42:57 +0000 Received: from mail-ea0-f181.google.com ([209.85.215.181]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vv8ak-0003GS-Dm for linux-arm-kernel@lists.infradead.org; Mon, 23 Dec 2013 16:42:55 +0000 Received: by mail-ea0-f181.google.com with SMTP id m10so2450038eaj.40 for ; Mon, 23 Dec 2013 08:42:32 -0800 (PST) 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; bh=UBWFMDyiJADJz2rJ1ykWUJP3qvSXLBabRhtmJspRs1Q=; b=kQgkHKg1+BeP4Xq4tEfSly+jNFDvZ41U6rm5PvBFAAzjq1NHBhZ5PjhmBS8EN78vff tPnLyryIa5VycPYMdrOwhgLU1HrcidDtJfupTIX67tTCM9PU1H6CJ/iMie+tFpi9oCTE jVGZcebn6K6mbK+2ZiRlq5mgQjQ6efASVQTGRNitsjQE1mY5caTcWzhEEtqtG3wqIX9m NcMTvF0R+pbKInFw3l3zbuuRTA0HQl0QTM7GL90KeG64dn1hkRCS5uSvtBsuBdK6jSfZ o6EJINAghvXKmJjLNXGicmzEsROJucfFpU4qjLUNMDFc1Bg3I39U5dMPFnHTNQRneXHU TkHQ== X-Gm-Message-State: ALoCoQkU2mUmamsxOZtyWxOlOQZ2EKlIkEVtwmx9uf1JAHlpqOywXR0QzJCIwFzfKfoHxJPTs6Gs 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131223_114254_578586_AC2ADDC7 X-CRM114-Status: GOOD ( 10.55 ) X-Spam-Score: -2.6 (--) Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, Taras Kondratiuk , linux-kernel@vger.kernel.org, Ben Dooks , linaro-networking@linaro.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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)