Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [High] vsock/bpf: blocking recvmsg returns -EAGAIN on EOF/errors
--

commit 8e70f21df314d9898f7fd2e5b9f42b2d7a42d677
Author: Jerome Mohm <[email protected]>

vsock/bpf: release sock lock while waiting for data in recvmsg

This commit modifies vsock_msg_wait_data() to drop the socket lock while
sleeping in wait_woken(), and reacquire it upon waking. This prevents the
transport's delivery context from stalling when a blocking recvmsg is in
progress.

> diff --git a/net/vmw_vsock/vsock_bpf.c b/net/vmw_vsock/vsock_bpf.c
> index 9049d26486460..bb7d81a95baa6 100644
> --- a/net/vmw_vsock/vsock_bpf.c
> +++ b/net/vmw_vsock/vsock_bpf.c
> @@ -50,7 +50,9 @@ static bool vsock_msg_wait_data(struct sock *sk, struct 
> sk_psock *psock, long ti
>       sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
>       ret = vsock_has_data(sk, psock);
>       if (!ret) {
> +             release_sock(sk);
>               wait_woken(&wait, TASK_INTERRUPTIBLE, timeo);
> +             lock_sock(sk);
>               ret = vsock_has_data(sk, psock);

[Severity: High]
Does this check in vsock_msg_wait_data() miss terminal states when
waking up? If the wakeup is caused by a socket shutdown (EOF), signal,
or socket error, vsock_has_data() will return false since there is no
data.

This would cause vsock_msg_wait_data() to return false, which in turn
makes the caller vsock_bpf_recvmsg() unconditionally translate the
result to -EAGAIN:

net/vmw_vsock/vsock_bpf.c:vsock_bpf_recvmsg() {
...
        if (!vsock_msg_wait_data(sk, psock, timeo)) {
                copied = -EAGAIN;
                break;
        }
...
}

Could this result in blocking recvmsg calls returning -EAGAIN on EOF
or socket errors, violating POSIX semantics and potentially causing
applications to spin in infinite polling loops?

>       }
>       sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
>       remove_wait_queue(sk_sleep(sk), &wait);
>       return ret;
>  }

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to