From patchwork Tue Sep 1 15:08:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 264542 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0810C433E7 for ; Tue, 1 Sep 2020 16:45:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75BB820767 for ; Tue, 1 Sep 2020 16:45:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598978711; bh=bpAPGWFkXj0y4Gl9wBaXlkTFfrLh15LKfUJ8jWWZ0SI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=u+iAZdfnZs0XEp9XxjW53ExqoyPoBqM80mTddbLmM39k6LBTFIuz1YutjUkk2aVjW 8PcE+q5o5eeSUEMKkYQsIj1WiuFktjf619E0/vwOB8zLQ7bmIdBV4RLmNmErAoWMnL LEVgJAvk/VDkYIxdF3T46qS6kYk97gu/w3WVWL/Q= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730234AbgIAQo6 (ORCPT ); Tue, 1 Sep 2020 12:44:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:54742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730219AbgIAP1g (ORCPT ); Tue, 1 Sep 2020 11:27:36 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 DB6DE206FA; Tue, 1 Sep 2020 15:27:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598974055; bh=bpAPGWFkXj0y4Gl9wBaXlkTFfrLh15LKfUJ8jWWZ0SI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u3SA1S4ulj+kaGLtRYHfGwFWgcFcTRynPnZ6IGsRgP76ro+kskTRu0aMnCM3RJk0I dUmy1+cEQ/Ae9sEmTZsFqW3taHRRMo/sAwqUdrgBly41Ch9OsFAEUbm/JlNZPDhipo m6XtFsNdRSfrMTnFmG8l2hJStbln3eYXrEtWwPKE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Tomlinson , "David S. Miller" Subject: [PATCH 5.4 003/214] gre6: Fix reception with IP6_TNL_F_RCV_DSCP_COPY Date: Tue, 1 Sep 2020 17:08:03 +0200 Message-Id: <20200901150953.122920456@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150952.963606936@linuxfoundation.org> References: <20200901150952.963606936@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mark Tomlinson [ Upstream commit 272502fcb7cda01ab07fc2fcff82d1d2f73d43cc ] When receiving an IPv4 packet inside an IPv6 GRE packet, and the IP6_TNL_F_RCV_DSCP_COPY flag is set on the tunnel, the IPv4 header would get corrupted. This is due to the common ip6_tnl_rcv() function assuming that the inner header is always IPv6. This patch checks the tunnel protocol for IPv4 inner packets, but still defaults to IPv6. Fixes: 308edfdf1563 ("gre6: Cleanup GREv6 receive path, call common GRE functions") Signed-off-by: Mark Tomlinson Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/ip6_tunnel.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c @@ -860,7 +860,15 @@ int ip6_tnl_rcv(struct ip6_tnl *t, struc struct metadata_dst *tun_dst, bool log_ecn_err) { - return __ip6_tnl_rcv(t, skb, tpi, tun_dst, ip6ip6_dscp_ecn_decapsulate, + int (*dscp_ecn_decapsulate)(const struct ip6_tnl *t, + const struct ipv6hdr *ipv6h, + struct sk_buff *skb); + + dscp_ecn_decapsulate = ip6ip6_dscp_ecn_decapsulate; + if (tpi->proto == htons(ETH_P_IP)) + dscp_ecn_decapsulate = ip4ip6_dscp_ecn_decapsulate; + + return __ip6_tnl_rcv(t, skb, tpi, tun_dst, dscp_ecn_decapsulate, log_ecn_err); } EXPORT_SYMBOL(ip6_tnl_rcv);