Skip to content

Commit 898e9af

Browse files
vsock: fix possible infinite sleep in vsock_connectible_wait_data()
Bugzilla: https://bugzilla.redhat.com/2160028 commit 466a853 Author: Dexuan Cui <decui@microsoft.com> Date: Mon Oct 31 19:17:06 2022 -0700 vsock: fix possible infinite sleep in vsock_connectible_wait_data() Currently vsock_connectible_has_data() may miss a wakeup operation between vsock_connectible_has_data() == 0 and the prepare_to_wait(). Fix the race by adding the process to the wait queue before checking vsock_connectible_has_data(). Fixes: b3f7fd5 ("af_vsock: separate wait data loop") Signed-off-by: Dexuan Cui <decui@microsoft.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Reported-by: Frédéric Dalleau <frederic.dalleau@docker.com> Tested-by: Frédéric Dalleau <frederic.dalleau@docker.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
1 parent 41a67ae commit 898e9af

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/vmw_vsock/af_vsock.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1905,8 +1905,11 @@ static int vsock_connectible_wait_data(struct sock *sk,
19051905
err = 0;
19061906
transport = vsk->transport;
19071907

1908-
while ((data = vsock_connectible_has_data(vsk)) == 0) {
1908+
while (1) {
19091909
prepare_to_wait(sk_sleep(sk), wait, TASK_INTERRUPTIBLE);
1910+
data = vsock_connectible_has_data(vsk);
1911+
if (data != 0)
1912+
break;
19101913

19111914
if (sk->sk_err != 0 ||
19121915
(sk->sk_shutdown & RCV_SHUTDOWN) ||

0 commit comments

Comments
 (0)