Received: by 10.213.65.68 with SMTP id h4csp1792984imn; Mon, 19 Mar 2018 13:25:00 -0700 (PDT) X-Google-Smtp-Source: AG47ELsho75+Cs8G+tQ9FNFE2yh8hs6MTIzaPBZxpFUlt3DHlLqECc7MNhM17GQRi029HLgJKPgZ X-Received: by 10.98.9.5 with SMTP id e5mr11423719pfd.189.1521491100144; Mon, 19 Mar 2018 13:25:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521491100; cv=none; d=google.com; s=arc-20160816; b=JQ/E1Xu3EYrNcOi/g3TvXd+WNGgJoo/drjv9Op9XRm3I2rAcnnYhrQU+D8FY8GoVN+ ygr8/XCO/fzn+m0THZC0oqGel5pnb6SXUaYqEZ+oTeAqS0yYxDXKWV3amQZO8wJafvH6 dvUcQhYHlLMkN5Eyq3UHFemqQ692tpReND+4FOaVHKVOdYTFSQXr/2Mfa5/L2RF3yQlX sqZR/jo4XD0fX4xScAJE4W6KZgYhk6naDc5gC9z2XnRmseX5bDYb9OuBe9YdXfCfhjCO FezAbXVkhuphnRNxG81vd7jVrwD9i9po+NlL3ch9Jstjlz3V7Z6t1zxtdacmEy4qg2wN +yhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=UnB0EA+nVFQO0Y4+Kdazx/CpHsPX7i0mosQ+DCt0gYU=; b=W3d5VPldKmhup7o/CIfM11ycfPHZXDCYAlx5CP4PUKE5sOgHnnN6GfUUGSzW6ndUNI ok9bNDyZzMXaVP/YfIQU6DnyxY8u/PsdKbVAHYY1s4x73DBfX0K4c+rEcgqXpSFLYpv5 t6G+mY7BEsYoCrQ5PbgcsJp/R1HyNMaQDH4CT9o7yL/V7efDUzTKz5ngk/4pVQme5bjb ZNBKdXmkRcrTkVVRFGrkUYF1GBvZhbNx5Hl33TeqTiZF6AWUcP27Zk8hs/FCztOrFlCr WztozcT6jEo5Nfp6PzjWHQC6qSUZIP5OQO5TwYhOK0Je7/FYWoHwjEgsCeV8JHwFbCfi kZzQ== 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 l33-v6si20691pld.187.2018.03.19.13.24.45; Mon, 19 Mar 2018 13:25:00 -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 S968897AbeCSSOj (ORCPT + 99 others); Mon, 19 Mar 2018 14:14:39 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44220 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030692AbeCSSOe (ORCPT ); Mon, 19 Mar 2018 14:14:34 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D9DB9F0F; Mon, 19 Mar 2018 18:14:33 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Daney , James Hogan , Alexei Starovoitov , "Steven J. Hill" , linux-mips@linux-mips.org, netdev@vger.kernel.org, Ralf Baechle , Sasha Levin Subject: [PATCH 4.4 063/134] MIPS: BPF: Fix multiple problems in JIT skb access helpers. Date: Mon, 19 Mar 2018 19:05:46 +0100 Message-Id: <20180319171858.380719820@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319171849.024066323@linuxfoundation.org> References: <20180319171849.024066323@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Daney [ Upstream commit a81507c79f4ae9a0f9fb1054b59b62a090620dd9 ] o Socket data is unsigned, so use unsigned accessors instructions. o Fix path result pointer generation arithmetic. o Fix half-word byte swapping code for unsigned semantics. Signed-off-by: David Daney Cc: James Hogan Cc: Alexei Starovoitov Cc: Steven J. Hill Cc: linux-mips@linux-mips.org Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/15747/ Signed-off-by: Ralf Baechle Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/mips/net/bpf_jit_asm.S | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) --- a/arch/mips/net/bpf_jit_asm.S +++ b/arch/mips/net/bpf_jit_asm.S @@ -90,18 +90,14 @@ FEXPORT(sk_load_half_positive) is_offset_in_header(2, half) /* Offset within header boundaries */ PTR_ADDU t1, $r_skb_data, offset - .set reorder - lh $r_A, 0(t1) - .set noreorder + lhu $r_A, 0(t1) #ifdef CONFIG_CPU_LITTLE_ENDIAN # if defined(__mips_isa_rev) && (__mips_isa_rev >= 2) - wsbh t0, $r_A - seh $r_A, t0 + wsbh $r_A, $r_A # else - sll t0, $r_A, 24 - andi t1, $r_A, 0xff00 - sra t0, t0, 16 - srl t1, t1, 8 + sll t0, $r_A, 8 + srl t1, $r_A, 8 + andi t0, t0, 0xff00 or $r_A, t0, t1 # endif #endif @@ -115,7 +111,7 @@ FEXPORT(sk_load_byte_positive) is_offset_in_header(1, byte) /* Offset within header boundaries */ PTR_ADDU t1, $r_skb_data, offset - lb $r_A, 0(t1) + lbu $r_A, 0(t1) jr $r_ra move $r_ret, zero END(sk_load_byte) @@ -139,6 +135,11 @@ FEXPORT(sk_load_byte_positive) * (void *to) is returned in r_s0 * */ +#ifdef CONFIG_CPU_LITTLE_ENDIAN +#define DS_OFFSET(SIZE) (4 * SZREG) +#else +#define DS_OFFSET(SIZE) ((4 * SZREG) + (4 - SIZE)) +#endif #define bpf_slow_path_common(SIZE) \ /* Quick check. Are we within reasonable boundaries? */ \ LONG_ADDIU $r_s1, $r_skb_len, -SIZE; \ @@ -150,7 +151,7 @@ FEXPORT(sk_load_byte_positive) PTR_LA t0, skb_copy_bits; \ PTR_S $r_ra, (5 * SZREG)($r_sp); \ /* Assign low slot to a2 */ \ - move a2, $r_sp; \ + PTR_ADDIU a2, $r_sp, DS_OFFSET(SIZE); \ jalr t0; \ /* Reset our destination slot (DS but it's ok) */ \ INT_S zero, (4 * SZREG)($r_sp); \