Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp635176ybi; Wed, 3 Jul 2019 02:15:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyznwqZdTKESb2GV0uuTY9y3YxW/uQ8ZrrBcpzdgzybbrB9AzQzau4vaFYk3z+rWbiUoqDe X-Received: by 2002:a17:90a:bf03:: with SMTP id c3mr804862pjs.112.1562145338855; Wed, 03 Jul 2019 02:15:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562145338; cv=none; d=google.com; s=arc-20160816; b=ZHzN81MqMfZI1YckCVEVCKTOrEHag1N5h4pS5Jrn/WlSa33XfkYF31mHB8sYiCJ83J G2yHgDrNhASuSYytDOTQhO2BLYFvUtJgfE50oOKf2OGCSFK+spZT0jXMjw8pi3+AtFyL EoDCUmUUbx1sBkKS2Vs94hYbhCAccZOtWsGpVBrXhU2g7Q4+Sp0jYEZGf/m8i3SNgRam 2ibZhBcNl+N9J4VZ+s3LASm87QNyhwXtpBv6lBJ2OGCFNGPyjURkR4cAmxQAtznkqfWh vtyxQDS/wsKCBK8BtoWEnSGez/J5eOsULnqDjpPV0BsKhPb0V4RHX6FBFT06XcwrZ2hp 2ceg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=lMART3am9pWyOxnMhWlb45/gJVQGInIr11h4R6xfxH4=; b=T6D0NHbJgXIKSlMbiuWNSUoqc53z4Iu8KtpWILx6zA7Q1Kdk63uHDC+r2WVy6QL05l 7y7Pa5in2ocDdp/p5DBxDV5zvKlbfrtPSDAVA4SIk0umHbsntZDCo+/INCct5sSw/AuZ 38NeVWJpCs92bUzJs0Z8OYNxWiwceLGdspKAGBQxCzgximV28xdLk7WpxiedrvvCHrhm 4i8nwii+SwgVxjpIOz/ZVoc7/ANX2pa690d5//RTrgF+4GxMazd6Tj3lD/OO1xJk8ilS CUWqPmJeNuQ2w7qyciVZrLUBi1Q0SnIuG3KTE3EMifmuROOOSjPaMvo+9Gn6S7XsSrAs T8oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f2qyXvKO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t4si1717184pfh.261.2019.07.03.02.15.22; Wed, 03 Jul 2019 02:15:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f2qyXvKO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727264AbfGCJO6 (ORCPT + 99 others); Wed, 3 Jul 2019 05:14:58 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45099 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727008AbfGCJO5 (ORCPT ); Wed, 3 Jul 2019 05:14:57 -0400 Received: by mail-wr1-f65.google.com with SMTP id f9so1853014wre.12; Wed, 03 Jul 2019 02:14:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=lMART3am9pWyOxnMhWlb45/gJVQGInIr11h4R6xfxH4=; b=f2qyXvKO8+f+AuUjin7CqwXeE0Ga3HeWuyEYBaaGc+UwaFejqxHfryHROkXHME8FVm 6cPDGURKrLajBSDB5utM0xsCZaUabbFOrG+2XFvmbYZUHrxr3vgl1DOVYBYhg9Gp3Fke bDwJtfXwC47tA8rOx0XMa7+yoHyrS/9KvykBXxpgXpz3j9fFzrJUg1J4F+ipFHFCrawG 2nJ0Cm+iBz3IRm9WIYGSwS+QYx1YPn8rZ/k8Am5vZwXO5dJVcHjg/fEcHlZ9QDVUxwQ2 NXgh3/xHAgoeUv7K6QLjQlwN9YUIFsd5zHBiSp26KsLJaLDUOUZkGrLkO/XEtcHuMLd3 2R4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=lMART3am9pWyOxnMhWlb45/gJVQGInIr11h4R6xfxH4=; b=bwSmgPJKywFPEfknoTn+Rg3hi1nHLbEWPYCpCjkKBWMDXCzOCZNgtikOJf8iq/WxzY 61Nyv2OC12SKsReSHDW4636lIJARIK2EStyT5uqNiDHHJ3WakAvJhD2svfnNznfUWCn4 GGQ4FtKrf75gI8P6RdtqQ0a9OntT5pplFoJpjq1lyd4Vez1ysgL2Om+3wWllcwIf/iqb 33dCA97SyA7LfX310df/Xhe2eo395EXZgv2YLODjgRCQW94e0JTmmNs4k3rWlFNCczpo NP5OyA5NBFV4+sZbyB6vDRiNKeuy2cdc8N5qxrusSUuJUQ1TFHrv6lOvTXWIGSIAmOMO R/tg== X-Gm-Message-State: APjAAAW7FImwhwnvbmiQEjzq2CaGwx4AShtIfMu7NdiGqUVovKRqwDQ9 r+bxDr7/J1Zfs0dA5OPgLbU= X-Received: by 2002:adf:e803:: with SMTP id o3mr4360588wrm.69.1562145295443; Wed, 03 Jul 2019 02:14:55 -0700 (PDT) Received: from localhost ([51.15.41.238]) by smtp.gmail.com with ESMTPSA id b2sm1921496wrp.72.2019.07.03.02.14.54 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 02:14:54 -0700 (PDT) Date: Wed, 3 Jul 2019 10:14:53 +0100 From: Stefan Hajnoczi To: Stefano Garzarella Cc: netdev@vger.kernel.org, kvm@vger.kernel.org, "Michael S. Tsirkin" , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Stefan Hajnoczi , "David S. Miller" Subject: Re: [PATCH v2 0/3] vsock/virtio: several fixes in the .probe() and .remove() Message-ID: <20190703091453.GA11844@stefanha-x1.localdomain> References: <20190628123659.139576-1-sgarzare@redhat.com> <20190701151113.GE11900@stefanha-x1.localdomain> <20190701170357.jtuhy3ank7mv6izb@steredhat> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6TrnltStXW4iwmi0" Content-Disposition: inline In-Reply-To: <20190701170357.jtuhy3ank7mv6izb@steredhat> User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --6TrnltStXW4iwmi0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 01, 2019 at 07:03:57PM +0200, Stefano Garzarella wrote: > On Mon, Jul 01, 2019 at 04:11:13PM +0100, Stefan Hajnoczi wrote: > > On Fri, Jun 28, 2019 at 02:36:56PM +0200, Stefano Garzarella wrote: > > > During the review of "[PATCH] vsock/virtio: Initialize core virtio vs= ock > > > before registering the driver", Stefan pointed out some possible issu= es > > > in the .probe() and .remove() callbacks of the virtio-vsock driver. > > >=20 > > > This series tries to solve these issues: > > > - Patch 1 adds RCU critical sections to avoid use-after-free of > > > 'the_virtio_vsock' pointer. > > > - Patch 2 stops workers before to call vdev->config->reset(vdev) to > > > be sure that no one is accessing the device. > > > - Patch 3 moves the works flush at the end of the .remove() to avoid > > > use-after-free of 'vsock' object. > > >=20 > > > v2: > > > - Patch 1: use RCU to protect 'the_virtio_vsock' pointer > > > - Patch 2: no changes > > > - Patch 3: flush works only at the end of .remove() > > > - Removed patch 4 because virtqueue_detach_unused_buf() returns all t= he buffers > > > allocated. > > >=20 > > > v1: https://patchwork.kernel.org/cover/10964733/ > >=20 > > This looks good to me. >=20 > Thanks for the review! >=20 > >=20 > > Did you run any stress tests? For example an SMP guest constantly > > connecting and sending packets together with a script that > > hotplug/unplugs vhost-vsock-pci from the host side. >=20 > Yes, I started an SMP guest (-smp 4 -monitor tcp:127.0.0.1:1234,server,no= wait) > and I run these scripts to stress the .probe()/.remove() path: >=20 > - guest > while true; do > cat /dev/urandom | nc-vsock -l 4321 > /dev/null & > cat /dev/urandom | nc-vsock -l 5321 > /dev/null & > cat /dev/urandom | nc-vsock -l 6321 > /dev/null & > cat /dev/urandom | nc-vsock -l 7321 > /dev/null & > wait > done >=20 > - host > while true; do > cat /dev/urandom | nc-vsock 3 4321 > /dev/null & > cat /dev/urandom | nc-vsock 3 5321 > /dev/null & > cat /dev/urandom | nc-vsock 3 6321 > /dev/null & > cat /dev/urandom | nc-vsock 3 7321 > /dev/null & > sleep 2 > echo "device_del v1" | nc 127.0.0.1 1234 > sleep 1 > echo "device_add vhost-vsock-pci,id=3Dv1,guest-cid=3D3" | nc 127.0.= 0.1 1234 > sleep 1 > done >=20 > Do you think is enough or is better to have a test more accurate? That's good when left running overnight so that thousands of hotplug events are tested. Stefan --6TrnltStXW4iwmi0 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAl0ccg0ACgkQnKSrs4Gr c8hyTQgAmrtuLTRHUWq+SnSxTw9xESj0gUVZd4sbTh6S0V4rPGdVbra3YbPfZfkH IaakopaoNOkTWrPnhYmwgU30HpR8IAq/y7clSCsRIfPUYDSZok/iyag75Cy5oKno lVANXMQYQ4Kgkq07R+BER41HW3MELCrSAX57rIat1F1OD3KouG6YicgmP7wetWcU HVXVfjP7u1a2lUmuBdlcgPKX05STySKyNEQ3QdtLI6bgM6rGkx8OYn38Qe9cQuyi zVG7+8JLFoJav87vvcIIB0IT8ifWocctQY//efyVVnrfHN6T5/35TPcM4bBW8HrK Zs+bh7qyccexuuow4DrBHexFCIdtCw== =jl/1 -----END PGP SIGNATURE----- --6TrnltStXW4iwmi0--