From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795619269; b=YgHKBpsUuFMRMFVphgISiDhS3tw072yXhK6hWwGdN/aXJ0UliIyHmV9nI66Qo0LJp2dr v7epQXBHABcNO+BmqNVOUPAcxyNmKOfbVPtyeWEMY7KX6iVVK+jTbHJmqmNNdnXUROEIJ OemN2YhPktA9lWmbI/BDqE8rOx4VrmEQJzcesS60vtrVZoVr+ULwHJwYkOvs6Tbj4xAkn kK9e9hc576X+IrHGeD9n3nUnQeu9j7/GYhzDaY3IW9HZvjPNVVb3XC7RGmmP5PdniqqLZ 5BgKRYujKJmR1VU8lgi+43FZi+PNi6FkVkqYDojWPbJG1RKvdUbOCqDVpegRR2Yzuyg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795619269; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=w7IOAubTkQHvxEzy20k2vQaPCMy1jdeIhSSeZLj2Z4A=; b=CgOFnINNBtoRP5RZzP8+Z2pjgRiBhVXKUohG4lrPys4oF0oZ+/nL0/YnFvzI9VooEHGX YVuvW/j+qlc4nX9zSKDRJ9kT57J86OexWmmFy84RjD8Lm5vZkkJMxsaDSZePxex+du64o kMk+tV9WtQOuSCwVDLDosXMaPD1P/tI047Q+0o2La3FF2AN5GfQ0FB5+STq980+cFhsh8 V/8PavUeAivnm7h5Toj5ZoIEkMB5cFqfQSAf1aqNxDyaiq2qJqwd0v5hwbIKnVUUD9UZE fOGPtfnV5WlZey2rRSYt6x7kswSEYnh3ZGICXE4WJr/Posm9iZWrN2HnK8NmoYj8eGQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=nPOunPy5; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7E01606A321; Wed, 25 Nov 2026 15:07:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=nPOunPy5 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B98D91F000D1; Wed, 25 Nov 2026 15:07:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795619269; bh=w7IOAubTkQHvxEzy20k2vQaPCMy1jdeIhSSeZLj2Z4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nPOunPy5dNgpxpp6bX0KC9VWnSSMeeZKRp0CVlzPOSTZKNKzP2uJEJRWMyLcY044T KhFh2D+KxBtxnOQGg2X54qfov7mh28zRAPm8ocdNgBAE4jm8kuCi4g2bTYgEAgcwxn 3mkx1BLkRfNqYl/sgJG5JbZbkEuZNLUFsoclU910= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sashiko , Eric Dumazet , Jakub Kicinski , Sasha Levin Subject: [PATCH 7.3 0541/1005] net: virtio: fix UDP tunnel GSO header of VLAN tagged packets Date: Wed, 25 Nov 2026 15:31:19 +0100 Message-ID: <20261125143834.419546573@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261125143821.729802100@linuxfoundation.org> References: <20261125143821.729802100@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 9e244f94128a4b89004f0564b66e039e58318a34 ] virtio_net_hdr_tnl_from_skb() builds a wrong header for VLAN tagged UDP tunnel GSO packets. 1) When the skb carries a hwaccel VLAN tag, tun_put_user() inserts the 802.1Q header in the frame it copies to user space or vhost-net, and passes vlan_hlen = VLAN_HLEN. virtio_net_hdr_from_skb() adds vlan_hlen to csum_start, but inner_nh_offset and outer_th_offset do not account for it, and are 4 bytes short of the real inner L3 and outer UDP headers in the emitted frame. tun advertises NETIF_F_HW_VLAN_CTAG_TX and NETIF_F_HW_VLAN_STAG_TX in hw_enc_features, and its vlan_features keep the UDP tunnel GSO features, so this happens for example with a VLAN filtering bridge with a tagged port, or with a vlan device on top of a tap. 2) The outer family comes from skb->protocol, which is ETH_P_8021Q or ETH_P_8021AD when the VLAN tag is in the packet data, so a packet with an outer IPv6 header is reported as VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4. This happens when __vlan_hwaccel_push_inside() inserted the tag because the device does not offload it: virtio_net never offloads VLAN insertion but keeps UDP tunnel GSO in its vlan_features, and tun does the same with VLAN TX offload disabled, or with QinQ (outer tag offloaded, inner tag in the data). The receiver sets inner_network_header and transport_header from these offsets, and checks them with the wrong outer family. A forwarded packet that gets segmented again uses the wrong inner headers, and a receiver checking the outer headers against the virtio header drops the packet. Add vlan_hlen to both offsets like csum_start, and take the outer family from vlan_get_protocol(), which skips VLAN tags in the data. Fixes: a2fb4bc4e2a6 ("net: implement virtio helpers to handle UDP GSO tunneling.") Reported-by: Sashiko Closes: https://lore.kernel.org/netdev/179421814766.994134.3669228181251158303@kernel.org/ Closes: https://lore.kernel.org/netdev/179433950084.994134.15100186606737698605@kernel.org/ Signed-off-by: Eric Dumazet Link: https://patch.msgid.link/20261110213628.3476051-2-edumazet@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- include/linux/virtio_net.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h index b7b6b542f4763..fc9667176f23c 100644 --- a/include/linux/virtio_net.h +++ b/include/linux/virtio_net.h @@ -622,7 +622,10 @@ virtio_net_hdr_tnl_from_skb(const struct sk_buff *skb, if (feature_hdrlen && hdr->hdr_len) __virtio_net_set_tnl_hdrlen(skb, hdr); - if (skb->protocol == htons(ETH_P_IPV6)) + /* skb->protocol is the VLAN protocol when the tag is in the + * packet data. + */ + if (vlan_get_protocol(skb) == htons(ETH_P_IPV6)) hdr->gso_type |= VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6; else hdr->gso_type |= VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4; @@ -630,8 +633,11 @@ virtio_net_hdr_tnl_from_skb(const struct sk_buff *skb, if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL_CSUM) hdr->flags |= VIRTIO_NET_HDR_F_UDP_TUNNEL_CSUM; - inner_nh = skb->inner_network_header - skb_headroom(skb); - outer_th = skb->transport_header - skb_headroom(skb); + /* Like csum_start, the offsets must account for a VLAN tag + * the caller inserts in the frame. + */ + inner_nh = skb->inner_network_header - skb_headroom(skb) + vlan_hlen; + outer_th = skb->transport_header - skb_headroom(skb) + vlan_hlen; vhdr->inner_nh_offset = cpu_to_le16(inner_nh); vhdr->outer_th_offset = cpu_to_le16(outer_th); return 0; -- 2.53.0