From: netdev-bot+sashiko@kernel.org
To: weir@nebusec.ai
Cc: virtualization@lists.linux.dev, netdev@vger.kernel.org,
sgarzare@redhat.com, bobbyeshleman@meta.com, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
willemb@google.com, horms@kernel.org,
arseny.krasnov@kaspersky.com, vega@nebusec.ai,
caoruide123@gmail.com
Subject: Re: [PATCH net 2/2] vsock/test: add stream MSG_WAITALL receive timeout test
Date: Sat, 28 Nov 2026 05:56:59 +0000 [thread overview]
Message-ID: <179584541902.3135.8648647638685703469@kernel.org> (raw)
In-Reply-To: <503c1d5538f5b41f8eda756f5ea4491f0bd44518.1795591531.git.caoruide123@gmail.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 3
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] The new entry "SOCK_STREAM MSG_WAITALL timeout" is inserted in
the middle of test_cases[] in tools/testing/vsock/vsock_test.c (lines…
- [Low] test_stream_timeout_waitall_client()
(tools/testing/vsock/vsock_test.c:717-738) only checks that the…
- [Low] In test_stream_timeout_waitall_client()
(tools/testing/vsock/vsock_test.c:709-717), read_ns = current_nsec() -…
- [Low] In test_stream_timeout_waitall_client()
(tools/testing/vsock/vsock_test.c:709-731), errno from recv() is not…
--
vsock/test: add stream MSG_WAITALL receive timeout test
This adds a SOCK_STREAM test to vsock_test. The client calls
recv(MSG_WAITALL) with a 1s SO_RCVTIMEO while the peer sends one byte
every 0.8s, and the test checks that the timeout is cumulative. The
client expects recv() to return in under 2s, either with EAGAIN or with a
partial read.
> diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
> index 10b9074fb87f7..868792f7729cf 100644
> --- a/tools/testing/vsock/vsock_test.c
> +++ b/tools/testing/vsock/vsock_test.c
> @@ -662,6 +662,113 @@ static void test_seqpacket_timeout_server(const struct test_opts *opts)
[ ... ]
> +static void test_stream_timeout_waitall_client(const struct test_opts *opts)
> +{
> + char buf[STREAM_RCVTIMEO_DRIP_BYTES];
> + time_t read_enter_ns;
> + struct timeval tv;
> + time_t read_ns;
[ ... ]
> + read_enter_ns = current_nsec();
> + n = recv(fd, buf, sizeof(buf), MSG_WAITALL);
> + read_ns = current_nsec() - read_enter_ns;
> +
> + /* Unfixed kernels restart the full SO_RCVTIMEO after each partial
> + * read, so this recv() returns 6 bytes after ~4.8s. A cumulative
> + * 1s timeout returns much sooner; use 2s as the cap so the two
> + * outcomes cannot be confused.
> + */
> + if (read_ns >= 2ULL * NSEC_PER_SEC * RCVTIMEO_TIMEOUT_SEC) {
[Severity: Low]
The commit message says:
With the fix, the call must return around the original timeout, either
with EAGAIN or with a partial read shorter than the MSG_WAITALL request.
This is the only timing check, and it only sets an upper bound. Would a
kernel that ignores MSG_WAITALL and returns 1 byte at about 0.8s also
pass?
The same question applies to a kernel that sets the remaining timeout to
0 after the first partial dequeue, and to one that returns EAGAIN at once
without waiting. In both cases this is the bookkeeping in question:
net/vmw_vsock/af_vsock.c:vsock_connectible_wait_data() {
...
*timeout = schedule_timeout(*timeout);
...
}
With the companion fix ("vsock: preserve receive timeout across partial
reads"), recv() should return 1 byte after about 1s.
Should the test also check for a lower bound near RCVTIMEO_TIMEOUT_SEC,
and that recv() returned the single byte?
[Severity: Low]
read_ns is a signed time_t. The 2ULL makes the right-hand side unsigned
long long, so read_ns is converted to unsigned for this comparison.
current_nsec() reads the wall clock:
if (clock_gettime(CLOCK_REALTIME, &ts)) {
Suppose CLOCK_REALTIME steps backwards while recv() is blocked, for
example on an NTP step or a guest clock resync after a VM pause. read_ns
would then be negative and compare as roughly 1.8e19.
Can the test then print "recv(MSG_WAITALL) exceeded SO_RCVTIMEO" and fail
even though recv() returned on time?
test_seqpacket_timeout_client() compares against an int constant, so a
backwards step there makes the check pass instead of fail.
Would a signed comparison, or measuring with CLOCK_MONOTONIC, avoid this?
> + fprintf(stderr,
> + "recv(MSG_WAITALL) exceeded SO_RCVTIMEO, %lu ns\n",
> + read_ns);
> + failed = 1;
> + }
> +
> + if (n == sizeof(buf)) {
> + fprintf(stderr,
> + "recv(MSG_WAITALL) completed under drip-feed\n");
> + failed = 1;
> + }
> +
> + if (n < 0 && errno != EAGAIN) {
> + perror("EAGAIN expected");
[Severity: Low]
errno is not saved right after recv(). It is checked only after
current_nsec() runs and, if the elapsed-time check fired, after
fprintf(). Both calls are allowed to change errno even when they succeed.
Could this check and perror() then report an errno that did not come from
recv()?
This only affects the diagnostic messages, not the pass/fail result.
test_seqpacket_timeout_client() checks errno right after read(). Would it
be cleaner to save errno in a local variable right after recv() here?
> + failed = 1;
> + }
[ ... ]
> @@ -2739,6 +2846,11 @@ static struct test_case test_cases[] = {
> .run_client = test_seqpacket_timeout_client,
> .run_server = test_seqpacket_timeout_server,
> },
> + {
> + .name = "SOCK_STREAM MSG_WAITALL timeout",
> + .run_client = test_stream_timeout_waitall_client,
> + .run_server = test_stream_timeout_waitall_server,
> + },
[Severity: Medium]
The new entry goes into the middle of test_cases[], right after
"SOCK_SEQPACKET timeout", so every later test's ID goes up by one.
vsock_test selects tests only by array index: parse_test_id() feeds
skip_test() and pick_test().
test_ns_same_local_host_connect_to_local_vm_ok() in
tools/testing/selftests/vsock/vmtest.sh hard-codes one of these IDs:
# Skip test 29 (transport release use-after-free): This test attempts
# binding both G2H and H2G CIDs. Because virtio-vsock (G2H) doesn't
# support local namespaces the test will fail when
# transport_g2h->stream_allow() returns false. This edge case only
# happens for vsock_test in client mode on the host in a local
# namespace. This is a false positive.
host_vsock_test "${ns}" "127.0.0.1" "${VSOCK_CID}" "${TEST_HOST_PORT}" --skip=29
After this patch, index 29 is "SOCK_STREAM MSG_ZEROCOPY leak completion
skb". "SOCK_STREAM transport release use-after-free" is now index 30.
Does this make that vmtest.sh case skip the zerocopy completion skb leak
test? It would also run the use-after-free test, which gives the false
failure the skip was added to avoid.
External scripts that pass --skip or --pick IDs would be off by one for
every test after index 8. So would host and guest binaries built from
different trees.
Could the new test be appended at the end of test_cases[] instead, or
could vmtest.sh be updated in the same patch?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795587333.git.caoruide123%40gmail.com
prev parent reply other threads:[~2026-11-28 5:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 5:19 [PATCH net 0/2] vsock: preserve receive timeout across partial reads Ren Wei
2026-11-27 5:19 ` [PATCH net 1/2] " Ren Wei
2026-11-27 5:19 ` [PATCH net 2/2] vsock/test: add stream MSG_WAITALL receive timeout test Ren Wei
2026-11-28 5:56 ` 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=179584541902.3135.8648647638685703469@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=arseny.krasnov@kaspersky.com \
--cc=bobbyeshleman@meta.com \
--cc=caoruide123@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sgarzare@redhat.com \
--cc=vega@nebusec.ai \
--cc=virtualization@lists.linux.dev \
--cc=weir@nebusec.ai \
--cc=willemb@google.com \
/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