Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp165234pxa; Wed, 26 Aug 2020 07:31:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwld+9W3QkKt4qIX3xbteZCwaiO9s5FFauEzSQGTx2oFGdOb1OmcPtC8ga17sa+pvIlM1qK X-Received: by 2002:a17:906:394c:: with SMTP id g12mr14864774eje.255.1598452289150; Wed, 26 Aug 2020 07:31:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598452289; cv=none; d=google.com; s=arc-20160816; b=zGnDrQ2QFDayA1RDOwSgQCP9htEpYiA/zgMceBph9DrgaUxgwrVGQcRVA6GvxlMQmz /axeLoXzucxCD+LUFoQEnNxKPGNQ7MIl5kR9To6WRWP+6ZO+5KinUnwa65M59EYodDaM RChrwxBBpETcdGy5fGqS6pSL5gQTpBQUQXmiqNfi8GAQ+9aJuQ9BNgiGrF0+5RnrMQer 5XE/A/jMSOD5zNWt9cJ+4R4NODxh5R3nBrPP85vD8u/IVV28zTZqZrTzokA7q7Z6REJ6 6fIS7uOpAFLCIInUPvbL10fHh7BAejBbPMU3N7ZJbgkB853C/Kn80XSitqWS980OshSg BW1A== 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=4yIW8KjvpqojwqHDyfrJZSoPzpOVQX5jeci5MPWpLYc=; b=FZp0eo1E8JMH7tU5CvUr4TJw1MPOvBlKZL4O/Z6zliQk2MchxBdWC5IqtJ5imc206V t6hemIfS0VussqIVSOeiLRcmh1VBMua/Jbt0H2uTkVJcoQca0Dz/Xtt3AT705j+Wu8fU A4WvhDvBTdEop4bXJfDrXYva24FvXn2k5q80+ZL0qbDU1apNl3O28D9PtJjFQ3qkW5Fm /YwkmaRBEEuSc3QE8YEobw0iA8Glpnzx1mq8LIDJuhEL5xMPQn3wIKKSY47X0zZffzKY VAkTw6/OQ+JDIuLmu6MbAPEaAFimPN4LrPXW8L6CttMHTTSutsqxk7VX+g/60TUa8zOg vk0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C7UJd0wT; 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 q20si1761618ejb.45.2020.08.26.07.31.06; Wed, 26 Aug 2020 07:31:29 -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=C7UJd0wT; 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 S1729513AbgHZMDR (ORCPT + 99 others); Wed, 26 Aug 2020 08:03:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:36406 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729445AbgHZMCa (ORCPT ); Wed, 26 Aug 2020 08:02:30 -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 20B4720786; Wed, 26 Aug 2020 12:02:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598443349; bh=y37TjwnN3ZVstO0ILROloWPnz1AJ4Je3xR4/WMvMAvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C7UJd0wTgivjveibVHseFAjcXGiwHa4u5y1aicrR7NrQVGIL/ihZT/X9nQkX9iGJM 2206faJN7LWlVxhQnlEt//s94De1w6z+BnuhvNQ+3ZlraiewAX+mjxhE5bvtNoxbj6 43lqLpKXl+M+PplExX3bwknCtFYGXaHbY6Z1smE8= 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.7 01/15] gre6: Fix reception with IP6_TNL_F_RCV_DSCP_COPY Date: Wed, 26 Aug 2020 14:02:29 +0200 Message-Id: <20200826114849.371310385@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200826114849.295321031@linuxfoundation.org> References: <20200826114849.295321031@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore 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 @@ -886,7 +886,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);