Skip to content
Commit 1fecefb0 authored by Filippo Storniolo's avatar Filippo Storniolo Committed by Greg Kroah-Hartman
Browse files

vsock/virtio: remove socket from connected/bound list on shutdown

[ Upstream commit 3a5cc90a ]

If the same remote peer, using the same port, tries to connect
to a server on a listening port more than once, the server will
reject the connection, causing a "connection reset by peer"
error on the remote peer. This is due to the presence of a
dangling socket from a previous connection in both the connected
and bound socket lists.
The inconsistency of the above lists only occurs when the remote
peer disconnects and the server remains active.

This bug does not occur when the server socket is closed:
virtio_transport_release() will eventually schedule a call to
virtio_transport_do_close() and the latter will remove the socket
from the bound and connected socket lists and clear the sk_buff.

However, virtio_transport_do_close() will only perform the above
actions if it has been scheduled, and this will not happen
if the server is processing the shutdown message from a remote peer.

To fix this, introduce a call to vsock_remove_sock()
when the server is handling a client disconnect.
This is to remove the socket from the bound and connected socket
lists without clearing the sk_buff.

Fixes: 06a8fc78

 ("VSOCK: Introduce virtio_vsock_common.ko")
Reported-by: default avatarDaan De Meyer <daan.j.demeyer@gmail.com>
Tested-by: default avatarDaan De Meyer <daan.j.demeyer@gmail.com>
Co-developed-by: default avatarLuigi Leonardi <luigi.leonardi@outlook.com>
Signed-off-by: default avatarLuigi Leonardi <luigi.leonardi@outlook.com>
Signed-off-by: default avatarFilippo Storniolo <f.storniolo95@gmail.com>
Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent baddcc2c
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment