Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3499393imm; Fri, 25 May 2018 06:49:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqx5JHCCLe4KQA4RT6NQGnm9NPrkGfKa76Jrju2tUoNl9Cdx9tlZAJbpC6LcUkGLJu17Nmx X-Received: by 2002:a62:89db:: with SMTP id n88-v6mr2651312pfk.11.1527256164981; Fri, 25 May 2018 06:49:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527256164; cv=none; d=google.com; s=arc-20160816; b=VMq9o4Y771q7bK/UPv+84VnQyn+Eeq1rDomvn63BQ9yguseLpmLoLd83+De76UZYAc paBlnmabsHxttdzySdOCKbH+ZkFZookeW11cv98wDaNPC4wyno8C80ySi3APdwr8csKP UOu0K5iGsHRQczdfLKhxcnZo2Il8PeuLjzh/KgI5K27apU/9IYPE6epU/qufOPLjxEOL CIGC3P2qrSj2qFXDfzbL3N97X0pLfAZ2opuFczRQ/ppmDdobroA7NH7wMUsI5sCnj5yZ zfpqUq9nxHQiwmHNYMKvKD+QVxfV/vS9HIvstaorRMa1KSZrUOtf681VZF+Kl7eHYqok 33iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:arc-authentication-results; bh=rlQvyyV0ecm22yyYA2JEelNbSDO9HNH23XYYj3ZkNIU=; b=mKUBO10qkPQ1Fj1sNQGOJWQ17OkcZIoq06vuagFsGqmtYEy14oRmMZcKGeeWel7oei 1KDb6H4ZRIggcBIMyPZI5pHK5G1MsGOhljewr40cUsZURXwrP1nYq81bAeGIqILgGj2p kluLzzRZfDUVsXyH5ZzpprYvlAUfncSm0Db7PHrGHcL4PrL+V4ncDeOG2R4e0Ea3WX2P Fkhv75vfKCaIf6GYihJXJ4JBAqoAvZNpmSfVB8a3xiBRnVe/3BWHUzCzYDG4Rgi8YgSz bLVIg7eXlYxNE2cSmRlOuG99KpcxRxHpBjbhGi/ZYKZwngr1X6mMPHi1b3y/lgFoOaZd vDBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k91-v6si6533314pld.27.2018.05.25.06.49.09; Fri, 25 May 2018 06:49:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935926AbeEYNsN (ORCPT + 99 others); Fri, 25 May 2018 09:48:13 -0400 Received: from www62.your-server.de ([213.133.104.62]:39467 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935737AbeEYNsL (ORCPT ); Fri, 25 May 2018 09:48:11 -0400 Received: from [62.202.221.10] (helo=linux.home) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-SHA:256) (Exim 4.85_2) (envelope-from ) id 1fMD4a-0001Md-AA; Fri, 25 May 2018 15:48:00 +0200 Subject: Re: [PATCH v2] bpf, arm32: Correct check_imm24 To: Wang YanQing , linux@armlinux.org.uk, ast@fb.com, illusionist.neo@gmail.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20180511030634.GB7621@udknight> From: Daniel Borkmann Message-ID: <206ea320-7f9e-6e3b-9808-f040f474839e@iogearbox.net> Date: Fri, 25 May 2018 15:47:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20180511030634.GB7621@udknight> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.99.3/24601/Fri May 25 06:40:37 2018) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/11/2018 05:06 AM, Wang YanQing wrote: > imm24 is signed, so the right range is: > [-(1<<(24 - 1)), (1<<(24 - 1)) - 1] > > Note:this patch also fix a typo. > > Signed-off-by: Wang YanQing Through which tree will this fix be routed? (And the cleanup in "[PATCH v2] bpf, arm32: Fix inconsistent naming about emit_a32_lsr_r64|emit_a32_lsr_i64"?) Wasn't fully clear from the subject in the patch whether target are bpf trees. If this one here should go as a fix via bpf tree, would be great to get an ACK from Russell. Just asking since I haven't seen it in Linus' tree and it's been two weeks by now, so making sure it's not getting lost in the archives. ;-) > --- > Changes > v1-v2: > 1:Rewrite the patch, I make a mistake, the v1 is wrong totally, > reported by Russell King. > > I use the fix suggested by Russell King instead of myself which > use the exact number range [-8388608, 8388607]. > 2:Fix the error in changelog. > > Thanks! > > arch/arm/net/bpf_jit_32.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c > index caccc78..316bc08 100644 > --- a/arch/arm/net/bpf_jit_32.c > +++ b/arch/arm/net/bpf_jit_32.c > @@ -84,7 +84,7 @@ > * > * 1. First argument is passed using the arm 32bit registers and rest of the > * arguments are passed on stack scratch space. > - * 2. First callee-saved arugument is mapped to arm 32 bit registers and rest > + * 2. First callee-saved argument is mapped to arm 32 bit registers and rest > * arguments are mapped to scratch space on stack. > * 3. We need two 64 bit temp registers to do complex operations on eBPF > * registers. > @@ -1199,8 +1199,8 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx) > s32 jmp_offset; > > #define check_imm(bits, imm) do { \ > - if ((((imm) > 0) && ((imm) >> (bits))) || \ > - (((imm) < 0) && (~(imm) >> (bits)))) { \ > + if ((imm) >= (1 << ((bits) - 1)) || \ > + (imm) < -(1 << ((bits) - 1))) { \ > pr_info("[%2d] imm=%d(0x%x) out of range\n", \ > i, imm, imm); \ > return -EINVAL; \ >