BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nnamdi Onyeyiri" <nnamdio@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v7 1/2] bpf, sockmap: handle spurious tcp_msg_wait_data() wakeup
Date: Tue, 21 Jul 2026 22:55:12 +0000	[thread overview]
Message-ID: <20260721225512.9654C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260721223807.75101-2-nnamdio@gmail.com>

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

Pre-existing issues:
- [High] tcp_bpf_recvmsg_parser() fails to handle unparsed data in sk_receive_queue, returning premature EAGAIN on blocking sockets.
--

--- Patch [1]: [PATCH v7 1/2] bpf, sockmap: handle spurious tcp_msg_wait_data() wakeup ---
commit 7468e0f3ba324455b02b600d4c77965cd4caa92c
Author: Nnamdi Onyeyiri <nnamdio@gmail.com>

bpf, sockmap: handle spurious tcp_msg_wait_data() wakeup

This commit addresses spurious wakeups from tcp_msg_wait_data() by looping
back to msg_bytes_ready instead of returning -EAGAIN. It also passes a pointer
for timeo to allow sk_wait_event() to update the remaining timeout.

> diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
> index 8e905b50deadb..87aef99a13792 100644
> --- a/net/ipv4/tcp_bpf.c
> +++ b/net/ipv4/tcp_bpf.c
[ ... ]
> @@ -310,13 +311,15 @@ static int tcp_bpf_recvmsg_parser(struct sock *sk,
>  			goto out;
>  		}
>  
> -		data = tcp_msg_wait_data(sk, psock, timeo);
> +		data = tcp_msg_wait_data(sk, psock, &timeo);
>  		if (data < 0) {
>  			copied = data;
>  			goto unlock;
>  		}
>  		if (data && !sk_psock_queue_empty(psock))
>  			goto msg_bytes_ready;
> +		if (!data && timeo > 0)
> +			goto msg_bytes_ready;

[Severity: High]
This is a pre-existing issue, but could this return a premature -EAGAIN on a
blocking socket when data is waiting to be parsed?

If data arrives and is added to sk_receive_queue, but a stream parser requires
more bytes to complete a message (or the parser is deferred to a workqueue),
tcp_msg_wait_data() will return 1.

Because psock->ingress_msg is still empty, both the existing condition:
    if (data && !sk_psock_queue_empty(psock))
and the new condition:
    if (!data && timeo > 0)
will evaluate to false.

Does this mean tcp_bpf_recvmsg_parser() falls through and returns -EAGAIN
instead of continuing to wait for the remaining data to be parsed?

>  		copied = -EAGAIN;
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260721223807.75101-1-nnamdio@gmail.com?part=1

  reply	other threads:[~2026-07-21 22:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21 22:38 [PATCH v7 0/2] bpf, sockmap: handle spurious tcp_msg_wait_data() wakeup Nnamdi Onyeyiri
2026-07-21 22:38 ` [PATCH v7 1/2] " Nnamdi Onyeyiri
2026-07-21 22:55   ` sashiko-bot [this message]
2026-07-22 11:01   ` Jakub Sitnicki
2026-07-22 11:22     ` Nnamdi Onyeyiri
2026-07-21 22:38 ` [PATCH v7 2/2] selftests/bpf: add sockmap recvfrom EAGAIN selftest Nnamdi Onyeyiri

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=20260721225512.9654C1F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox