public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexandru Matei <alexandru.matei@uipath.com>
To: Vadim Fedorenko <vadim.fedorenko@linux.dev>,
	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: Fri, 20 Oct 2023 00:12:48 +0300	[thread overview]
Message-ID: <126c3133-2bca-4bb3-9cb2-7ca4fae2eda1@uipath.com> (raw)
In-Reply-To: <f2d0aaad-70ca-4417-bf8e-0d7006be6ebc@linux.dev>

On 10/19/2023 3:12 AM, Vadim Fedorenko wrote:
> 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?
> 
Thanks, it definitely looks better and it solves a few other issues by splitting the function in two.

  reply	other threads:[~2023-10-19 21:12 UTC|newest]

Thread overview: 6+ 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
2023-10-19 21:12   ` Alexandru Matei [this message]
2023-10-19  8:54 ` Stefano Garzarella
2023-10-19 21:12   ` Alexandru Matei
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=126c3133-2bca-4bb3-9cb2-7ca4fae2eda1@uipath.com \
    --to=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=vadim.fedorenko@linux.dev \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox