From: sashiko-bot@kernel.org
To: "Nnamdi Onyeyiri" <nnamdio@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v5 2/2] selftest/bpf: added selftest sockmap_basic/sockmap recvfrom eagain
Date: Fri, 17 Jul 2026 17:29:43 +0000 [thread overview]
Message-ID: <20260717172944.992241F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260717155348.54975-3-nnamdio@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The test silently ignores non-EAGAIN errors from recvfrom(), incorrectly treating socket failures or premature EOFs as a test success.
- [Medium] Test suite hangs indefinitely if the receiver thread encounters an error during recvfrom() and exits early.
--
--- Patch [2]: [PATCH v5 2/2] selftest/bpf: added selftest sockmap_basic/sockmap recvfrom eagain ---
commit 5b1a8047d6f2573ba61a579d78502e3442c615cc
Author: Nnamdi Onyeyiri <nnamdio@gmail.com>
selftest/bpf: added selftest sockmap_basic/sockmap recvfrom eagain
This commit adds a selftest to ensure that tcp_bpf_recvmsg() and
tcp_bpf_recvmsg_parser() correctly handle spurious wakeups in
tcp_msg_wait_data(). It verifies that recvfrom() does not incorrectly return
EAGAIN.
> diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
> index e5fc038d747b6..c38d1514e2533 100644
> --- a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
> +++ b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
[ ... ]
> @@ -1410,6 +1410,117 @@ static void test_sockmap_no_verdict_fionread(void)
> test_sockmap_pass_prog__destroy(skel);
> }
>
> +static void *test_sockmap_recvfrom_eagain_thread(void *arg)
> +{
> + int fd = *(int *)arg;
> + char buf[1024];
> + void *result = NULL;
> +
> + while (true) {
> + ssize_t len = recvfrom(fd, buf, sizeof(buf), 0, NULL, NULL);
> +
> + if (len == -1) {
> + if (errno == EINTR)
> + continue;
> + result = (void *)1;
> + break;
> + }
> +
> + if (!len || buf[len - 1] == 'e')
> + break;
> + }
> +
> + send(fd, "test", 4, MSG_NOSIGNAL);
> +
> + return result;
[Severity: Medium]
If the receiver thread encounters an unexpected error (e.g., -1 from recvfrom),
it breaks out of the loop and exits without closing the file descriptor fd.
Meanwhile, the main thread attempts to send 25MB of data via a blocking xsend().
Since fd remains open but is no longer being read, the TCP receive window fills
up, and the main thread will block indefinitely in xsend().
Should the socket fd be closed before returning to prevent the test suite from
hanging?
> +}
[ ... ]
> + while (rem) {
> + sent = xsend(c, buf + (buflen - rem), rem, 0);
> + if (sent == -1)
> + goto end_attempt;
> + rem -= sent;
> + }
> +
> + err = recvfrom(c, ignored, sizeof(ignored), 0, NULL, NULL);
> + if (err < 0 && !ASSERT_NEQ(errno, EAGAIN, "recvfrom eagain"))
> + goto end_attempt;
> +
> + success = true;
[Severity: Medium]
Does this logic silently ignore errors from recvfrom() when errno is not EAGAIN?
If recvfrom() fails with an error other than EAGAIN, ASSERT_NEQ(errno, EAGAIN)
evaluates to true. The logical NOT operator negates this to false, causing the
if condition to fail.
The code then falls through to success = true, which treats the failure as a
successful test pass.
> +
> +end_attempt:
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260717155348.54975-1-nnamdio@gmail.com?part=2
prev parent reply other threads:[~2026-07-17 17:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-17 15:53 [PATCH v5 0/2] bpf, sockmap: handle spurious tcp_msg_wait_data() wakeup Nnamdi Onyeyiri
2026-07-17 15:53 ` [PATCH v5 1/2] " Nnamdi Onyeyiri
2026-07-17 17:01 ` sashiko-bot
2026-07-17 15:53 ` [PATCH v5 2/2] selftest/bpf: added selftest sockmap_basic/sockmap recvfrom eagain Nnamdi Onyeyiri
2026-07-17 16:36 ` bot+bpf-ci
2026-07-17 17:29 ` sashiko-bot [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=20260717172944.992241F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=nnamdio@gmail.com \
--cc=sashiko-reviews@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.