From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Alexandru Matei <alexandru.matei@uipath.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Stefano Garzarella <sgarzare@redhat.com>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Mihai Petrisor <mihai.petrisor@uipath.com>,
Viorel Canja <viorel.canja@uipath.com>
Subject: Re: [PATCH] vsock: initialize the_virtio_vsock before using VQs
Date: Thu, 19 Oct 2023 01:12:34 +0100 [thread overview]
Message-ID: <f2d0aaad-70ca-4417-bf8e-0d7006be6ebc@linux.dev> (raw)
In-Reply-To: <20231018183247.1827-1-alexandru.matei@uipath.com>
On 18/10/2023 19:32, Alexandru Matei wrote:
> Once VQs are filled with empty buffers and we kick the host, it can send
> connection requests. If 'the_virtio_vsock' is not initialized before,
> replies are silently dropped and do not reach the host.
>
> Fixes: 0deab087b16a ("vsock/virtio: use RCU to avoid use-after-free on the_virtio_vsock")
> Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
> ---
> net/vmw_vsock/virtio_transport.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
> index e95df847176b..eae0867133f8 100644
> --- a/net/vmw_vsock/virtio_transport.c
> +++ b/net/vmw_vsock/virtio_transport.c
> @@ -658,12 +658,13 @@ static int virtio_vsock_probe(struct virtio_device *vdev)
> vsock->seqpacket_allow = true;
>
> vdev->priv = vsock;
> + rcu_assign_pointer(the_virtio_vsock, vsock);
>
> ret = virtio_vsock_vqs_init(vsock);
> - if (ret < 0)
> + if (ret < 0) {
> + rcu_assign_pointer(the_virtio_vsock, NULL);
> goto out;
> -
> - rcu_assign_pointer(the_virtio_vsock, vsock);
> + }
>
> mutex_unlock(&the_virtio_vsock_mutex);
>
Looks like virtio_vsock_restore() needs the same changes. But
virtio_vsock_vqs_init() can fail only in virtio_find_vqs(). Maybe it can
be split into 2 functions to avoid second rcu_assign_pointer() in case
of error?
next prev parent reply other threads:[~2023-10-19 0:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-18 18:32 [PATCH] vsock: initialize the_virtio_vsock before using VQs Alexandru Matei
2023-10-19 0:12 ` Vadim Fedorenko [this message]
2023-10-19 21:12 ` Alexandru Matei
2023-10-19 8:54 ` Stefano Garzarella
2023-10-19 8:54 ` Stefano Garzarella
2023-10-19 21:12 ` Alexandru Matei
2023-10-20 7:23 ` Stefano Garzarella
2023-10-20 7:23 ` Stefano Garzarella
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f2d0aaad-70ca-4417-bf8e-0d7006be6ebc@linux.dev \
--to=vadim.fedorenko@linux.dev \
--cc=alexandru.matei@uipath.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mihai.petrisor@uipath.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
--cc=viorel.canja@uipath.com \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.