Received: by 10.213.65.68 with SMTP id h4csp1761162imn; Mon, 19 Mar 2018 12:31:17 -0700 (PDT) X-Google-Smtp-Source: AG47ELufs8Z8gWqZzk5gFG09qWS2n0flu1oSRSqF1fMwQNburD99U5zetpKQfM/NmET5U+zJWR6o X-Received: by 2002:a17:902:67c8:: with SMTP id g8-v6mr13578628pln.106.1521487877393; Mon, 19 Mar 2018 12:31:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521487877; cv=none; d=google.com; s=arc-20160816; b=uE7gSGu6iJxcrkPcJpzwVFxnyHyIhtez46Q6Qi3WYYGwQW537YKMSYrOsnyxZYpqlc sx/81miYzFThti40xjK7t9iCOMtMMVo519gfAfR1nj2g18rB4CumsZBvixvaBSp9hhet 9kapAEdUqDX/sXtM1MuXQlmu49KyTQj+nR8ZMgS4P31K9+TEE7ef6KSWfF5DtcVHDO6F F3nqyU/I9P2qWC+1RlW6eoBfFS8QwNsY7hO6EQgaEfOvQfyeLCHqfnYPRtxOktnkdeRg cKDNpjMbDVIy6yJFGJjGWxlKwPGtDLWqfGGAzewjePW9moV7KLKXYo9dYzcbFYMHJl5X Wpqw== 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=DH9nM66qSwlmv1c6DHzxCpXITNBD0ir/rIPGXZf3h1E=; b=Puqod5s4oF12wD342kTPJ90S1bWSRbzEhLaIwTYipSlJu9p6g6c4Q620gJs5xpSZwp CVc5uk99I4mxRkwpmHwP/4tJ3J04bAxlNYdiZsGycNwFMfW2SQ9ZFc1JXTEvklWOChrr +8E3pKtER725aSbWivcuk6UkufL4vHmIGKC4f+UbYlZILyWi9SIgnubbOJMPE6nbuGTo FY/d510UvzcYJZ6p/3HT0SQ4NDK7a4nIzxnFDJotk8nGeIkpTmJDsegtINzbUQs8laEe IqlWFRjOwCr/KxyGTQwOzoGL02Pr6UlgHKBkUuZ2S/mSaPwWEy+AKm2gEwcKvRj0AcAd /r4Q== 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 j10si442918pfe.276.2018.03.19.12.31.02; Mon, 19 Mar 2018 12:31:17 -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 S1031514AbeCSSXx (ORCPT + 99 others); Mon, 19 Mar 2018 14:23:53 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:49638 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031469AbeCSSXr (ORCPT ); Mon, 19 Mar 2018 14:23:47 -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 0B749E06; Mon, 19 Mar 2018 18:23:46 +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.9 130/241] MIPS: BPF: Fix multiple problems in JIT skb access helpers. Date: Mon, 19 Mar 2018 19:06:35 +0100 Message-Id: <20180319180756.575852956@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@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.9-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); \