Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1892872pxk; Tue, 1 Sep 2020 10:10:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKOn45rtgkKFKVTtcnaFtZtpya/X7NRQ7tERVOhcKvE4lMZsvnB5mZL6EB17PMaVma0Rko X-Received: by 2002:aa7:c4c8:: with SMTP id p8mr2508419edr.231.1598980225332; Tue, 01 Sep 2020 10:10:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598980225; cv=none; d=google.com; s=arc-20160816; b=0vbhTZeUOiPidXqqRejfe7F/uDTTSZMv77f7/6TH0Xwkkj/VdrJUioYuXw55gq8paY XlykMXodHlnyj1jiFojaR9E5O3YJnA/XY7ovwrkZ4qExlz14b4qxEehy3wmpdgjXnKHG ILrkKKiwE7DoorDyPj3LuJrTazSMmskKj5gHpLkknTFs1EwuuJQ+Nwl8mn8ni74gqCfn drzGZx38Rmx3f/48nzhOVZtctFrM8uPOsATvA/k7WlCaaqQ5jDrr8SZTtSlhf8WYrFt8 zmVYVlv6J+BG21nmBTrmGGOKDwuGGKBw/qIBAFr0QTXZrWbyJ3bKTk4Ihq5Suhp+GQVi 1HSw== 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=nbrtFG3LRqyfYJVIU15z0DJQGnOF5h9irRSy8Kx/Iko=; b=ZoPOYeIyvIA4qyO8YeHJNnI1YhLx77wPSirfe7KfIWFLe7koRpjx9T1aQy3BLDyg0h /wiSzezimz5GXCjUlcsmOwi/3f+MUYx5JYBvetP0PmZ5df+RwKi7WvPcwpT1u+ctiCXj NmX2CPhENJz5FdINpiY1MgJJojiJtmAPFzhsWGrjYtihU63qBWuE5m5bHVMgjgc6T6bj EPphk3Ezf8BQVgQzq0mz/DlHKRO2UNL+BhtVEGwxPx3yOcJJ7gj/8NehJvLBwLOHMTI5 I8Fz0sIbOfJRDHZ8Yu/VTgvbQ5GmWfZlVP4NmRGAR8kHs+dlR65h2kWVgvKCLyH5UJF4 /HkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ERWxrLom; 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 v6si1002486ejc.37.2020.09.01.10.10.01; Tue, 01 Sep 2020 10:10:25 -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=ERWxrLom; 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 S1729556AbgIARH1 (ORCPT + 99 others); Tue, 1 Sep 2020 13:07:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:37074 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727786AbgIAPSh (ORCPT ); Tue, 1 Sep 2020 11:18:37 -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 989A9206FA; Tue, 1 Sep 2020 15:18:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598973517; bh=TkDQcsAX3HHNrBrO+Mb/QHzzrFQRrw+VNf7CO+9GGfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ERWxrLomp9X8FyQidWrVwFafeFDEOdimE5hPP0addmqlm425ujenPhtOni984e0dj len/kwR2jNYjabMmxPIb5GzQmnXP5CryprnNDH70ZdgopIiiQ3sJM1SBzSzgQi5p9H AOyi6XaRBdjS5gFgr8r5IwiK3+wclLx+lECpgVBk= 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 4.14 05/91] gre6: Fix reception with IP6_TNL_F_RCV_DSCP_COPY Date: Tue, 1 Sep 2020 17:09:39 +0200 Message-Id: <20200901150928.383698607@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150928.096174795@linuxfoundation.org> References: <20200901150928.096174795@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 @@ -872,7 +872,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, NULL, 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, NULL, dscp_ecn_decapsulate, log_ecn_err); } EXPORT_SYMBOL(ip6_tnl_rcv);