Received: by 10.223.185.116 with SMTP id b49csp1067078wrg; Sat, 3 Mar 2018 14:36:39 -0800 (PST) X-Google-Smtp-Source: AG47ELuHAdjKAbl7NUKmJNe1foOEoh7h85zdSYhQ9rgCrVob/vertaWk9t0G3CirtLjHeC2vqbQS X-Received: by 10.98.219.129 with SMTP id f123mr10435762pfg.195.1520116599254; Sat, 03 Mar 2018 14:36:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520116599; cv=none; d=google.com; s=arc-20160816; b=HAIbdYaSl62nCQug0QwC78KPtYIK5U1bHcQJaJEO3hodBRgWEcxtlJ/ppKK+LUT7k4 1NYxjxfvn4gaxcQ6Z76fOKL2dKeibcJlmr2sOWMcs0WQiPbbaB4Sv1I8n7issbP2drMR id07i4EhA4Su0rVoJDoxLrDjzLq68e3G9WVy7i1lB1ecCAGnkBI4tAQkd+ox3F2rRufg BTf7uaQVsAiNFLgJ6lAj/Pc9meUv5xp8MbVDcb/Ics5DeQljlLMrjl4Uyj6PjGfEUZqn 7sf0H+RpsbSetatViz4NegBDuX+qltD4qS/fsqaO5Kw8TfBoR+WA/I7jyStpfrAKATyD /nzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=sd4gbDGvuTP8uce9Zd7kcRmt147rCNKml4/lIBq/RvU=; b=ezCIlCixMIvkg1RS+mkGZmAhV4Iw4AIzD1E/oqVZI2p0668k9S9ebyPBfjz0zOm62I RF735zyYRpkWoDYUl4p7BX6/hDpt5fjCbCadTWFYP2WHy6Mw4KHsB7e0cmC88V9CRHCv +9IiCNBDTbMZCUZhI5pN4hpO16+zyw4n3EYGmOoncesxSLkuuUFewHEWv4p+QQhNQeUL p5J1Q+ooddoQfK/GzSoIlmShZ7agPWbyL2XuDErRDBx0MN6psKBBS8kMgoLoO+AurO6j AYcWhM5GV9v7pKWfG4L83ohaoctjcKrGPQZD0qC/yGX7Xn49NDzCFeoYSbhA7F4E1DeI uN3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=nWHY7FBR; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a31-v6si6905107pla.427.2018.03.03.14.36.24; Sat, 03 Mar 2018 14:36:39 -0800 (PST) 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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=nWHY7FBR; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934416AbeCCWfV (ORCPT + 99 others); Sat, 3 Mar 2018 17:35:21 -0500 Received: from mail-sn1nam02on0094.outbound.protection.outlook.com ([104.47.36.94]:45030 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934341AbeCCWfL (ORCPT ); Sat, 3 Mar 2018 17:35:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=sd4gbDGvuTP8uce9Zd7kcRmt147rCNKml4/lIBq/RvU=; b=nWHY7FBR1hquVeteNxjOCux6k5v6zXUAk0madIMCCw+jL4K2DNmRCn73F2UJGgZGkjXMN3OVbEgvKnCt96arNHyAdOXGYAf+70kdmV7Xn9o530q94hlHrWqlgeD66tMtgMd9H9IbKAqKx4x5TlMrrhTvFV0m5z2rh/nxD2DYhhQ= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB0924.namprd21.prod.outlook.com (52.132.152.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.588.3; Sat, 3 Mar 2018 22:34:54 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:34:54 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: David Daney , James Hogan , Alexei Starovoitov , "Steven J . Hill" , "linux-mips@linux-mips.org" , "netdev@vger.kernel.org" , Ralf Baechle , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 137/219] MIPS: BPF: Fix multiple problems in JIT skb access helpers. Thread-Topic: [PATCH AUTOSEL for 4.9 137/219] MIPS: BPF: Fix multiple problems in JIT skb access helpers. Thread-Index: AQHTsz8QdLxyySlwWEu+oufZVP8dTQ== Date: Sat, 3 Mar 2018 22:29:15 +0000 Message-ID: <20180303222716.26640-137-alexander.levin@microsoft.com> References: <20180303222716.26640-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222716.26640-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MW2PR2101MB0924;6:nqKRoKP1ZCfeyQgBR9HpepXf92133uoEDt9T37FVoaujcpsUPEqABdqVk5tWOOmaLSIjypeFvllmPGwIwF0NtuRcyHglohdRuf3KziVZJnaE2fYfYhiS1FnpTSlkNx3sc5GQdVFxe96ZSZXgHW2EjHBDiM4RTEDpOF8naSiVLjQTxByXE6ujdVht8Os0sR7ryQK5PGikHsOBnoc29z4mQmDmosd8Xj3yq/rZwJv/y4VltmhnUDQiIYpjW7smbFGJwvd/t7sAkjopfWdWhj4TKQ7cQFUaMeKFBE3yfh0nOJKALBFeJre2Na7pa6u1Mzd8xY0G9CXuAZyqGxzCC6gjwcaGsh7MWk2+WYNi0pBi4o0=;5:KCxm4/Mx7LI6Y3bwVRJoU7/WCx3WbAVqUTu2s5VULLXdjLVj4pYYDUcSnbmGE10jxzzguSH/tDI3oxRVY4rns506VEHAj+pKkBxNd54lXY0HrTiRi7LUWK/7w2mT+/dsCrg9euXMwpMnDTd359Ufl0/TFuRoIlCCmvfjNGUeDMw=;24:w7rgpracERFaNmik8eNV2/hOTxraahm0k3Gb2iWBIQp+xjlNYCiT5Q9tIb+h14y9txmPOsVniKRSFrOwhQ7igDZGbqqraNsIDaZpkxLfQKc=;7:k6aVh9tGVF5tRjElei7eMOOq1PT4YNxghNG5Gu1GU8ta8IJCUweZ7cLLAa3AXUwj/PhO82I90WAIFYkb2rKYl5LbJnIVBmqHKB0V44a3bkF2hoHxkC/kQhXLNyUdPaC6YA+N4vo4M8gb4oVuGKavvrko8Jqb533BN80YmLefMz7QU8I3yIMzcMbu83Hx7510Rg96femUF1QvZuzbpd5XTj16pQhgkd6BcD01raywZ4PB1NXC6cuoT/zh8ZqgMlzI x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: f5724acc-4a1a-4000-531f-08d58156fc53 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7193020);SRVR:MW2PR2101MB0924; x-ms-traffictypediagnostic: MW2PR2101MB0924: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(9452136761055); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231220)(944501244)(52105095)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:MW2PR2101MB0924;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB0924; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(376002)(39860400002)(396003)(366004)(39380400002)(189003)(199004)(102836004)(2950100002)(10090500001)(6666003)(316002)(26005)(186003)(25786009)(2900100001)(2906002)(54906003)(22452003)(110136005)(97736004)(6506007)(7736002)(4326008)(305945005)(5250100002)(86362001)(575784001)(2501003)(99286004)(68736007)(72206003)(53936002)(6436002)(6116002)(3846002)(5660300001)(66066001)(1076002)(76176011)(14454004)(966005)(36756003)(3660700001)(6486002)(86612001)(81156014)(8676002)(81166006)(10290500003)(6512007)(8936002)(3280700002)(478600001)(107886003)(106356001)(6306002)(105586002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB0924;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: f5724acc-4a1a-4000-531f-08d58156fc53 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:29:15.9944 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB0924 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- arch/mips/net/bpf_jit_asm.S | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/arch/mips/net/bpf_jit_asm.S b/arch/mips/net/bpf_jit_asm.S index 5d2e0c8d29c0..88a2075305d1 100644 --- 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 >=3D 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); \ --=20 2.14.1