From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CE971DED63; Wed, 6 Nov 2024 13:17:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730899035; cv=none; b=Lz2tPqc1r+TLLca9dF53tzBba/yc2b+Zr+SuubpuU1f/19XEHp4OIVGBRS3uhM4TqfRiHZQIerOmrwbb+UZ+fo+a5E9kSKXGHy7qRX6NbEr1bcq/5vY/O7+Yrh/MUgnbFXTM8v49LsGWOBDvb3hrrXivz3Kjam4tMy4joahdE0s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730899035; c=relaxed/simple; bh=usGgYjs5oF5lV5eW/ltjnt4N5OFZyCE76iWKZHHAc9g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jNuDs1z/w/T0aA2gpdV7FzxGtqjY6rDJhN39C4gjKX81/pD7uIs5Z1BqLa7FBQjDeFPCg0gQ1Lx4TcucJtfBh6aPJP1OZpUT8aBQTErB1c2rr3px3oDE/FuyES6eoC54Q6ZwVWnFHwcPZ3yuu/iWc/vP/7cl5cfyLSVkjsEdyrw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IxunuMGT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="IxunuMGT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDCB1C4CED7; Wed, 6 Nov 2024 13:17:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730899035; bh=usGgYjs5oF5lV5eW/ltjnt4N5OFZyCE76iWKZHHAc9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IxunuMGT77AaQ/o5cdx3Lyy0UhGLas5FHTomBszjAKwzigR4VjVyq0w6kw0iha78y cJqninCRQrqpLVbyDF7KZagn5rpAcc28EY5SSQSgkyJ1Ip2VFCaa7yqFjqbBagDAmO QxZOwn+N4SWg7WS2GcZTnwiURo+0FdkhPxkd35TE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Beno=C3=AEt=20Monin?= , Willem de Bruijn , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.4 440/462] net: skip offload for NETIF_F_IPV6_CSUM if ipv6 header contains extension Date: Wed, 6 Nov 2024 13:05:33 +0100 Message-ID: <20241106120342.368364001@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106120331.497003148@linuxfoundation.org> References: <20241106120331.497003148@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Benoît Monin [ Upstream commit 04c20a9356f283da623903e81e7c6d5df7e4dc3c ] As documented in skbuff.h, devices with NETIF_F_IPV6_CSUM capability can only checksum TCP and UDP over IPv6 if the IP header does not contains extension. This is enforced for UDP packets emitted from user-space to an IPv6 address as they go through ip6_make_skb(), which calls __ip6_append_data() where a check is done on the header size before setting CHECKSUM_PARTIAL. But the introduction of UDP encapsulation with fou6 added a code-path where it is possible to get an skb with a partial UDP checksum and an IPv6 header with extension: * fou6 adds a UDP header with a partial checksum if the inner packet does not contains a valid checksum. * ip6_tunnel adds an IPv6 header with a destination option extension header if encap_limit is non-zero (the default value is 4). The thread linked below describes in more details how to reproduce the problem with GRE-in-UDP tunnel. Add a check on the network header size in skb_csum_hwoffload_help() to make sure no IPv6 packet with extension header is handed to a network device with NETIF_F_IPV6_CSUM capability. Link: https://lore.kernel.org/netdev/26548921.1r3eYUQgxm@benoit.monin/T/#u Fixes: aa3463d65e7b ("fou: Add encap ops for IPv6 tunnels") Signed-off-by: Benoît Monin Reviewed-by: Willem de Bruijn Link: https://patch.msgid.link/5fbeecfc311ea182aa1d1c771725ab8b4cac515e.1729778144.git.benoit.monin@gmx.fr Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/core/dev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/core/dev.c b/net/core/dev.c index ff62b0027d600..b75c9bebd5c6e 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3267,6 +3267,9 @@ int skb_csum_hwoffload_help(struct sk_buff *skb, return 0; if (features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) { + if (vlan_get_protocol(skb) == htons(ETH_P_IPV6) && + skb_network_header_len(skb) != sizeof(struct ipv6hdr)) + goto sw_checksum; switch (skb->csum_offset) { case offsetof(struct tcphdr, check): case offsetof(struct udphdr, check): @@ -3274,6 +3277,7 @@ int skb_csum_hwoffload_help(struct sk_buff *skb, } } +sw_checksum: return skb_checksum_help(skb); } EXPORT_SYMBOL(skb_csum_hwoffload_help); -- 2.43.0