Skip to contentSkip to conversation

vsock: fix timeout in vsock_accept()

PATCH In review Stefano Garzarella 3 participants 3 messages May 27, 2020

Subsystems (3)
lore
Share & tools
lore

Stefano Garzarella

author maintainer
#0 lore raw

PATCH 1/1 vsock: fix timeout in vsock_accept()

The accept(2) is an "input" socket interface, so we should use SO_RCVTIMEO instead of SO_SNDTIMEO to set the timeout.

So this patch replace sock_sndtimeo() with sock_rcvtimeo() to use the right timeout in the vsock_accept().

Fixes d021c344051a ("VSOCK: Introduce VM Sockets")
---
 net/vmw_vsock/af_vsock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/vmw_vsock/af_vsock.c +1 -1
index a5f28708e0e7..626bf9044418 100644
@@ -1408,7 +1408,7 @@ static int vsock_accept(struct socket *sock, struct socket *newsock, int flags,
 	/* Wait for children sockets to appear; these are the new sockets
 	 * created upon connection establishment.
 	 */
-	timeout = sock_sndtimeo(listener, flags & O_NONBLOCK);
+	timeout = sock_rcvtimeo(listener, flags & O_NONBLOCK);
 	prepare_to_wait(sk_sleep(listener), &wait, TASK_INTERRUPTIBLE);
 
 	while ((connected = vsock_dequeue_accept(listener)) == NULL &&
Signature · 1 line
2.25.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 28 lines

From: Stefano Garzarella <[email protected]>
Sent: Wednesday, May 27, 2020 9:57 AM

The accept(2) is an "input" socket interface, so we should use SO_RCVTIMEO instead of SO_SNDTIMEO to set the timeout.

So this patch replace sock_sndtimeo() with sock_rcvtimeo() to use the right timeout in the vsock_accept().

Fixes d021c344051a ("VSOCK: Introduce VM Sockets")
---
 net/vmw_vsock/af_vsock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/vmw_vsock/af_vsock.c +1 -1
index a5f28708e0e7..626bf9044418 100644
@@ -1408,7 +1408,7 @@ static int vsock_accept(struct socket *sock, struct
 socket *newsock, int flags,
 	/* Wait for children sockets to appear; these are the new sockets
 	 * created upon connection establishment.
 	 */
-	timeout = sock_sndtimeo(listener, flags & O_NONBLOCK);
+	timeout = sock_rcvtimeo(listener, flags & O_NONBLOCK);
 	prepare_to_wait(sk_sleep(listener), &wait, TASK_INTERRUPTIBLE);
 
Quoted 3 lines

while ((connected = vsock_dequeue_accept(listener)) == NULL &&
--
2.25.4

Thanks for fixing this!

maintainer
#2 lore raw
In reply to Stefano Garzarella

From: Stefano Garzarella <[email protected]>
Date: Wed, 27 May 2020 09:56:55 +0200

Quoted 8 lines

The accept(2) is an "input" socket interface, so we should use SO_RCVTIMEO instead of SO_SNDTIMEO to set the timeout.

So this patch replace sock_sndtimeo() with sock_rcvtimeo() to use the right timeout in the vsock_accept().

Fixes d021c344051a ("VSOCK: Introduce VM Sockets")

Applied and queued up for -stable, thank you.