🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10786

Re: [PATCH net 1/3] net: virtio: validate outer protocol of UDP tunnel GSO packets

#10786
From: Eric Dumazet
Date: Wed, 04 Nov 2026 04:49
81 lines
12329 bytes
Le mer. 4 nov. 2026 à 03:01, Willem de Bruijn
<willemdebruijn.kernel@gmail.com> a écrit :
>
> Eric Dumazet wrote:
> > virtio_net_hdr_tnl_to_skb() trusts the virtio header to describe a
> > UDP tunnel over IPv4 or IPv6, but never checks that the frame actually
> > carries such an outer header. Because VIRTIO_NET_HDR_F_NEEDS_CSUM is
> > mandatory for tunnel GSO, __virtio_net_hdr_to_skb() skips the flow
> > dissector, so virtio_net_hdr_match_proto() is never applied either.
> >
> > A guest (or a tap writer) can then inject a frame with an arbitrary
> > outer ethertype, for example ETH_P_NSH, with SKB_GSO_UDP_TUNNEL set.
> > The GSO stack then runs nsh_gso_segment() on top of the UDP tunnel
> > segmentation, which assumes a different header layout. The result is
> > segments with skb->data before skb->head, and a host crash in
> > skb_under_panic() as soon as a later layer pushes a header:
> >
> >   skbuff: skb_under_panic: ... put:4 ... dev:gretap1
> >   kernel BUG at net/core/skbuff.c:215!
> >    skb_push
> >    __gre_xmit
> >    gre_tap_xmit
> >    ...
> >    tun_get_user
> >
> > Require the outer L3 protocol to match the declared tunnel type:
> > for Ethernet frames, look at the ethertype after optional VLAN tags,
> > and check that the outer network header fits before outer_th_offset.
> > For IFF_TUN, skb->protocol is already set by the caller.
> >
> > Fixes: a2fb4bc4e2a6 ("net: implement virtio helpers to handle UDP GSO tunneling.")
> > Reported-by: Hassan Sultan <hassansultan@google.com>
> > Signed-off-by: Eric Dumazet <edumazet@kernel.org>
> > Cc: Willem de Bruijn <willemb@google.com>
> > Cc: Michael S. Tsirkin <mst@redhat.com>
>
> Thanks for the fix. It overlaps with
>
> commit "net: resolve uncommon partial checksums at ingress"
> https://lore.kernel.org/netdev/93d0e37c99711bebdf60c120af03010455c2f2e2.1793276116.git.mst@redhat.com/
>
> There are a bunch of subtle issues here. That series is up to v7.
>
> Two specific issues are that
> - skb->protocol in general cannot be trusted, and
> - non-L3 sources cannot be assumed Ethernet

Agreed on both. With IFF_TUN and a tun_pi header, skb->protocol is
whatever userspace put in pi.proto, and v1 would accept an IPv4 tunnel
frame whose IP version says otherwise.

>
> Would it make sense to take the relevant parts from the quoted commit,
> which has hopefully resolved those edge cases, and send that on its own?
> The rest of the series can come later.

Done in v2: patch 1 now uses virtio_net_l3_start(), virtio_net_l4_start(),
virtio_net_ip4_parse() and virtio_net_tnl_offsets_ok() from Michael's
v7 4/5, unchanged except that ipv6_find_hdr() stops at AH, as you
suggested in your v7 review. The checksum validation/completion parts
and the non-GSO carve-out are left to Michael's series.

Michael, I added your Co-developed-by and Signed-off-by, since the code
is yours; please let me know if you prefer a different attribution.

v2 also adds IFF_TUN tests with a mismatching tun_pi protocol, and
addresses your comments on patches 2 and 3.

One side note: virtio_net_hdr_tnl_to_skb() uses
outer_l3min = ETH_HLEN + virtio_l3min(outer_isv6) for IFF_TUN too, so
tunnel GSO frames without an Ethernet header are rejected unless the
outer IP header carries at least 14 bytes of options (the tests pad
with IPv4 options for that reason). This predates the series, I left
it alone for now.

Thanks!

