Patch "vsock: notify server to shutdown when client has pending signal" has been added to the 5.4-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: notify server to shutdown when client has pending signal

to the 5.4-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-notify-server-to-shutdown-when-client-has-pend.patch
and it can be found in the queue-5.4 subdirectory.

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



commit f44ec38312423f0cfc3c1170419d6f6d316fe1db
Author: Longpeng(Mike) <longpeng2@xxxxxxxxxx>
Date:   Mon Jun 21 14:26:01 2021 +0800

    vsock: notify server to shutdown when client has pending signal
    
    [ Upstream commit c7ff9cff70601ea19245d997bb977344663434c7 ]
    
    The client's sk_state will be set to TCP_ESTABLISHED if the server
    replay the client's connect request.
    
    However, if the client has pending signal, its sk_state will be set
    to TCP_CLOSE without notify the server, so the server will hold the
    corrupt connection.
    
                client                        server
    
    1. sk_state=TCP_SYN_SENT         |
    2. call ->connect()              |
    3. wait reply                    |
                                     | 4. sk_state=TCP_ESTABLISHED
                                     | 5. insert to connected list
                                     | 6. reply to the client
    7. sk_state=TCP_ESTABLISHED      |
    8. insert to connected list      |
    9. *signal pending* <--------------------- the user kill client
    10. sk_state=TCP_CLOSE           |
    client is exiting...             |
    11. call ->release()             |
         virtio_transport_close
          if (!(sk->sk_state == TCP_ESTABLISHED ||
                  sk->sk_state == TCP_CLOSING))
                    return true; *return at here, the server cannot notice the connection is corrupt*
    
    So the client should notify the peer in this case.
    
    Cc: David S. Miller <davem@xxxxxxxxxxxxx>
    Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
    Cc: Jorgen Hansen <jhansen@xxxxxxxxxx>
    Cc: Norbert Slusarek <nslusarek@xxxxxxx>
    Cc: Andra Paraschiv <andraprs@xxxxxxxxxx>
    Cc: Colin Ian King <colin.king@xxxxxxxxxxxxx>
    Cc: David Brazdil <dbrazdil@xxxxxxxxxx>
    Cc: Alexander Popov <alex.popov@xxxxxxxxx>
    Suggested-by: Stefano Garzarella <sgarzare@xxxxxxxxxx>
    Link: https://lkml.org/lkml/2021/5/17/418
    Signed-off-by: lixianming <lixianming5@xxxxxxxxxx>
    Signed-off-by: Longpeng(Mike) <longpeng2@xxxxxxxxxx>
    Reviewed-by: Stefano Garzarella <sgarzare@xxxxxxxxxx>
    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 c82e7b52ab1f..d4104144bab1 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1217,7 +1217,7 @@ static int vsock_stream_connect(struct socket *sock, struct sockaddr *addr,
 
 		if (signal_pending(current)) {
 			err = sock_intr_errno(timeout);
-			sk->sk_state = TCP_CLOSE;
+			sk->sk_state = sk->sk_state == TCP_ESTABLISHED ? TCP_CLOSING : TCP_CLOSE;
 			sock->state = SS_UNCONNECTED;
 			vsock_transport_cancel_pkt(vsk);
 			goto out_wait;



[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