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: 563210 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3E18F140180 for ; Wed, 6 Jan 2016 04:34:37 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=vTbL0VsK; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752493AbcAERed (ORCPT ); Tue, 5 Jan 2016 12:34:33 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:33811 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752487AbcAEReb (ORCPT ); Tue, 5 Jan 2016 12:34:31 -0500 Received: by mail-wm0-f54.google.com with SMTP id u188so31967576wmu.1 for ; Tue, 05 Jan 2016 09:34:31 -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 Cc: netdev@vger.kernel.org, linux@arm.linux.org.uk, linux-arm-kernel@lists.infradead.org, Rabin Vincent 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 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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);