Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4414384pxa; Mon, 10 Aug 2020 08:32:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxd1b15zxoWbd2ImdwF7TVAKRj6fCLxXKV1XMUj1wrfE11XQ+eF4OXi8ezIpTcW/8NsOq1s X-Received: by 2002:a17:906:e2c5:: with SMTP id gr5mr23218528ejb.89.1597073552761; Mon, 10 Aug 2020 08:32:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597073552; cv=none; d=google.com; s=arc-20160816; b=OBP0cCmUrVVFWudEr4bqx6uQ1qd3hLBW+UELNvLOZVq0U6qdWYlPDwHOfqcXPdIGkj 2ypBmRVNFH00UCOfikmBcs+YtjT4arHF2RDuoJPIxHU5kB6HlDK/JCiFZlowRXhMvP5m NQXzZDYa9lp5MRSea+HN3jm8AyX1wfmo98usT1hBJF8IM+KYlp44qq4JaqBFEmT0if3V 1Dqpm+CHjcRjpYj5NfF1Q5EvTXGlKB1KfQZ5C8+kdwrYed08HHACcpk/RxnRCDNe5qPq Zjvp18EajUV1ZjH4bqkbQ2WzBmFptq9bi1yT1AQJbJwBJhRBVrXPnn5PFmyaTFP5SidA Oqaw== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WRFvzkVQl/K6GOk8G35Suq61t+kKn5Ve5OJG2AaLKvw=; b=DplawAo9SjjNvbPlgbCIPjnNE4sEAECDEFDJok+XIHWOo3R3EC6pGMP8MdAzuNP9av 9LwpMKmZ+PtMrBlGQ0eXqnWioaTMwAmLycLxYs+XL4nFNLzakxwm/J0g9ydwubsQ9IvJ 3U6poCZ7ul5YK01DBE4YihOsSwstDd+99/fRE+3+N8THAmTmUTrDR0skGyWFfGRJ81EQ syBZih/yWAJQr901YjIbdliCIbTdrtCA80VBWI9XaAC45Es21iKC7G+nmWVijqN/X1IS LLC2RMzhCTcfrw2vEKo7e0SOv1wGqqYdnWVfSfmN1377rT5RCiAwDT0aaPKTTpHBL18K hnyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2PUc7HbY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mj19si10820491ejb.291.2020.08.10.08.32.09; Mon, 10 Aug 2020 08:32:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2PUc7HbY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729111AbgHJPaf (ORCPT + 99 others); Mon, 10 Aug 2020 11:30:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:37578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728605AbgHJPae (ORCPT ); Mon, 10 Aug 2020 11:30:34 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3918820774; Mon, 10 Aug 2020 15:30:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597073433; bh=0ZrsPUjG0hdVMilu3PldGC8BakCU6TEwpGp5jBD+8ro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2PUc7HbYRbdVej6t0nCYIco3gg1MqugfwPXohPoRehBa9MBLNxHL+ESZz+UHKlWlV O/xRAlDr/8U9ofHcNRWq3wVfpXfi/Uri87DzEfcqOiFdmukKGairq+mbyTxB3dXKse UT9+wVu0KKd2L6m27eYFz3xbEwQ1qrW9jGnKk4EA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Bianconi , Marcelo Ricardo Leitner , "David S. Miller" Subject: [PATCH 4.19 38/48] net: gre: recompute gre csum for sctp over gre tunnels Date: Mon, 10 Aug 2020 17:22:00 +0200 Message-Id: <20200810151806.093646552@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200810151804.199494191@linuxfoundation.org> References: <20200810151804.199494191@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lorenzo Bianconi [ Upstream commit 622e32b7d4a6492cf5c1f759ef833f817418f7b3 ] The GRE tunnel can be used to transport traffic that does not rely on a Internet checksum (e.g. SCTP). The issue can be triggered creating a GRE or GRETAP tunnel and transmitting SCTP traffic ontop of it where CRC offload has been disabled. In order to fix the issue we need to recompute the GRE csum in gre_gso_segment() not relying on the inner checksum. The issue is still present when we have the CRC offload enabled. In this case we need to disable the CRC offload if we require GRE checksum since otherwise skb_checksum() will report a wrong value. Fixes: 90017accff61 ("sctp: Add GSO support") Signed-off-by: Lorenzo Bianconi Reviewed-by: Marcelo Ricardo Leitner Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/gre_offload.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) --- a/net/ipv4/gre_offload.c +++ b/net/ipv4/gre_offload.c @@ -19,12 +19,12 @@ static struct sk_buff *gre_gso_segment(s netdev_features_t features) { int tnl_hlen = skb_inner_mac_header(skb) - skb_transport_header(skb); + bool need_csum, need_recompute_csum, gso_partial; struct sk_buff *segs = ERR_PTR(-EINVAL); u16 mac_offset = skb->mac_header; __be16 protocol = skb->protocol; u16 mac_len = skb->mac_len; int gre_offset, outer_hlen; - bool need_csum, gso_partial; if (!skb->encapsulation) goto out; @@ -45,6 +45,7 @@ static struct sk_buff *gre_gso_segment(s skb->protocol = skb->inner_protocol; need_csum = !!(skb_shinfo(skb)->gso_type & SKB_GSO_GRE_CSUM); + need_recompute_csum = skb->csum_not_inet; skb->encap_hdr_csum = need_csum; features &= skb->dev->hw_enc_features; @@ -102,7 +103,15 @@ static struct sk_buff *gre_gso_segment(s } *(pcsum + 1) = 0; - *pcsum = gso_make_checksum(skb, 0); + if (need_recompute_csum && !skb_is_gso(skb)) { + __wsum csum; + + csum = skb_checksum(skb, gre_offset, + skb->len - gre_offset, 0); + *pcsum = csum_fold(csum); + } else { + *pcsum = gso_make_checksum(skb, 0); + } } while ((skb = skb->next)); out: return segs;