Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp689796ybi; Wed, 3 Jul 2019 03:08:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMa2u20B2BvRgpHAc98w2aK16ZmwLzuwex04eZ5gam2JUIcyC9gfjdRK+AXcdMDEJxp61D X-Received: by 2002:a17:90a:a404:: with SMTP id y4mr12188208pjp.58.1562148494647; Wed, 03 Jul 2019 03:08:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562148494; cv=none; d=google.com; s=arc-20160816; b=SItmZptv9ADSFdBNXfi/78EwlypIztcwAGdoJYDH0i6CtvSaMIXYDIgqhnnuGCNMgG KwwN/7qDsgkSdSrvvaEPCfqhfuOACdCmlJNvaI4UcgV8ojDDKF2gP063W0ORDq8vBQWN EFzhbBFyd7EdJUF10s7UIIX2u02hqVFXk97brnZxZlRlT7NYjOlbTszoEqdU6K8TmFP8 MYQZBGWNC70rOqpzacZte+qU7geHhIsftwf49UdddYfhq1jCCXVS/UVr0BPcsZ/uHCgT +z1k5aYlzdeWD7piyMI71Lc2e4ckUThcJz0qzkm37UsU9Gn4svFp47iTcyBW/5mjppQc VQMQ== 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; bh=VNvFKH5K+pDMmuMUJ4DZzYn2K79WWFEugthw2tWzrCE=; b=NKwmsublOw2pRW1RyYVBiztNpd9TQVkjIOVOn3mC5H9UU6kRMUpeMV9eHttDAIKmYC AGyBZGhvcORB601dw7mvZXkH29Nm1SAQm3LgoVBasKE4vAys5CtHt4bicY1JOHi4A23c UuBVjm6ru47Uy5JBHg3IaAA5RuK0h9dWh+IjpBN8kvv8n7qqiUzjhIEPhhsgtZTD7/13 WtHM+5+y9DVwfVA6FyI0oHWCKPevEkewD67JFnk0DG+Go44gmdgdy+kTmQpJr0iqTLht x0/nkxSnpGabeEOhM6CxLnNzPmF9dSys0OTFLL7H7BiyXEW2s9k8Co7aepngsJXXd6CA QASA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d7si1983720pfd.185.2019.07.03.03.07.58; Wed, 03 Jul 2019 03:08:14 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726811AbfGCKHd (ORCPT + 99 others); Wed, 3 Jul 2019 06:07:33 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:34891 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726308AbfGCKHd (ORCPT ); Wed, 3 Jul 2019 06:07:33 -0400 Received: by mail-wr1-f65.google.com with SMTP id c27so2106241wrb.2 for ; Wed, 03 Jul 2019 03:07:31 -0700 (PDT) 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=VNvFKH5K+pDMmuMUJ4DZzYn2K79WWFEugthw2tWzrCE=; b=L5bSJ23nDj0fE71yEvu5iWM3J99PcKGk5vVt9hfZSoLVC4vBxHNzXRu1aFMgA9zVOc o7SxFO3LWmFaSfblyzl2ERJzBxlwIv70ZvnDpXiDtZ+tlUr7Tdzkda1mE5XplWTccCar qxYlXKh3DhX02EtD+5yijdeMmTCgo0XMQwbUkPBAz7fYFyHU20vPRqRHj/O3xELtNFTr LXk74n5fpvUkib2ejjUHeLgnlOHH/SY79K6i/OkuJx7MHD0ftRrYz69xLcb2Nd4+F4AF BdGOfrQLFSfY6fJ7irQ9WNjvwgE5kATWzG7FuhXV7T+nbD5JL0JWYav5Aq2Z8NctAxMV LgJw== X-Gm-Message-State: APjAAAWLbvawjiNDCAEx/Vx/SVH0TmuED2xwXFgLuRd+hiwLkQVyheFK GfrQ0X3/e4cdgqdadq7LdBC08A== X-Received: by 2002:adf:dfc4:: with SMTP id q4mr27669596wrn.54.1562148450882; Wed, 03 Jul 2019 03:07:30 -0700 (PDT) Received: from steredhat (host21-207-dynamic.52-79-r.retail.telecomitalia.it. [79.52.207.21]) by smtp.gmail.com with ESMTPSA id z5sm1183115wmf.48.2019.07.03.03.07.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 03:07:30 -0700 (PDT) Date: Wed, 3 Jul 2019 12:07:27 +0200 From: Stefano Garzarella To: Stefan Hajnoczi 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: <20190703100727.kuwpyc5sksrgmoxb@steredhat> References: <20190628123659.139576-1-sgarzare@redhat.com> <20190701151113.GE11900@stefanha-x1.localdomain> <20190701170357.jtuhy3ank7mv6izb@steredhat> <20190703091453.GA11844@stefanha-x1.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190703091453.GA11844@stefanha-x1.localdomain> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 03, 2019 at 10:14:53AM +0100, Stefan Hajnoczi wrote: > 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 vsock > > > > before registering the driver", Stefan pointed out some possible issues > > > > in the .probe() and .remove() callbacks of the virtio-vsock driver. > > > > > > > > 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. > > > > > > > > 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 the buffers > > > > allocated. > > > > > > > > v1: https://patchwork.kernel.org/cover/10964733/ > > > > > > This looks good to me. > > > > Thanks for the review! > > > > > > > > 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. > > > > Yes, I started an SMP guest (-smp 4 -monitor tcp:127.0.0.1:1234,server,nowait) > > and I run these scripts to stress the .probe()/.remove() path: > > > > - 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 > > > > - 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=v1,guest-cid=3" | nc 127.0.0.1 1234 > > sleep 1 > > done > > > > 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. Honestly I run the test for ~30 mins (because without the patch the crash happens in a few seconds), but of course, I'll run it this night :) Thanks, Stefano