Received: by 10.213.65.68 with SMTP id h4csp2144807imn; Sun, 8 Apr 2018 20:52:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx491Nkzwdf+0SuyQQoYCGTvyh9sm0bU11cHOw0DBqkxkquGm09AeC3lDneXG9TFbYxitCUn/ X-Received: by 10.98.89.89 with SMTP id n86mr26138888pfb.158.1523245960688; Sun, 08 Apr 2018 20:52:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523245960; cv=none; d=google.com; s=arc-20160816; b=ZCIN4k8KlHflWgNTs2S9g45vbZ2WtSXHt5SA3DBgKxOe8RUk7d82SMeknXZDuF0zQ8 yylAHnVimX9vLkMKLrEEOBlzxzJmJtOIUYai3igrCUbf7TRyb7LcctOFESN6zARVLoxz nrM553q7X7kmTmR6aoP1/aGQw6VLFXRWGrRlvFa/Vs3DrisCMpoLnU9uuEa+RfCa710T Ak5fZhjEMs4/rUevx9eUcRrvyF/HJ7NHJ4YJpiwihSuYqXVTqNLJEBQyqVY7Ge57vyGJ GG8f622vNsfg1jCh0YtOB3IGfYWNccqcvhR00A2FTCa5Vos/RJ3lGlR9L/t+k0/MMPWl vv+g== 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 :spamdiagnosticmetadata:spamdiagnosticoutput: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=GolHb/JmG018fQauv+xlE6eUXcFz35pei5T11gIWV3I=; b=QonB0+qXqVda4RfHMvagQvDWZYu6wkqB2mFA8+nzXTg1vSiHGxQbE1C/GKTpwDiLvp p1TZ2Qcc8/gxqviD4P7GnAjgLXEYrs/TAduluUMBxaGNxKkhxZyhJE8yKDHpGDgCYq1N mTdKgqH0wrnT9B9E4IfQptzcvxwp6P0mP58mPSuGLgmups5dVsPJjE3WL5mSROJYtpTu MyC+DAB808QjYj3SxhHX+IPP7mgY0NyTZW+KzGE636CFvxbK+sCAie4uu1D0Oiy/jJ94 DXBXhaQKGFvRjXOoyOt48FCHISdHxvgPFoihra4qtwKNfLt1H9PPrtP7Sz4erTSMq7RT iwyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=AEoWbtth; 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 bb10-v6si2543688plb.474.2018.04.08.20.52.03; Sun, 08 Apr 2018 20:52:40 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=AEoWbtth; 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 S1754474AbeDIDr0 (ORCPT + 99 others); Sun, 8 Apr 2018 23:47:26 -0400 Received: from mail-bn3nam01on0125.outbound.protection.outlook.com ([104.47.33.125]:5792 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754085AbeDIAUL (ORCPT ); Sun, 8 Apr 2018 20:20:11 -0400 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=GolHb/JmG018fQauv+xlE6eUXcFz35pei5T11gIWV3I=; b=AEoWbtth4SsmavNdhOkm8JdflsBTvf6PxI4aDuyP1Yxp1XX3hBiV6OUMdDA6xki6LiBDsp/F6Fam+SH9MRBDRom4H+Ox7Iw3iiXc7g8RYDkq3Z1K1avCJb/d/u3awR4467edA/ibrawy0d1Y1p0JDJY6GJolpkrHG9fxyEDcVhE= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0726.namprd21.prod.outlook.com (10.167.108.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:20:06 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:20:06 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Ed Swierk , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 126/189] openvswitch: Remove padding from packet before L3+ conntrack processing Thread-Topic: [PATCH AUTOSEL for 4.15 126/189] openvswitch: Remove padding from packet before L3+ conntrack processing Thread-Index: AQHTz5hISJOrcgkW9kyzrzrqKVb3Yg== Date: Mon, 9 Apr 2018 00:18:27 +0000 Message-ID: <20180409001637.162453-126-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-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;DM5PR2101MB0726;7:jZmxVtPKMPmXe0zjiT1sMKfyKTfPJWSziaETuVRiYC56edVauvPRESSd03FUwU0o/3CwrnsHkTyFPQhhDPmfyeiDsciRK8uk2MvFf5U3KqYaJVTwUTgaSt5jNuyhfVPOzftlClEZAiKUlhXVl5HLVZpQVdtJqeqIiJnAm3WVcSl07F1j5jwh4S5gVua/vZzSOUylB0JdhY39dSKASO4j3eZG4SBk1vu9N5Irw1YASgmJ5SKnsanB+YzDMYumSBuJ;20:IZel0703vLJcHlU76aQ4x0i+1dSEIgZhjHAJI9KHgd67u57NXjuq2/3gr5VdRhtQFCIsCNzYxHJrxbsFjwhXj4KOQrowVuNik6JQuopxQQGswtfFoSQIxsOVY49X+75oAEpBamFZB6uB08yQO2pttfbFR9lP9wl5ZWWn8rTQ4Rk= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: c33bdf60-1959-4d86-260e-08d59dafa5a6 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0726; x-ms-traffictypediagnostic: DM5PR2101MB0726: 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); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB0726;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0726; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(346002)(39380400002)(39860400002)(396003)(376002)(199004)(189003)(6486002)(26005)(6512007)(4326008)(81166006)(6666003)(6436002)(81156014)(8676002)(97736004)(186003)(36756003)(72206003)(53936002)(107886003)(2906002)(86362001)(76176011)(110136005)(305945005)(10090500001)(486006)(3660700001)(102836004)(5660300001)(14454004)(476003)(86612001)(446003)(99286004)(68736007)(66066001)(11346002)(54906003)(2616005)(1076002)(7736002)(5250100002)(25786009)(8936002)(478600001)(2900100001)(2501003)(3280700002)(105586002)(59450400001)(316002)(106356001)(22452003)(6506007)(3846002)(10290500003)(6116002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0726;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: CcVpc8n0QLRNcItD6YT5D+Zhawfii1WkkT5GG5ocaaV/exZ+DYvQojuvcLFNRIZ9DgDBPxTqk+Cj9aQ1lA2K5MSvSYcMRKZgt+SjvUUjpgXzLiCoQ49Y8MBByZuXfDkyz+lDPdrG8S/xdwh+dqI4xXrA87YFZSbCZjMdhCRJulRz/G6VEbUd74PBcsnulz5DcYBFNDrYHJZPxcua6NBd71EUk4M+IDM3lMTuso7DXzFo8wvRKnMYBxehVryEBWUw7JIMotq6RZZyijw1iJHjUps9qR25a1R0NTNSkOLO1hvKv20NTEpESOYFFhpEJo0LYNGOp+86eRd+5/IfNA2A3RQBwzekHxdRDk8e3FocxnuXT1s/yq7lyq4/ZilRO+lj3azxewFus4dFLPLTgRPxhrs7V9HSfM8lYFRmlcsZJ7w= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM 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: c33bdf60-1959-4d86-260e-08d59dafa5a6 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:18:27.6446 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0726 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ed Swierk [ Upstream commit 9382fe71c0058465e942a633869629929102843d ] IPv4 and IPv6 packets may arrive with lower-layer padding that is not included in the L3 length. For example, a short IPv4 packet may have up to 6 bytes of padding following the IP payload when received on an Ethernet device with a minimum packet length of 64 bytes. Higher-layer processing functions in netfilter (e.g. nf_ip_checksum(), and help() in nf_conntrack_ftp) assume skb->len reflects the length of the L3 header and payload, rather than referring back to ip_hdr->tot_len or ipv6_hdr->payload_len, and get confused by lower-layer padding. In the normal IPv4 receive path, ip_rcv() trims the packet to ip_hdr->tot_len before invoking netfilter hooks. In the IPv6 receive path, ip6_rcv() does the same using ipv6_hdr->payload_len. Similarly in the br_netfilter receive path, br_validate_ipv4() and br_validate_ipv6() trim the packet to the L3 length before invoking netfilter hooks. Currently in the OVS conntrack receive path, ovs_ct_execute() pulls the skb to the L3 header but does not trim it to the L3 length before calling nf_conntrack_in(NF_INET_PRE_ROUTING). When nf_conntrack_proto_tcp encounters a packet with lower-layer padding, nf_ip_checksum() fails causing a "nf_ct_tcp: bad TCP checksum" log message. While extra zero bytes don't affect the checksum, the length in the IP pseudoheader does. That length is based on skb->len, and without trimming, it doesn't match the length the sender used when computing the checksum. In ovs_ct_execute(), trim the skb to the L3 length before higher-layer processing. Signed-off-by: Ed Swierk Acked-by: Pravin B Shelar Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/openvswitch/conntrack.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index b27c5c6d9cab..8f04bd6e44bb 100644 --- a/net/openvswitch/conntrack.c +++ b/net/openvswitch/conntrack.c @@ -1098,6 +1098,36 @@ static int ovs_ct_commit(struct net *net, struct sw_= flow_key *key, return 0; } =20 +/* Trim the skb to the length specified by the IP/IPv6 header, + * removing any trailing lower-layer padding. This prepares the skb + * for higher-layer processing that assumes skb->len excludes padding + * (such as nf_ip_checksum). The caller needs to pull the skb to the + * network header, and ensure ip_hdr/ipv6_hdr points to valid data. + */ +static int ovs_skb_network_trim(struct sk_buff *skb) +{ + unsigned int len; + int err; + + switch (skb->protocol) { + case htons(ETH_P_IP): + len =3D ntohs(ip_hdr(skb)->tot_len); + break; + case htons(ETH_P_IPV6): + len =3D sizeof(struct ipv6hdr) + + ntohs(ipv6_hdr(skb)->payload_len); + break; + default: + len =3D skb->len; + } + + err =3D pskb_trim_rcsum(skb, len); + if (err) + kfree_skb(skb); + + return err; +} + /* Returns 0 on success, -EINPROGRESS if 'skb' is stolen, or other nonzero * value if 'skb' is freed. */ @@ -1112,6 +1142,10 @@ int ovs_ct_execute(struct net *net, struct sk_buff *= skb, nh_ofs =3D skb_network_offset(skb); skb_pull_rcsum(skb, nh_ofs); =20 + err =3D ovs_skb_network_trim(skb); + if (err) + return err; + if (key->ip.frag !=3D OVS_FRAG_TYPE_NONE) { err =3D handle_fragments(net, key, info->zone.id, skb); if (err) --=20 2.15.1