pw-bot: cr
Technical Details
Message-ID: <CAL4WiipSx0h-zFwHR-CPLi0dVo3EwhhKgSqhQa1SaKixKSRiaQ@mail.gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356187-linux-kernel-netdev=dewy.ru
References: <20261103203113.550604-1-edumazet@kernel.org> <20261103203113.550604-2-edumazet@kernel.org> <willemdebruijn.kernel.2e11b18d6e190@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356187-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 1/3] net: virtio: validate outer protocol of UDP
 tunnel GSO packets
Date: Wed, 4 Nov 2026 05:49:48 +0100
Organization: Usenet Network
Message-ID: <CAL4WiipSx0h-zFwHR-CPLi0dVo3EwhhKgSqhQa1SaKixKSRiaQ@mail.gmail.com>
References: <20261103203113.550604-1-edumazet@kernel.org> <20261103203113.550604-2-edumazet@kernel.org>
 <willemdebruijn.kernel.2e11b18d6e190@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="3327401"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Dk2orbZ+yw2ojzhQO6bSG20I5Ps= sha256:Rz4wLcqSCN/iC9asXhZjH9ZRftd9b5hFeIUl+jJdkC8=
	sha1:s19khVLK1w2rjm9UArtwQZ5/4pA= sha256:MCUDy2QruITkwLGOXoJow62CYul1x4HksvMtLKscQPw=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 9E640112ADB; Wed,  4 Nov 2026 07:50:23 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id nP0zm9aweCWz;
	Wed,  4 Nov 2026 07:50:16 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-356187-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 4BEB9112AD5; Wed,  4 Nov 2026 07:50:06 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 610766066A3; Wed,  4 Nov 2026 04:50:05 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793767802;
	b=Abp563ir09UHphFOIU1adsPz1XI7bwGhpEkCjWZ177wxYHQu7nQ2tGgF2tan/Mbudxsv
	 lJr3LdxCLYqp8M3KEcugDeIwbbuiUXTSEEqjn7zwknnFEopgcqlbycB39lX0NkiEWI3fq
	 ZpgI53isL9qtyS4VRJbm9PQIkqc23LCtSGQoq9ZzhibVEHIArXtX+42bh3muVCgKrL8+V
	 Tl570yyMSBcMpMy0oMr2bLKZGuSEAmZfO+TsN6tSfNnURUhtA+s4TMeMpgR/D4oscRPvw
	 ySYan4pqQTODPq4jgi5TzpeVxm6Ovfo/352G6bmil7avN5O57ooR8ULjUstheUfaRPw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793767802;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:
	 X-Gm-Message-State:X-Received:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:References:In-Reply-To:From:Date:
	 X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=qvTB6orR9VnOe8lzo+/JurYDotlGDFrB0B/lCSPx3t4=;
	b=D0c4zfzeYh8gn+5VqMkr1vpTRA8W3qYZhxdN159mVZ3MQN8mBdo/aghmL3UUXRPjqUus
	 IojmabPv5mbuKLh9K/J0FSqaZQYJewXIkdFK9d/8SXqcFUYjIR6UQd7efI3jcCzcm8pHP
	 ahrS5LI0qXhf8cl2l5aHZJA2xrLNvp71A9hlEH4T+imsXNAUDuuAaG6VNI/93pFUV060V
	 saKPNVcZn2JECTOUmh+0hm2xatNlUfjb8PvT2xbOMM59a+zFdTSFptWydqRslf8Jj4MrI
	 LYIm2Z0vG7ahfJYEZvL5fqw0HQUVFuGBdJNhu4+217xp/eqERq2fJnBaIXgW+jrSAmQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OGWSztWO;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id A7EF1606A33C;
	Wed,  4 Nov 2026 04:50:02 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OGWSztWO
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793767801;
	b=jo5JtQWOClZbGcpAH7ahht4cWMb6BqVgV/Uq/6ZDA2T2LpIYQ2o2iIbBTxsYuAedAN/h
	 fP9gEAf2qAyVglWRXwh9QYuUdtHzNbaKL07n0pCfmEtYZtd1OPguZFziANDqmHeHezvy1
	 ud5xZ9WvKMnG099qr0N1udDW20zFEem5ek23srbLB9Nsqi+pFm8oTosK0HYjCKLEzk4fR
	 eSSokuGhhBjsp8DF+42ExctjBIyFJXeLqJmYdLq5EM1Mj69NHqxC7VRe2HSSgeIFNC0MG
	 32Vx0/H6N9/dJ58IFhE59RtHOJHyDUwr89F7kHNSzMHEQEautZGUL0dLp1Tfzo+u0FA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793767801;
	h=Received:DKIM-Signature:Received:X-Gm-Message-State:X-Received:
	 MIME-Version:References:In-Reply-To:From:Date:
	 X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=qvTB6orR9VnOe8lzo+/JurYDotlGDFrB0B/lCSPx3t4=;
	b=oodA+5Ioj9wVO/ygNESulU+QzcyyAosWE3DiUJojxU/ZyVSHcXijcGJJdA1Rk6tb/LAF
	 D6GvpN/XgPvsro9JiViOTwxq+HIR5bdPW2wzI8ey5GBgg7Cvj8a5tl6E6NqNQa5yr9NF+
	 KM6NWwq/b6iEKxpPIM1C0ByRtHzoHH0ty6TGfkVwjiTOlwPAvlmsw9sYceh3uWW44IUaR
	 TAG1kf/1x8cPc4VH9avuz0JJzNkoEq/dHpUeEgE/rY/4hDW46Ozojpgiskmf1X1kQ6J0x
	 kTRMWxbcR9CutR54zL1xv3+xZXBEmIxZsxmzwvmbS4AlZdWhNK6BNK1y98D3e5sNXHw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OGWSztWO;
	arc=none smtp.remote-ip=100.103.45.18
