From patchwork Tue Jan 5 17:34:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rabin Vincent X-Patchwork-Id: 7956561 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0B1EEBEEE5 for ; Tue, 5 Jan 2016 17:36:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3CE942017D for ; Tue, 5 Jan 2016 17:36:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7C89220160 for ; Tue, 5 Jan 2016 17:36:20 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aGVVX-0002VC-PV; Tue, 05 Jan 2016 17:34:55 +0000 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aGVVU-0002Np-Bv for linux-arm-kernel@lists.infradead.org; Tue, 05 Jan 2016 17:34:53 +0000 Received: by mail-wm0-x22c.google.com with SMTP id l65so31496775wmf.1 for ; Tue, 05 Jan 2016 09:34:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=ehQ14HUYX3fdztsYiLS/x1AhjyW7k0Pei2Dq8K7DhRE=; b=vTbL0VsK0qak5wDlkiDJ2CjA9vYdxGekG7hu7LbNayGRYd4KUd/Z/Aikw6dqPLqKTV miQP7qTxDviY5ssUinSsAuOeUEhZxi4mnjwo9nwIXo9ZDNeDne9EIQKvCsHF/VBIw8vR ANeg9tBNRaGVj78qo7Hck1k85gH3lH7/Ozq6TmvkFKogeWRsjO6ECI/emI7r5MdXzIqV Q0cVT13/eXZ7CUVpPmaXtAuSc5JLGLgRC1Hx7KDFY5aLBUQmKP0Ss2U4mL8N7/p9RMOR mJ8s5NE9mdFPyYKxVp43iCU7Ka4DoAhFBBRv1fpaz5mGOm3Tjr4nyY7XrI1hVbU5LBFD KnWQ== X-Received: by 10.194.58.165 with SMTP id s5mr110709103wjq.70.1452015270666; Tue, 05 Jan 2016 09:34:30 -0800 (PST) Received: from localhost.localdomain (h249n21-ld-c-a31.ias.bredband.telia.com. [78.70.84.249]) by smtp.gmail.com with ESMTPSA id u12sm4543863wmu.10.2016.01.05.09.34.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Jan 2016 09:34:30 -0800 (PST) From: Rabin Vincent To: davem@davemloft.net Subject: [PATCH] ARM: net: bpf: fix zero right shift Date: Tue, 5 Jan 2016 18:34:04 +0100 Message-Id: <1452015244-1230-1-git-send-email-rabin@rab.in> X-Mailer: git-send-email 2.6.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160105_093452_573605_B863A263 X-CRM114-Status: GOOD ( 11.24 ) X-Spam-Score: -2.3 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rabin Vincent , netdev@vger.kernel.org, linux@arm.linux.org.uk, 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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 The LSR instruction cannot be used to perform a zero right shift since a 0 as the immediate value (imm5) in the LSR instruction encoding means that a shift of 32 is perfomed. See DecodeIMMShift() in the ARM ARM. Make the JIT skip generation of the LSR if a zero-shift is requested. This was found using american fuzzy lop. Signed-off-by: Rabin Vincent Acked-by: Alexei Starovoitov --- arch/arm/net/bpf_jit_32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c index e153eb065fe4..93d0b6d0b63e 100644 --- a/arch/arm/net/bpf_jit_32.c +++ b/arch/arm/net/bpf_jit_32.c @@ -756,7 +756,8 @@ load_ind: case BPF_ALU | BPF_RSH | BPF_K: if (unlikely(k > 31)) return -1; - emit(ARM_LSR_I(r_A, r_A, k), ctx); + if (k) + emit(ARM_LSR_I(r_A, r_A, k), ctx); break; case BPF_ALU | BPF_RSH | BPF_X: update_on_xread(ctx);