Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: bryon@fryer.io
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org,
	horms@kernel.org, jasowangio@gmail.com, kuba@kernel.org,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	pabeni@redhat.com, shuah@kernel.org
Subject: Re: [PATCH net 2/2] selftests: net: check UDP tunnel GRO virtio offsets
Date: Mon, 16 Nov 2026 13:50:37 +0000	[thread overview]
Message-ID: <179483703798.3136.17536195102947528618@kernel.org> (raw)
In-Reply-To: <20261112030708.1915665-3-bryon@fryer.io>

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

      reply	other threads:[~2026-11-16 13:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  3:07 [PATCH net 0/2] udp: preserve outer transport header after tunnel GRO Bryon Fryer
2026-11-12  3:07 ` [PATCH net 1/2] udp: restore " Bryon Fryer
2026-11-16 13:50   ` netdev-bot+sashiko
2026-11-12  3:07 ` [PATCH net 2/2] selftests: net: check UDP tunnel GRO virtio offsets Bryon Fryer
2026-11-16 13:50   ` netdev-bot+sashiko [this message]

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=179483703798.3136.17536195102947528618@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=bryon@fryer.io \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jasowangio@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox