• Longpeng(Mike)'s avatar
    vsock: notify server to shutdown when client has pending signal · c7ff9cff
    Longpeng(Mike) authored
    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@davemloft.net>
    Cc: Jakub Kicinski <kuba@kernel.org>
    Cc: Jorgen Hansen <jhansen@vmware.com>
    Cc: Norbert Slusarek <nslusarek@gmx.net>
    Cc: Andra Paraschiv <andraprs@amazon.com>
    Cc: Colin Ian King <colin.king@canonical.com>
    Cc: David Brazdil <dbrazdil@google.com>
    Cc: Alexander Popov <alex.popov@linux.com>
    Suggested-by: default avatarStefano Garzarella <sgarzare@redhat.com>
    Link: https://lkml.org/lkml/2021/5/17/418Signed-off-by: default avatarlixianming <lixianming5@huawei.com>
    Signed-off-by: default avatarLongpeng(Mike) <longpeng2@huawei.com>
    Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    c7ff9cff
af_vsock.c 54.4 KB