Skip to content

Commit b3c2d93

Browse files
stefano-garzarellaopsiff
authored andcommitted
vsock: reset socket state when de-assigning the transport
commit a24009b upstream. Transport's release() and destruct() are called when de-assigning the vsock transport. These callbacks can touch some socket state like sock flags, sk_state, and peer_shutdown. Since we are reassigning the socket to a new transport during vsock_connect(), let's reset these fields to have a clean state with the new transport. Fixes: c0cfa2d ("vsock: add multi-transports support") Cc: stable@vger.kernel.org Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Reviewed-by: Luigi Leonardi <leonardi@redhat.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit d2a1836212c49e2ef3763e6358637b609ce02035)
1 parent 990fa0d commit b3c2d93

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

net/vmw_vsock/af_vsock.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,15 @@ int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk)
490490
*/
491491
vsk->transport->release(vsk);
492492
vsock_deassign_transport(vsk);
493+
494+
/* transport's release() and destruct() can touch some socket
495+
* state, since we are reassigning the socket to a new transport
496+
* during vsock_connect(), let's reset these fields to have a
497+
* clean state.
498+
*/
499+
sock_reset_flag(sk, SOCK_DONE);
500+
sk->sk_state = TCP_CLOSE;
501+
vsk->peer_shutdown = 0;
493502
}
494503

495504
/* We increase the module refcnt to prevent the transport unloading

0 commit comments

Comments
 (0)