Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4453693imw; Tue, 19 Jul 2022 06:57:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ttakeiJYAiNT1l1L6jaI5EIJ6JIWgMPjM7XEQ3XTOUIA1GCqnBAiJld0Q0YTuKpom+Dk0s X-Received: by 2002:a05:6402:4144:b0:431:6ef0:bef7 with SMTP id x4-20020a056402414400b004316ef0bef7mr43378550eda.151.1658239066060; Tue, 19 Jul 2022 06:57:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658239066; cv=none; d=google.com; s=arc-20160816; b=g+1LlxucWMJmkTxf6fNuGVqZROnefxyJkybGnTyINNjXrN3LLh3g3TufEB9a0t6swm vR/E1lzBl84Nu1nnX2GcHGQj14ejUt0uBEqqxcGzxucccu4mNYq9xsBOznzAcBM2Yswg d30fvHIp/OFDYtJM699AOaPp5Oix+x0fiQXyNxzB6prmHpAVSZtTDJmpU9cOlQjO6/oz TBco6rOlUGzIYLWYTAI4VjpXpg6H7dBIobM4kVX5SeT3y8VfFVvnOKSLYPkwCSnjuLdM i77yP1A70VPO9adiLQtta/OSVmS5m5lzvfagqWsqjrObfZvYR3aTXV/sJI06CzAZkmUR rMuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HX5ewVC6fOipFC4QayqZQ4+BjkFCdBJJYyMkuZEwiuo=; b=O7L4boWRWUAnzsFkU0b+QEvGLmnYeROlpv0zOoIPWnw/3e4+x0sic6c8j/qMB+hny+ qSqOP834nJZ5YkTMxkSTDheMmVp27fec0jYX4xxOtRMD1ZV00Ry+xW2s1joFWK6IpidE WCT5pyWtY7qDsrYksQIPITYIpBzOEkP2s159V5Ty956PXMxwV0NHKl74uWOOB+BnpAem 25HJPvZx6k1S/WPzYUrfTVYZKmh2W5ndQ7GM2U543T894RfbsyKhETYvmk+WxgK7W2Ni T7zrSKw9C6yE3pFqO+scKEa8KHiyh3b+RsUn+Ghea/7xvkeQkxFTT/PoU/xaLaY/KgpW 6tSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JJCRuPrn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ht12-20020a170907608c00b0072f05757268si16152267ejc.132.2022.07.19.06.57.20; Tue, 19 Jul 2022 06:57:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JJCRuPrn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242752AbiGSNB4 (ORCPT + 99 others); Tue, 19 Jul 2022 09:01:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242706AbiGSM72 (ORCPT ); Tue, 19 Jul 2022 08:59:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C61E74F685; Tue, 19 Jul 2022 05:24:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 53EFF61921; Tue, 19 Jul 2022 12:24:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22E5AC36AE3; Tue, 19 Jul 2022 12:24:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658233481; bh=T0O0KgkJt/ofJDvterLLW1GOiWLpCRtQ9l7LyqAHt2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JJCRuPrnXS0CdgmwHLaKQBHvQaR+xxQXENnxEE5JkZqN/e+rUKb8g3rHbo4VHuDAq cWbhFkeLcGspJVTIqYCEdn1QuhQ4JIiLVbbRlSv/or3iyVdYDnB55NFnJpZNyJZrnX /nFtsTcYsIyIY4NjACbiu0vfDWGo2bF+5r9diskQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Abeni , Andrea Mayer , Sasha Levin Subject: [PATCH 5.18 136/231] seg6: fix skb checksum evaluation in SRH encapsulation/insertion Date: Tue, 19 Jul 2022 13:53:41 +0200 Message-Id: <20220719114725.865735173@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114714.247441733@linuxfoundation.org> References: <20220719114714.247441733@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrea Mayer [ Upstream commit df8386d13ea280d55beee1b95f61a59234a3798b ] Support for SRH encapsulation and insertion was introduced with commit 6c8702c60b88 ("ipv6: sr: add support for SRH encapsulation and injection with lwtunnels"), through the seg6_do_srh_encap() and seg6_do_srh_inline() functions, respectively. The former encapsulates the packet in an outer IPv6 header along with the SRH, while the latter inserts the SRH between the IPv6 header and the payload. Then, the headers are initialized/updated according to the operating mode (i.e., encap/inline). Finally, the skb checksum is calculated to reflect the changes applied to the headers. The IPv6 payload length ('payload_len') is not initialized within seg6_do_srh_{inline,encap}() but is deferred in seg6_do_srh(), i.e. the caller of seg6_do_srh_{inline,encap}(). However, this operation invalidates the skb checksum, since the 'payload_len' is updated only after the checksum is evaluated. To solve this issue, the initialization of the IPv6 payload length is moved from seg6_do_srh() directly into the seg6_do_srh_{inline,encap}() functions and before the skb checksum update takes place. Fixes: 6c8702c60b88 ("ipv6: sr: add support for SRH encapsulation and injection with lwtunnels") Reported-by: Paolo Abeni Link: https://lore.kernel.org/all/20220705190727.69d532417be7438b15404ee1@uniroma2.it Signed-off-by: Andrea Mayer Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/ipv6/seg6_iptunnel.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c index d64855010948..e756ba705fd9 100644 --- a/net/ipv6/seg6_iptunnel.c +++ b/net/ipv6/seg6_iptunnel.c @@ -189,6 +189,8 @@ int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh, int proto) } #endif + hdr->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); + skb_postpush_rcsum(skb, hdr, tot_len); return 0; @@ -241,6 +243,8 @@ int seg6_do_srh_inline(struct sk_buff *skb, struct ipv6_sr_hdr *osrh) } #endif + hdr->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); + skb_postpush_rcsum(skb, hdr, sizeof(struct ipv6hdr) + hdrlen); return 0; @@ -302,7 +306,6 @@ static int seg6_do_srh(struct sk_buff *skb) break; } - ipv6_hdr(skb)->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); skb_set_transport_header(skb, sizeof(struct ipv6hdr)); nf_reset_ct(skb); -- 2.35.1