[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <126c3133-2bca-4bb3-9cb2-7ca4fae2eda1@uipath.com>
Date: Fri, 20 Oct 2023 00:12:48 +0300
From: Alexandru Matei <alexandru.matei@...ath.com>
To: Vadim Fedorenko <vadim.fedorenko@...ux.dev>,
Stefan Hajnoczi <stefanha@...hat.com>,
Stefano Garzarella <sgarzare@...hat.com>,
"David S . Miller" <davem@...emloft.net>, Eric Dumazet
<edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: kvm@...r.kernel.org, virtualization@...ts.linux-foundation.org,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Mihai Petrisor <mihai.petrisor@...ath.com>,
Viorel Canja <viorel.canja@...ath.com>
Subject: Re: [PATCH] vsock: initialize the_virtio_vsock before using VQs
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@...ath.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.
Powered by blists - more mailing lists