Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp208690rdb; Thu, 19 Oct 2023 01:55:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSxG7JQugJgQcEKTsb4V6pnhjeSI0+0ODwRuvoaXQUfTdy8KW+rD6GoQCr/EB7iZLJAJBs X-Received: by 2002:a05:6358:1a85:b0:166:be1f:25cb with SMTP id gm5-20020a0563581a8500b00166be1f25cbmr1515313rwb.8.1697705753814; Thu, 19 Oct 2023 01:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697705753; cv=none; d=google.com; s=arc-20160816; b=Fu5o6njUlm6Dq2zdoO3ZDmIInoyL3S5FufDTj9uT7rpVdof8Xq8nLp1omZwUOE3QLb 0j+PaD8HnNfLgVCe9qzii0lKtxY7siG6YZzfOPWxriJ6hfen/WHjuLVJL8Vjw5pwyFjA xGfByccw1yLdEsqilzGKoLFUGyusE/6FoVabSj/pxrUp0hv22RMUsNQOohA7+NpcjlTC hyEpvG7Tz08dFCsuKA4zjoAkai/qH/wLEC4qwYUXj28PQPQm1NitOonEXEMJ4wNnAlrm iV8jkAmssghOP2YMPpIuNleqDrJ8nw5Ps8bSB4kyvJFxPEtUnp+3p4fT72/ssp5sxEwy 3C7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wEAJ+VDUrNVXU5xbHG/3Z3vLqN5pIVSHhZmt7Niw3wo=; fh=g5qm3EvcEddfDirpyLMc7MJe9QOvYDcNxwtLglLkguo=; b=O9sSN2doqR9sQ3jKrvo3H3RQ+C9bs6PjfaudbHONuHUPNWbfX7g35VBZAbfmILbq54 WDglCx8vHZ0wYFFkjUCoR7JgPmsP9IWu3L2S3eBDkq48a6xKk7r8pHWNQVukGKqqb7sb KeQIjyFJypsejhV3GUNFWObR7TL1m8lt8q7IF6STOeqcxmwCxc6BAceObnfQGuckBgAX +VdhpuwplKWRUrxcQ/utCsL50MlQ2Q37f1H23KTdlPPIHw5lRa7/I4LAQSwc8FBPU44n 2k2Sfl0S9mJoah9e4wqiyymAHeD3wrMVZPncbM3dqN8yC6WFPSA2mCT0UwEazUODJfuR gEXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NqtpNseF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id u9-20020a056a00124900b0068a557febfcsi5947707pfi.111.2023.10.19.01.55.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 01:55:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NqtpNseF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 9DED68100D86; Thu, 19 Oct 2023 01:55:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345005AbjJSIzU (ORCPT + 99 others); Thu, 19 Oct 2023 04:55:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232908AbjJSIzS (ORCPT ); Thu, 19 Oct 2023 04:55:18 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEB32129 for ; Thu, 19 Oct 2023 01:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697705670; 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: in-reply-to:in-reply-to:references:references; bh=wEAJ+VDUrNVXU5xbHG/3Z3vLqN5pIVSHhZmt7Niw3wo=; b=NqtpNseF/ro67oDdwHxRPxrvti6lW2IjbvU708bshs34mJMSwCwyNsxtITXl6pZsztDbir stfhdd3ral3HkAQc6RDE8IO4LWHyV9z5Tt2bO+GOSV+F/A10qRgOZQaI5mkhG8xQRJGzBX V313ThuZdXz7h5TRrJzryxTWuaap6L4= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-363-fU9XmV1pN3-jboGM3NMt-g-1; Thu, 19 Oct 2023 04:54:29 -0400 X-MC-Unique: fU9XmV1pN3-jboGM3NMt-g-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-53ec72af708so3315420a12.0 for ; Thu, 19 Oct 2023 01:54:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697705668; x=1698310468; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=wEAJ+VDUrNVXU5xbHG/3Z3vLqN5pIVSHhZmt7Niw3wo=; b=FQYjFl/7zj35Fb8FtBWUDkuVE3i09kJr10CRsoVICnXh6HLA7PrDW7ZMfWWW1JEZBf bQ4Mn5LXh5oCsc1Ge+r+VwPCyrqEvw5UZz8zXW9iEdGZpYVHltzajbKQIBPuj3JJCJVu w/MN1hwmu4jHuimKq5ErIvTciph2YZOoW1l5s08Dck/h3SmNZ9GFe2J/qQcg64bLvHAx 8Kb4kNTFnqpANxiEUXHhId2Suaad88K1zOjLYuE9YVtfzezhXXzpo2FDkQ/896XoDE6r EOV6j5DfBo1QTzsLU1jj2XJCY3Jd9XQ3A/7MAJCjJi4FEfcAHObm7Fu1/pDdbsk/4SBm pxKQ== X-Gm-Message-State: AOJu0Yy/hDddV5eSBV+aWrFXeaaoKMJN80WH+RN5WQGY5PL4XX9mHxOC 20+jmi4GE9UyL+R5+Hc/zZZeTjI55OTuuqOen+SOs2gBmj/zFYPfmqHaXVOTvVaw9S7YMsLdu+H HalxEz1ySNF/Vl/5kdBf5f2y4 X-Received: by 2002:a05:6402:3483:b0:53e:3fce:251 with SMTP id v3-20020a056402348300b0053e3fce0251mr1126830edc.0.1697705668235; Thu, 19 Oct 2023 01:54:28 -0700 (PDT) X-Received: by 2002:a05:6402:3483:b0:53e:3fce:251 with SMTP id v3-20020a056402348300b0053e3fce0251mr1126810edc.0.1697705667920; Thu, 19 Oct 2023 01:54:27 -0700 (PDT) Received: from sgarzare-redhat (host-87-12-185-56.business.telecomitalia.it. [87.12.185.56]) by smtp.gmail.com with ESMTPSA id v23-20020a50d597000000b0053e2a64b5f8sm4088664edi.14.2023.10.19.01.54.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 01:54:27 -0700 (PDT) Date: Thu, 19 Oct 2023 10:54:21 +0200 From: Stefano Garzarella To: Alexandru Matei Cc: Stefan Hajnoczi , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Mihai Petrisor , Viorel Canja Subject: Re: [PATCH] vsock: initialize the_virtio_vsock before using VQs Message-ID: References: <20231018183247.1827-1-alexandru.matei@uipath.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20231018183247.1827-1-alexandru.matei@uipath.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,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 fry.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 (fry.vger.email [0.0.0.0]); Thu, 19 Oct 2023 01:55:29 -0700 (PDT) On Wed, Oct 18, 2023 at 09:32:47PM +0300, 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. Are replies really dropped or we just miss the notification? Could the reverse now happen, i.e., the guest wants to send a connection request, finds the pointer assigned but can't use virtqueues because they haven't been initialized yet? Perhaps to avoid your problem, we could just queue vsock->rx_work at the bottom of the probe to see if anything was queued in the meantime. Nit: please use "vsock/virtio" to point out that this problem is of the virtio transport. Thanks, Stefano > >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); > >-- >2.34.1 > >