X-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 47807606A329
	for <netdev@vger.kernel.org>; Wed,  4 Nov 2026 04:50:00 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDE071F00919
	for <netdev@vger.kernel.org>; Wed,  4 Nov 2026 04:50:00 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793767800;
	bh=qvTB6orR9VnOe8lzo+/JurYDotlGDFrB0B/lCSPx3t4=;
	h=References:In-Reply-To:From:Date:Subject:To:Cc;
	b=OGWSztWOlnSC49QWCnONMoxB548HtMJ3i+EbtpVkfmP86vwGg3IwMgF/6eJHgI2cj
	 /0fSbUFEPm1ibfocgjpcMFr0S1E66EZ0b9m1hYJGudE8ouJXU1nBuvI48F3SfzB+yx
	 wYgqNNr9Q4K90k2j8cPoRSUbr+UHs/UrGy5yCSPxu/DVt/DV0YXKkX7OWCy3LGmU9/
	 8mc/az6AYqmu2Gc/NZxO1wIEWWPNzcdxrpTEWUNi+bvKpvkQC3f/LPLSe9J4yU5lhj
	 xAJRF2rxgBplb17VDWIaSocjvaS9YbXlxukIrYjFDvhyi4ORIwxRzSstpEs4hPk+FX
	 yZ0Nd+zD3tPig==
X-Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-46556b9e02cso160571fac.1
        for <netdev@vger.kernel.org>; Tue, 03 Nov 2026 20:50:00 -0800 (PST)
X-Gm-Message-State: APuU4Z9ww/fnLUPbuPr3kssTxBj1y1STrTKvbtyl1BqI7FkpsI7Ad/cs
	ar1oi5T5Ytb/0u4ueQlbCipVh0EV4UFs+n6smJMXLuBjgUnEBGDh8d0vtawE5jl8QmSdrL2+3I3
	+YD41YEF9rci0eP7h2bG9+0cvk7z1YpI=
X-Received: by 2002:a05:6871:203:b0:4a2:4e0c:5964 with SMTP id
 586e51a60fabf-4a8e099d9dbmr9359126fac.18.1793767800077; Tue, 03 Nov 2026
 20:50:00 -0800 (PST)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <willemdebruijn.kernel.2e11b18d6e190@gmail.com>
X-Gmail-Original-Message-ID: <CAL4WiipSx0h-zFwHR-CPLi0dVo3EwhhKgSqhQa1SaKixKSRiaQ@mail.gmail.com>
X-Gm-Features: AclHuK_Xn8BTM2XHTtAW8fRMMiq8m8CUtMjMGhCCbjgo-W_Yc0MLwBl7Lw5xvW4
X-Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>, 
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, mst@redhat.com, 
	Simon Horman <horms@kernel.org>, Willem de Bruijn <willemb@google.com>, 
	Eugenio Pérez <eperezma@redhat.com>, 
	Hassan Sultan <hassansultan@google.com>, virtualization@lists.linux.dev