Re: [PATCH net v5] vsock/bpf: release sock lock while waiting for data in recvmsg

From: jrmmhm . kernel

Date: Thu Nov 12 2026 - 15:44:31 EST


On Thu, Nov 12, 2026 at 08:08:52AM +0000, netdev-bot+sashiko@xxxxxxxxxx wrote:
>> -static bool vsock_msg_wait_data(struct sock *sk, struct sk_psock *psock, long timeo)
>> +/* __vsock_recvmsg() doesn't wait in these states and knows what to return. */
>> +static bool vsock_rx_done(struct sock *sk)
>
>[Severity: Low]
>Does this comment hold for the sk_err case after a transport reset?
[ ... ]
>The wait loop stops on sk_err, but the code it hands off to can't
>report that error. Could the wait path return the pending error the
>way the native path does? If not, could the comment be reworded to
>cover this case?

I reworded the comment and kept -ENOTCONN, which the commit
message already notes. Returning the pending error from the wait would
bring back the copy of the native return values that Alexei asked me
to drop in v4.

>> + while (!vsock_has_data(sk, psock) && !vsock_rx_done(sk)) {
>> + if (!timeo) {
>> + ret = -EAGAIN;
>> + break;
>> + }
>> + if (signal_pending(current)) {
>> + ret = sock_intr_errno(timeo);
>> + break;
>> + }
>
>[Severity: Low]
>What happens when the timeout and a signal land in the same wakeup?
[ ... ]
>Would checking signal_pending() right after wait_woken() returns, as
>the native loop does, make this match?

I'm leaving this one as is: it only changes which error a reader gets
when the timeout and a signal land in the same wakeup, and I don't
think that is worth another change to the loop in this patch.

>> + release_sock(sk);
>> + timeo = wait_woken(&wait, TASK_INTERRUPTIBLE, timeo);
>> + lock_sock(sk);
>> }
>
>[Severity: Medium]
>Now that the lock is dropped around wait_woken(), can vsk->transport
>be NULL when the loop condition is checked again?
[ ... ]
>Before this patch, the lock was held for the whole wait on the BPF
>path, so this interleaving could not happen there. Would checking
>vsock_rx_done() or !vsk->transport before vsock_has_data() in the loop
>condition avoid the warning?

I haven't reproduced this, but the code agrees with it: v6 will check
vsk->transport first in the wait loop, so a reader woken after its
transport is gone no longer calls vsock_has_data(). The entry
WARN_ON_ONCE() in vsock_bpf_recvmsg() stays as it is, so a later recv()
on such a socket still reaches it, as it does on net today.

pw-bot: cr

Jerome