Article View: linux.kernel.netdev
Article #11543Re: [PATCH net 3/3] selftests: net: tun: test outer protocol of UDP tunnel GSO packets
From: netdev-bot+sashiko
Date: Thu, 05 Nov 2026 08:32
Date: Thu, 05 Nov 2026 08:32
172 lines
14205 bytes
14205 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The new tests cover only part of the fix they are meant to
validate.
- [Low] virtio_net_tnl_outer_proto_ok() in include/linux/virtio_net.h was
added by the series commit "net: virtio: validate outer protocol ofโฆ
- [Low] Both tun_vnet_udptnl_proto tests build several frames in the same
calloc'd buffer (self->pkt) without clearing it in between.
--
selftests: net: tun: test outer protocol of UDP tunnel GSO packets
This adds a tun_vnet_udptnl_proto fixture that writes single 4in4 Geneve
GSO frames to a tap device with UDP tunnel offloads enabled. outer_proto_ok
expects outer IPv4 frames, optionally VLAN tagged, to be accepted.
outer_proto_bad expects IPv6 or NSH outer ethertypes to be rejected with
EINVAL.
> diff --git a/tools/testing/selftests/net/tun.c b/tools/testing/selftests/net/tun.c
> index 34de2580e32ec..47a24b9c477bb 100644
> --- a/tools/testing/selftests/net/tun.c
> +++ b/tools/testing/selftests/net/tun.c
> @@ -683,6 +683,136 @@ TEST_F(tun_vnet_gso, vlan_tcpv4_gso_no_csum_64k)
[ ... ]
> +FIXTURE_SETUP(tun_vnet_udptnl_proto)
> +{
> + int flags = IFF_TAP | IFF_NO_PI | IFF_VNET_HDR;
[Severity: Low]
This fixture only opens IFF_TAP devices. That means the IFF_TUN branch of
virtio_net_tnl_outer_proto_ok() from the previous patch is never run. Does
the assumption behind that branch hold?
include/linux/virtio_net.h:virtio_net_tnl_outer_proto_ok() {
...
/* L3 device (IFF_TUN): the caller already set the protocol. */
if (proto)
return proto == expected;
/* Ethernet frame, possibly VLAN tagged. */
proto = eth_hdr(skb)->h_proto;
...
}
The previous patch's commit message also says "For IFF_TUN, skb->protocol
is already set by the caller."
For IFF_TUN without IFF_NO_PI, tun_get_user() in drivers/net/tun.c copies
struct tun_pi from userspace. It stores the value as-is before
tun_vnet_hdr_tnl_to_skb() runs:
skb_reset_network_header(skb);
skb->protocol = pi.proto;
pi.proto can be 0 here. In that case, would the helper take the Ethernet
branch for an L3 packet?
The mac header was reset to the start of the outer IP header. So h_proto
would be read from the first two bytes of the IPv4 saddr, and nh_off would
be measured from ETH_HLEN.
For example, a 4in4 frame with an outer saddr of 8.0.x.x and outer_th >= 34
(IPv4 options) would pass the check. The skb would then go into the stack
with SKB_GSO_UDP_TUNNEL set and skb->protocol == 0, which the comment says
can't happen. With other saddr values the same packet would be rejected.
The downstream impact looks limited, because skb_mac_gso_segment() returns
-EINVAL when skb_network_protocol() gives 0. Even so, should the helper or
its comment handle this case? Would an IFF_TUN case in this fixture be
useful?
[ ... ]
> +static int build_udptnl_frame(uint8_t *buf, bool vlan, uint16_t l3proto,
> + int payload_len)
> +{
> + struct virtio_net_hdr_v1_hash_tunnel *vh = (void *)buf;
> + int vlan_len = vlan ? 4 : 0;
> + int hlen = ETH_HLEN + vlan_len + UDP_TUNNEL_GENEVE_4IN4_HDRLEN;
> + uint8_t *outer_udph, *cur = buf;
> + int pktlen;
> +
> + cur += build_virtio_net_hdr_v1_hash_tunnel(cur, true, hlen, 1400,
> + AF_INET, AF_INET);
> + vh->outer_th_offset += vlan_len;
[Severity: Low]
outer_th_offset is always shifted by vlan_len, and the outer family is
always AF_INET. Given that, do these tests reach all of the checks added by
"net: virtio: validate outer protocol of UDP tunnel GSO packets"?
virtio_net_tnl_outer_proto_ok() ends with:
return proto == expected &&
nh_off + virtio_l3min(outer_isv6) <= outer_th;
The length clause can only fail when a VLAN tag moves nh_off to 18 or
more. Without a tag it is the same as the existing outer_l3min check.
No case here sends a VLAN tagged IPv4 frame with outer_th_offset left at
34. If that clause were removed or miscomputed (for example in a stable
backport), no test would fail.
Every frame also declares VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4. So the
outer_isv6 side of expected is never tested either, for example an IPv4
ethertype on a declared IPv6 tunnel.
Separately, the commit message says outer_proto_bad covers:
(IPv6 on an IPv4 tunnel, or NSH, with or without a VLAN tag)
outer_proto_bad actually tests IPv6 untagged, NSH untagged and NSH behind a
VLAN tag. IPv6 behind a VLAN tag is not tested. Should the message be
narrowed, or should that case be added?
[ ... ]
> +TEST_F(tun_vnet_udptnl_proto, outer_proto_ok)
> +{
> + uint8_t *pkt = self->pkt;
> + int len, ret;
> +
> + len = build_udptnl_frame(pkt, false, ETH_P_IP, 2800);
> + ret = write(self->fd, pkt, len);
> + ASSERT_EQ(ret, len);
> +
> + /* The outer IPv4 header can follow a VLAN tag. */
> + len = build_udptnl_frame(pkt, true, ETH_P_IP, 2800);
[Severity: Low]
Is the VLAN tagged frame here well formed? self->pkt is calloc'd once in
FIXTURE_SETUP and is not cleared between frames. The helpers in
tuntap_helpers.h expect a zeroed buffer.
build_ipv4_header() never writes tos or frag_off. It also sums over
whatever is already in the check field:
iph->check = build_ip_csum(buf, iph->ihl << 2, 0);
build_udp_packet_csum() also sums over the existing udph->check. The
existing tun_vnet_udptnl test clears its buffer first in send_gso_packet():
memset(pkt, 0, sizeof(pkt));
In this test, the second frame's outer IPv4 header starts 4 bytes after the
first frame's. As a result:
- frag_off holds the previous outer IPv4 checksum
- tos holds the low byte of the previous IP ID
- the checksum is computed starting from stale saddr bytes
The inner IPv4 header and the inner UDP checksum are shifted and corrupted
in the same way.
This only passes today because the kernel path checks just the offsets and
the ethertype. If that path ever validates the outer IPv4 header, for
example by rejecting fragments for GSO, outer_proto_ok would fail for an
unrelated reason. Would a memset at the start of build_udptnl_frame() avoid
this?
[ ... ]
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261103203113.550604-1-edumazet%40kernel.org
Technical Details
Message-ID:
<179386753718.488856.13433005125725728519@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357149-linux-kernel-netdev=dewy.ruReferences:
<20261103203113.550604-4-edumazet@kernel.org>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-357149-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 3/3] selftests: net: tun: test outer protocol of UDP tunnel GSO packets Date: Thu, 05 Nov 2026 08:32:17 +0000 Organization: Usenet Network Message-ID: <179386753718.488856.13433005125725728519@kernel.org> References: <20261103203113.550604-4-edumazet@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3592588"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:iS5hGATvzvVOS1e0/AC8Au28ezQ= sha256:eWRTXlaL7VeN5zzTdmUQvl6A5oxJTJJw+/KjvM79ogE= sha1:JaQlQeJAbeBSQnya2i32Uafthz8= sha256:WV9Q4mLq8ADpKikVHf/L7ynjllfjbY7GzurTRrRcW1E= 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 A285B112ED9; Thu, 5 Nov 2026 11:34:14 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, 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 6okh2NovSnuR; Thu, 5 Nov 2026 11:34:10 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-357149-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 2F794112ED2; Thu, 5 Nov 2026 11:34:02 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id F0C9431B67; Thu, 5 Nov 2026 08:32:24 +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=1793867544; b=xfSzq1u1WKbvYg5w5HQ12fqB1RThXOGcC7YYRvlmlQT7DC/w7yA/nv9BcCNimvmKVWGP Rvd3g3XgzfsQtXRT5OPNp0eujGC1rsFEdO0tTMw1n2edcWArLQ+7SenJMTQgAXncXeZex Dl425JG++LHYxVahhAuZHTyDOEmO3uqNC84MqBRie7znjOA7TerDdOXYKeM6oIZ0gIZW0 pJCarpU13AGvCv/vMaen3gXihSsQTSvO726cZCKe+oKdXsAwSpOZR5AEhWtLmOJ9XFnwd l/bc5rvgu+8i9CrOekHGBTIp8I7tio0KlmErLnWGv2b0wcWWT4csqh0oZN/h/nXzv8Q== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793867544; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=NVbW2BmaD9uKOnn7G67IrkamJB+FiKSrtrQf7TOH35E=; b=058MMZNKqFn1H9+G3ZwJtaAEBNsTcFiV//I/t3oN6joRuCoBwbsTP0f844kVHePUelLV o0ROH7bRuFOOjPB4K/4i54Dji2R+EQYL1QtdnPEEXT2/nrAIReX6o9DNRUxeo6XMMiNe8 vVNeMx7wqUveofElqmaU9YAKl+VV2x0H9pWb27iRJ40/6tM3v8OTsCXOeUWcXGlPXcRPV ASaFYOC+UYH1H0SehcaSWhugoxQS75RMnbrbKDJFyuK0W4tZWh8FTD+UN9MqMdtkEYsVN wes7c9viNLbkTgZkqD18VqKmIsvolPgEji6FcJcGFcIf1zp172XYqme1M9J3x2ht9Dw== 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=O4f4SU0D; 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 C6C02606A332; Thu, 5 Nov 2026 08:32:24 +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=O4f4SU0D 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=1793867539; b=Bf4x0bsqBW5vUDuoeRz6qidTLnknrbXnQI07BjX76Yay9xmEMKkl44oEyi59UL54GpcA geYVGcgR2dYmaVdegAq5TMY5cRlH6CeucQ2cvx/RZDPcXrC6kO39mOcypKdvURHsuf5Bu E5rMmVlC17Zpd9dkw/oI57j6ddevPKStBT06hPuabdBZC6TXQ+Qd+idSiPqlR6p65Ips6 ekHWpZB6Q8AQ4aHhHdyyBnWtxYbCWpzFFZ3faDqunUEyNg1xW8+YyayfK/Vfje90Kse3u uEtKp3011xqP0WfkNgUnCUfB7Wm11N4pVxN2jZ0IaBzuttarNCM7nu0PzEJQeOqkY9g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793867539; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=NVbW2BmaD9uKOnn7G67IrkamJB+FiKSrtrQf7TOH35E=; b=mcEhlVqV6RXbV/TAf4UJ0lpaI9nHjHwMkGP8kqGLNZKMYQ56KH0joqSXkY/opCks48Po Y16+Wq08xft1ouNLmPYrytN0B6DhDYrZCsH8KH+eSQzQE4ZpIXg7zzYN+Rf7nl6Exy+SX O0Ce5nIuObz7p8dkJsXJwBoNlbXdEL5Sl/mFQNQ3bz8SZ4TGyCR6403WGqsQck182KUa9 ekXBOaLvNkzi7BJKOLfQD0pfdy9FsizPsUak91GtBtHlfJDuAI+4hXhh8Iad4VVysEJFR NBXvXxlgAfeZegciC3I3snNsL6RSGlMLNOxuGWggcmiuczQN/xzOOk/MFBY3eKD07hA== 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=O4f4SU0D; 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 A0AD1606A32C; Thu, 5 Nov 2026 08:32:18 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9ED881F00919; Thu, 5 Nov 2026 08:32:17 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793867538; bh=NVbW2BmaD9uKOnn7G67IrkamJB+FiKSrtrQf7TOH35E=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=O4f4SU0D8QIgL1X10PD9EVe0bw/EfGxKi4rbWrDIY5Q/Y9urMRJepmU1iI8zqSYxm Ml+7pzp2epoG9bkg5Hocu4KklduGIonUPFnqj3jPu8grFbLrgjXZW0y7ekufemrQG0 qKyi8DzKqSbwNatkOhp0Ja+E4TfkYg2hSjJe0pElsCYldYYEgGr2/26glmErirx/WT j4LL6CbYpIASfkqJJJT4XQneo+ThZZDws7oSSoXe6dwBipvvVwUB9uNo4Rz/88J1nB JzllwV3Spt6ff5COQiPpaWan3MtU02VeACWvpblkLiEGNcprDWFIqBJN03OMpbtwEq BXqMQEFS19rpQ== X-Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, willemb@google.com, mst@redhat.com, eperezma@redhat.com, hassansultan@google.com, virtualization@lists.linux.dev X-In-Reply-To: <20261103203113.550604-4-edumazet@kernel.org> X-sashiko-severity: Low 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