Re: [syzbot] [net?] [virt?] BUG: stack guard page was hit in vsock_bpf_recvmsg

Hillf Danton
2024-08-11T00:23:31Z

On Fri, 09 Aug 2024 10:42:21 -0700
> syzbot found the following issue on:
>
> HEAD commit: eb3ab13d997a net: ti: icssg_prueth: populate netdev of_node
> git tree: net-next
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17522ec5980000

#syz test net-next eb3ab13d997a

--- x/net/vmw_vsock/vsock_bpf.c
+++ y/net/vmw_vsock/vsock_bpf.c
@@ -77,37 +77,29 @@ static int vsock_bpf_recvmsg(struct sock
size_t len, int flags, int *addr_len)
{
struct sk_psock *psock;
- int copied;
+ int copied = -EAGAIN;

psock = sk_psock_get(sk);
if (unlikely(!psock))
- return __vsock_recvmsg(sk, msg, len, flags);
+ return -EAGAIN;

lock_sock(sk);
- if (vsock_has_data(sk, psock) && sk_psock_queue_empty(psock)) {
- release_sock(sk);
- sk_psock_put(sk, psock);
- return __vsock_recvmsg(sk, msg, len, flags);
- }
+ if (vsock_has_data(sk, psock) && sk_psock_queue_empty(psock))
+ goto out;

copied = sk_msg_recvmsg(sk, psock, msg, len, flags);
while (copied == 0) {
long timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);

- if (!vsock_msg_wait_data(sk, psock, timeo)) {
- copied = -EAGAIN;
+ copied = -EAGAIN;
+ if (!vsock_msg_wait_data(sk, psock, timeo))
+ break;
+ if (sk_psock_queue_empty(psock))
break;
- }
-
- if (sk_psock_queue_empty(psock)) {
- release_sock(sk);
- sk_psock_put(sk, psock);
- return __vsock_recvmsg(sk, msg, len, flags);
- }
-
copied = sk_msg_recvmsg(sk, psock, msg, len, flags);
}

+out:
release_sock(sk);
sk_psock_put(sk, psock);

--