mirror of
https://github.com/torvalds/linux.git
synced 2026-06-07 22:14:04 +02:00
vsock/virtio: fix sock refcnt holding during the shutdown
[ Upstream commitad8a722035] The "42f5cda5eaf4" commit rightly set SOCK_DONE on peer shutdown, but there is an issue if we receive the SHUTDOWN(RDWR) while the virtio_transport_close_timeout() is scheduled. In this case, when the timeout fires, the SOCK_DONE is already set and the virtio_transport_close_timeout() will not call virtio_transport_reset() and virtio_transport_do_close(). This causes that both sockets remain open and will never be released, preventing the unloading of [virtio|vhost]_transport modules. This patch fixes this issue, calling virtio_transport_reset() and virtio_transport_do_close() when we receive the SHUTDOWN(RDWR) and there is nothing left to read. Fixes:42f5cda5ea("vsock/virtio: set SOCK_DONE on peer shutdown") Cc: Stephen Barber <smbarber@chromium.org> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
2e7e3f1690
commit
e238e05ec2
|
|
@ -871,9 +871,11 @@ virtio_transport_recv_connected(struct sock *sk,
|
|||
if (le32_to_cpu(pkt->hdr.flags) & VIRTIO_VSOCK_SHUTDOWN_SEND)
|
||||
vsk->peer_shutdown |= SEND_SHUTDOWN;
|
||||
if (vsk->peer_shutdown == SHUTDOWN_MASK &&
|
||||
vsock_stream_has_data(vsk) <= 0) {
|
||||
sock_set_flag(sk, SOCK_DONE);
|
||||
sk->sk_state = TCP_CLOSING;
|
||||
vsock_stream_has_data(vsk) <= 0 &&
|
||||
!sock_flag(sk, SOCK_DONE)) {
|
||||
(void)virtio_transport_reset(vsk, NULL);
|
||||
|
||||
virtio_transport_do_close(vsk, true);
|
||||
}
|
||||
if (le32_to_cpu(pkt->hdr.flags))
|
||||
sk->sk_state_change(sk);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user