Skip to content

Commit c9e883d

Browse files
dcuikelsey-steele
authored andcommitted
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 <[email protected]> Signed-off-by: Kelsey Steele <[email protected]>
1 parent fba4c74 commit c9e883d

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
@@ -1881,8 +1881,11 @@ static int vsock_connectible_wait_data(struct sock *sk,
18811881
err = 0;
18821882
transport = vsk->transport;
18831883

1884-
while ((data = vsock_connectible_has_data(vsk)) == 0) {
1884+
while (1) {
18851885
prepare_to_wait(sk_sleep(sk), wait, TASK_INTERRUPTIBLE);
1886+
data = vsock_connectible_has_data(vsk);
1887+
if (data != 0)
1888+
break;
18861889

18871890
if (sk->sk_err != 0 ||
18881891
(sk->sk_shutdown & RCV_SHUTDOWN) ||

0 commit comments

Comments
 (0)