Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp35238rdb; Wed, 18 Oct 2023 17:13:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjQn09f38FoYLvlae2RcvcNleKdAK4jdLByav9elChq5an5Eul6MSiXRoe2ERLu6jMFBVJ X-Received: by 2002:a17:90a:1944:b0:27c:f2e5:a82 with SMTP id 4-20020a17090a194400b0027cf2e50a82mr737321pjh.15.1697674382987; Wed, 18 Oct 2023 17:13:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697674382; cv=none; d=google.com; s=arc-20160816; b=MKXjaQ8L+j+5+djBUZ6bCCQ4G7c/oqEIrBN1WTjLvZpepMSqlkgCmgqJYqDIDFb9X0 f9UUhH+j7drbJJGu3vmiTUCKNYBSGSVPO9d68RWzfaGASaUVnQHHBSq1gSvwyEeT/2+6 Nmo5dSFRwFEP0MlMx1F5ng49ajyTTGDO6hcd1ea1DwSaAHxcTRrlTswfTzKlmL+q176L 75w715a7jN5ZNilD50iEYsknS+LdUfMA1HUDnwdLNLuGOT22a5AIa6/Twe5Hw/BsyE5g nw5oW9LUcplxQHTmlhHfLcoyOjQuNdCgr9sD188mmecxJintG7/gkXNvycWjrAt3I/rp 4+3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=eiFGcXBir5895gbTnSvVkUAxBA2ZOAi3wV+AILiCiwU=; fh=WmUViQAhAeOvvq52mpCCdrYo9RvtEDsU1rRZgGcDvuk=; b=VMpr4s1kc0d5UeATvbCCgfBkOPsahbcOr2hpkO8GNjjDXSz9bCotEgzK8/aLkKoSVS /sST+mjtFWB0+MmS1I8FJ4eQCMaDKIqNQaoDa8B7QTlfR6naTeMRKFV2SjtzWbe5A5I3 ljIhyJoeSxzHh89KHqLTfvuKOdtUcUOy+MaDyjtWFE6SWCqPlN8FkJ5sIRbjSUr9S9yx XNFPqcQIYxTP96c4ph6Sb6TTBZUpmhoFFghd/gae7yRlpJNwoCcrLdfOgAFM97/4hlac GE3ZuOY0cY+eJ44jckQ720lx315athAIaRZKS5j14Utune3O3sQFjUmPma0ejpNijUTx owEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=gYDHfis9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id lx17-20020a17090b4b1100b0026b502223cbsi987722pjb.10.2023.10.18.17.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 17:13:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=gYDHfis9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 3B1348115A92; Wed, 18 Oct 2023 17:12:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231441AbjJSAMo (ORCPT + 99 others); Wed, 18 Oct 2023 20:12:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231199AbjJSAMo (ORCPT ); Wed, 18 Oct 2023 20:12:44 -0400 Received: from out-203.mta1.migadu.com (out-203.mta1.migadu.com [IPv6:2001:41d0:203:375::cb]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92EF6124 for ; Wed, 18 Oct 2023 17:12:41 -0700 (PDT) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1697674360; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eiFGcXBir5895gbTnSvVkUAxBA2ZOAi3wV+AILiCiwU=; b=gYDHfis9ygwRm6l48oBXXssrXFtLKWBA7IorJAjoGE8Y7cjSK3C6oXw0KLLLCpy6zE4dCc ZDd5n0hHsdxcVwqeXXZddcG8WfkDBsqheECQ//wETBy+XTwaaYas4ig9BUhzqjjEnFnkgT OsgHmHHIzL+WgaterzAipWgib/DnH2Y= Date: Thu, 19 Oct 2023 01:12:34 +0100 MIME-Version: 1.0 Subject: Re: [PATCH] vsock: initialize the_virtio_vsock before using VQs Content-Language: en-US To: Alexandru Matei , Stefan Hajnoczi , Stefano Garzarella , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Mihai Petrisor , Viorel Canja References: <20231018183247.1827-1-alexandru.matei@uipath.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Vadim Fedorenko In-Reply-To: <20231018183247.1827-1-alexandru.matei@uipath.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 18 Oct 2023 17:12:59 -0700 (PDT) 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 > --- > 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?