From: sashiko-bot@kernel.org
To: "Eric Dumazet" <edumazet@kernel.org>
Cc: virtualization@lists.linux.dev,
"Michael S. Tsirkin" <mst@redhat.com>,
"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH net v3 8/8] selftests: net: tuntap: write UDP tunnel offsets in little endian
Date: Fri, 06 Nov 2026 08:16:44 +0000 [thread overview]
Message-ID: <sashiko-outbox-201045@kernel.org> (raw)
In-Reply-To: <20261105115715.1466924-9-edumazet@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] selftests: net: tun: UDP tunnel GSO tests still fail on
big-endian hosts
--
commit 19b0a422177cb62b0357c401d17b939feb10dca3
Author: Eric Dumazet <edumazet@kernel.org>
selftests: net: tuntap: write UDP tunnel offsets in little endian
This commit converts the outer_th_offset and inner_nh_offset fields of
struct virtio_net_hdr_v1_hash_tunnel to little-endian in the tuntap
selftests while leaving the base virtio_net_hdr_v1 fields in host byte
order.
> diff --git a/tools/testing/selftests/net/tuntap_helpers.h b/tools/testing/selftests/net/tuntap_helpers.h
> index ecad83fae1582..dc85cd9bc0aec 100644
> --- a/tools/testing/selftests/net/tuntap_helpers.h
> +++ b/tools/testing/selftests/net/tuntap_helpers.h
[ ... ]
> @@ -375,11 +377,14 @@ static inline int build_virtio_net_hdr_v1_hash_tunnel(uint8_t *buf, bool is_tap,
> inner_iphlen = (inner_family == AF_INET) ? sizeof(struct iphdr) :
> sizeof(struct ipv6hdr);
>
> - vh_tunnel->outer_th_offset = eth_hlen + outer_iphlen;
> - vh_tunnel->inner_nh_offset = vh_tunnel->outer_th_offset + ETH_HLEN +
> - GENEVE_HLEN + sizeof(struct udphdr);
> + outer_th = eth_hlen + outer_iphlen;
> + inner_nh = outer_th + ETH_HLEN + GENEVE_HLEN + sizeof(struct udphdr);
>
> - vh->csum_start = vh_tunnel->inner_nh_offset + inner_iphlen;
> + /* The tunnel offsets are always little endian. */
> + vh_tunnel->outer_th_offset = htole16(outer_th);
> + vh_tunnel->inner_nh_offset = htole16(inner_nh);
> +
> + vh->csum_start = inner_nh + inner_iphlen;
> vh->csum_offset = __builtin_offsetof(struct udphdr, check);
> vh->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
> vh->hdr_len = hdr_len;
[Severity: Medium]
Will the UDP tunnel GSO tests still fail on big-endian hosts because the
kernel hardcodes little_endian = true when delegating the base header fields
in virtio_net_hdr_tnl_to_skb() and virtio_net_hdr_tnl_from_skb()?
In tools/testing/selftests/net/tun.c, tun_open() does not set TUNSETVNETLE,
so tun_vnet_is_little_endian() is false and __tun_vnet_hdr_get() reads
hdr_len, csum_start, and csum_offset in host order. However, when
tun_vnet_hdr_tnl_to_skb() calls virtio_net_hdr_tnl_to_skb() with
little_endian = false:
include/linux/virtio_net.h:virtio_net_hdr_tnl_to_skb() {
...
inner_th = __virtio16_to_cpu(little_endian, hdr->csum_start);
inner_nh = le16_to_cpu(vhdr->inner_nh_offset);
outer_th = le16_to_cpu(vhdr->outer_th_offset);
if (outer_th < outer_l3min ||
inner_nh < outer_th + sizeof(struct udphdr) ||
inner_th < inner_nh + inner_l3min)
return -EINVAL;
/* Let the basic parsing deal with plain GSO features. */
ret = __virtio_net_hdr_to_skb(skb, hdr, true,
hdr->gso_type & ~gso_tunnel_type);
if (ret)
return ret;
if (!virtio_net_tnl_offsets_ok(skb, has_eth, outer_isv6, outer_th))
return -EINVAL;
...
}
Because __virtio_net_hdr_to_skb() is called with little_endian hardcoded to
true instead of passing little_endian, it byte-swaps the host-order
csum_start, csum_offset, and gso_size on big-endian hosts. That causes
__virtio_net_hdr_to_skb() to return -EINVAL (either in pskb_may_pull() or the
skb->csum_offset check) before virtio_net_tnl_offsets_ok() is reached in
tun_vnet_udptnl_proto, tun_vnet_udptnl_proto_l3, and tun_vnet_udptnl.
Similarly, on the receive path in virtio_net_hdr_tnl_from_skb():
include/linux/virtio_net.h:virtio_net_hdr_tnl_from_skb() {
...
/* Let the basic parsing deal with plain GSO features. */
skb_shinfo(skb)->gso_type &= ~tnl_gso_type;
ret = virtio_net_hdr_from_skb(skb, hdr, true, false, vlan_hlen);
skb_shinfo(skb)->gso_type |= tnl_gso_type;
...
}
virtio_net_hdr_from_skb() is also called with little_endian hardcoded to
true, writing hdr->gso_size in little-endian while recv_gso_packet in
tools/testing/selftests/net/tun.c compares vh->gso_size against host-order
variant->gso_size.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105115715.1466924-1-edumazet@kernel.org?part=8
next prev parent reply other threads:[~2026-11-06 8:16 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 11:57 [PATCH net v3 0/8] net: virtio: validate outer protocol of UDP tunnel GSO packets Eric Dumazet
2026-11-05 11:57 ` [PATCH net v3 1/8] " Eric Dumazet
2026-11-06 8:16 ` sashiko-bot
2026-11-08 23:01 ` netdev-bot+sashiko
2026-11-05 11:57 ` [PATCH net v3 2/8] net: virtio: do not use dev->type to find the outer L3 header Eric Dumazet
2026-11-06 4:18 ` Willem de Bruijn
2026-11-06 8:48 ` Eric Dumazet
2026-11-06 8:16 ` sashiko-bot
2026-11-06 8:50 ` Eric Dumazet
2026-11-06 9:27 ` Michael S. Tsirkin
2026-11-06 9:55 ` Eric Dumazet
2026-11-08 23:01 ` netdev-bot+sashiko
2026-11-05 11:57 ` [PATCH net v3 3/8] tun: clear stale skb->protocol of NAPI frags skbs Eric Dumazet
2026-11-06 4:21 ` Willem de Bruijn
2026-11-06 8:49 ` Eric Dumazet
2026-11-06 8:16 ` sashiko-bot
2026-11-08 23:01 ` netdev-bot+sashiko
2026-11-05 11:57 ` [PATCH net v3 4/8] selftests: net: tuntap: fix UDP checksum length in build_udp_packet_csum() Eric Dumazet
2026-11-06 8:16 ` sashiko-bot
2026-11-05 11:57 ` [PATCH net v3 5/8] selftests: net: tun: test outer protocol of UDP tunnel GSO packets Eric Dumazet
2026-11-06 8:16 ` sashiko-bot
2026-11-05 11:57 ` [PATCH net v3 6/8] selftests: net: tun: test UDP tunnel GSO on retyped devices Eric Dumazet
2026-11-06 4:25 ` Willem de Bruijn
2026-11-06 8:16 ` sashiko-bot
2026-11-08 23:02 ` netdev-bot+sashiko
2026-11-05 11:57 ` [PATCH net v3 7/8] selftests: net: tun: test more outer header mismatches of UDP tunnel GSO Eric Dumazet
2026-11-06 8:16 ` sashiko-bot
2026-11-06 8:51 ` Eric Dumazet
2026-11-08 23:02 ` netdev-bot+sashiko
2026-11-05 11:57 ` [PATCH net v3 8/8] selftests: net: tuntap: write UDP tunnel offsets in little endian Eric Dumazet
2026-11-06 8:16 ` sashiko-bot [this message]
2026-11-06 8:52 ` Eric Dumazet
2026-11-08 23:02 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-201045@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=edumazet@kernel.org \
--cc=eperezma@redhat.com \
--cc=mst@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.