Re: [PATCH net 2/2] selftests: net: check UDP tunnel GRO virtio offsets

From: netdev-bot+sashiko

Date: Mon Nov 16 2026 - 08:52:00 EST


Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In the gro_on variant, TEST_F(tun_vnet_gro,
outer_transport_header) in tools/testing/selftests/net/tun.c reports…
- [Low] In TEST_F(tun_vnet_gro, outer_transport_header)
(tools/testing/selftests/net/tun.c), `len` is an `int` that holds the…

--

selftests: net: check UDP tunnel GRO virtio offsets

This adds a tun_vnet_gro fixture to the tun selftest. It writes Geneve/TCP
frames into a NAPI TAP, bridges them to a second virtio-header TAP, and
compares the exported tunnel offsets and checksum fields of the GRO
aggregate with the parsed wire headers. A gro_off variant is used as a
packet integrity control.

> diff --git a/tools/testing/selftests/net/tun.c b/tools/testing/selftests/net/tun.c
> index 34de2580e32ec..192b3e0c0d172 100644
> --- a/tools/testing/selftests/net/tun.c
> +++ b/tools/testing/selftests/net/tun.c

[ ... ]

> +TEST_F(tun_vnet_gro, outer_transport_header)
> +{
> + uint8_t input[GRO_BUFFER_SIZE], output[GRO_BUFFER_SIZE];
> + unsigned int seen = 0, aggregates = 0, records = 0;
> + /* Bound the wait even if forwarding fails or packets are lost. */
> + int64_t deadline = gro_milliseconds() + GRO_RECEIVE_TIMEOUT_MS;
> + struct pollfd pfd = { .fd = self->fd[1], .events = POLLIN };
> + int i, len, frame_len, ready;

[ ... ]

> + ASSERT_NE(pfd.revents & POLLIN, 0);
> + ASSERT_LT(records++, 128);
> + len = read(self->fd[1], output, sizeof(output));
> + ASSERT_GE(len, TUN_VNET_TNL_SIZE + ETH_HLEN);
> + frame_len = len - TUN_VNET_TNL_SIZE;

[Severity: Low]
Can a failed read() get past this assert? len is an int, but
TUN_VNET_TNL_SIZE is sizeof(struct virtio_net_hdr_v1_hash_tunnel), so the
right-hand side is a size_t. __EXPECT() keeps the type of each operand:

__typeof__(_expected) __exp = (_expected);
__typeof__(_seen) __seen = (_seen);
if (!(__exp _t __seen)) {

That means a -1 from read() is compared as SIZE_MAX, and the assert passes.

read() can fail even after poll() reports POLLIN. tun_do_read() dequeues
the skb and calls tun_put_user(), which can return -EINVAL from
virtio_net_hdr_tnl_from_skb(). The skb is freed either way:

drivers/net/tun.c:tun_do_read() {
...
ret = tun_put_user(tun, tfile, skb, to);
if (unlikely(ret < 0))
kfree_skb(skb);
...
}

When that happens, frame_len goes negative. The later ASSERT_GE(frame_len,
...) checks against size_t or unsigned operands pass for the same reason.

On the first iteration, output[] is uninitialized stack memory. The MAC
memcmp() then most likely mismatches and the error is dropped by the
continue. On later iterations the stale previous frame is parsed until the
tot_len check fails with a misleading message.

The test still fails in the end because seen never reaches 0xff, but the
real errno is never reported. Would an ASSERT_GE(len, 0) before this check,
or an (int) cast on the size, give a clearer failure?

[ ... ]

> + if (!variant->gro || vh->gso_type == VIRTIO_NET_HDR_GSO_NONE) {
> + ASSERT_EQ(vh->gso_type, VIRTIO_NET_HDR_GSO_NONE);
> + ASSERT_EQ(segments, 1);
> + ASSERT_EQ(le16toh(vh->gso_size), 0);
> + ASSERT_EQ(gro_build_packet(input, first), len);
> + ASSERT_EQ(memcmp(frame, input + TUN_VNET_TNL_SIZE, frame_len), 0);
> + continue;
> + }

[ ... ]

> + ASSERT_EQ(seen, (1U << GRO_PACKETS) - 1);
> + if (variant->gro && !aggregates && _metadata->exit_code != KSFT_FAIL)
> + SKIP(return, "No multi-segment GRO aggregate observed");

[Severity: Medium]
Does this match the commit message? The commit message says:

Require a multi-segment GRO aggregate ... No output or no merge is not
a pass.

In kselftest_harness.h, SKIP() is documented as forcing a "pass" after
reporting why the test is skipped. It sets _metadata->exit_code to
KSFT_SKIP, which appears as "ok ... # SKIP" in the TAP output.

In the gro_on variant, the GSO_NONE branch above accepts unmerged frames
after only an integrity check. Those frames never reach the
outer_th_offset and inner_nh_offset checks. virtio_net_hdr_tnl_from_skb()
only fills those fields for SKB_GSO_UDP_TUNNEL or SKB_GSO_UDP_TUNNEL_CSUM
skbs, which means only for aggregates.

Suppose Geneve GRO stops merging, or the tunnel GSO export path stops
producing tunnel GSO skbs. All 8 packets would then arrive as valid
singles, seen would become 0xff, aggregates would stay 0, and the test
would report SKIP.

Wouldn't a regression in the path this test targets then look like an
environment skip instead of a failure? Should the gro_on variant fail
here instead?

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112030708.1915665-1-bryon%40fryer.io