Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1874643pxk; Tue, 1 Sep 2020 09:45:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiGwGj0nycfo2+5BeLDabNBB4IV8fGdlxgNniNlLEcSnEZ8NhEurRDeqBq/MYHR4gPMcKi X-Received: by 2002:a17:906:22cc:: with SMTP id q12mr2276501eja.78.1598978755238; Tue, 01 Sep 2020 09:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598978755; cv=none; d=google.com; s=arc-20160816; b=Eri/cuFXCXEzGKFVI6sWdfesQx8LC99PpnVu9QEZcl9y/hT9nVGCo2QFLsOFEsfZpU c9HgwfgcHENRYkUjAlagsrzuJuU59jPBCwL+iJvfZtkj67z/dzgfo9dwd7XkvAUXQ9s0 0zaueKSI9m/WKHUDGoFHTj/Z2ioJwkFlpSZWGtZuoel69t0yOOWcP6svyPfEmWTE08Kr HJYz7IT4QD4u7QOlraKtABCBiih3RCwEVCmudbiwFDjgOaOsdGuIqNiGq3z5o7Qp63+Y gGLfnwWYNV8JCmHdf4M8R6yngq0tLR9CYKNHDNSAuMEnHy/Q+0J7HsEMrSqO2DZsOtPw +Aww== 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=hCYAxf85qcdhiRa6ydO8DU+jWWwc1e3aW+s6YRd4n4w=; b=NryS8W73Pbu+clHa74iXVKT/zs8UB5yWI5gf0mU8ZVjgBkzzSa/ck8xFtBAdKLX9C9 BYwQkZDYPHR8e1q32Pi6U2tHfDiUMkSWKbi4BjLmEvhmqs1dsplVsQb44/d9ypsIJLuy z/L0sdMzH+6xe2gU/txrXzV0aKb6She9eqElC6afWSu7/ndR+HYHv3fRWRrEZQwyMuJ7 4s4xkp0cTuwYYFxQM5klwm0GepkvX7rc0DJpZy/1ojppZHsPKRnCWjzm0HxtLnf1xFRr oMN9kjiuOpmai/mJjpUTgp7PtNmcGBVTctyTKJBRYT1SYDQBCWzgTMKaalLiEHj6aXZL KLbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=u3SA1S4u; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rh17si903939ejb.256.2020.09.01.09.45.30; Tue, 01 Sep 2020 09:45:55 -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=u3SA1S4u; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730256AbgIAQpB (ORCPT + 99 others); Tue, 1 Sep 2020 12:45:01 -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 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: 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);