Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932657AbdFLPmH (ORCPT ); Mon, 12 Jun 2017 11:42:07 -0400 Received: from mail-ot0-f195.google.com ([74.125.82.195]:35287 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932615AbdFLPmE (ORCPT ); Mon, 12 Jun 2017 11:42:04 -0400 MIME-Version: 1.0 In-Reply-To: <20170612110611.GC4902@n2100.armlinux.org.uk> References: <1495754003-21099-1-git-send-email-illusionist.neo@gmail.com> <593E6B0F.8070901@iogearbox.net> <20170612110611.GC4902@n2100.armlinux.org.uk> From: Shubham Bansal Date: Mon, 12 Jun 2017 21:11:58 +0530 Message-ID: Subject: Re: [PATCH v2] arm: eBPF JIT compiler To: Russell King - ARM Linux Cc: Daniel Borkmann , Kees Cook , Network Development , "David S. Miller" , Alexei Starovoitov , "linux-arm-kernel@lists.infradead.org" , LKML , Andrew Lunn Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1063 Lines: 33 Hi Russel, On Mon, Jun 12, 2017 at 4:36 PM, Russell King - ARM Linux wrote: > On Mon, Jun 12, 2017 at 12:21:03PM +0200, Daniel Borkmann wrote: >> On 05/30/2017 09:19 PM, Kees Cook wrote: >> >On Thu, May 25, 2017 at 4:13 PM, Shubham Bansal >> > wrote: >> >>+static int validate_code(struct jit_ctx *ctx) >> >>+{ >> >>+ int i; >> >>+ >> >>+ for (i = 0; i < ctx->idx; i++) { >> >>+ u32 a32_insn = le32_to_cpu(ctx->target[i]); >> >> Given __opcode_to_mem_arm(ARM_INST_UDF) is used to fill the image, >> perhaps use the __mem_to_opcode_arm() helper for the check? >> >> >>+ if (a32_insn == ARM_INST_UDF) > > The following is probably better: > > if (ctx->target[i] == __opcode_to_mem_arm(ARM_INST_UDF)) > > since then you can take advantage of the compiler optimising the > constant rather than having to do a byte swap on an unknown 32-bit > value. Done. Thanks :) Please check if you can find anymore issues with the code. I really appreciate it. -Shubham