Patch "vsock: prevent unnecessary refcnt inc for nonblocking connect" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    vsock: prevent unnecessary refcnt inc for nonblocking connect

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     vsock-prevent-unnecessary-refcnt-inc-for-nonblocking.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit ab1393c3e39563bdb5b659c8e4229c246be82ecc
Author: Eiichi Tsukata <eiichi.tsukata@xxxxxxxxxxx>
Date:   Tue Nov 9 00:15:02 2021 +0000

    vsock: prevent unnecessary refcnt inc for nonblocking connect
    
    [ Upstream commit c7cd82b90599fa10915f41e3dd9098a77d0aa7b6 ]
    
    Currently vosck_connect() increments sock refcount for nonblocking
    socket each time it's called, which can lead to memory leak if
    it's called multiple times because connect timeout function decrements
    sock refcount only once.
    
    Fixes it by making vsock_connect() return -EALREADY immediately when
    sock state is already SS_CONNECTING.
    
    Fixes: d021c344051a ("VSOCK: Introduce VM Sockets")
    Reviewed-by: Stefano Garzarella <sgarzare@xxxxxxxxxx>
    Signed-off-by: Eiichi Tsukata <eiichi.tsukata@xxxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index e2c0cfb334d20..fa8c1b623fa21 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1322,6 +1322,8 @@ static int vsock_connect(struct socket *sock, struct sockaddr *addr,
 		 * non-blocking call.
 		 */
 		err = -EALREADY;
+		if (flags & O_NONBLOCK)
+			goto out;
 		break;
 	default:
 		if ((sk->sk_state == TCP_LISTEN) ||



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux