Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3256247ybd; Fri, 28 Jun 2019 05:37:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnzrPFli9CS86f8WtWeSm7sfVWm1DD+QWgLYvO6ARva3JIu52xTCMNjpQfTtYnrS1BYJx0 X-Received: by 2002:a63:c34c:: with SMTP id e12mr8855523pgd.195.1561725465476; Fri, 28 Jun 2019 05:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561725465; cv=none; d=google.com; s=arc-20160816; b=0TnuNv2U4t7H+yFxff3aVlSFU/r9nNQOTg7BVd4e6OMUWeI0KG92GIAQGW4NQPiaxV WA6RQAhpTLJwCLej9rA5hhFvzw/41rJf3KJOn331Irw2QV+zTYOC1aqM4bcSaDvBZySs HhtaX5m1dWihnxmQF4mwKpHPdocS++89l2QHaX0vDhgQnHFDdS6CINDwgIfBu9OlewJo s0NkolESSPnTTgtqB0wZ+5Hhn7w3EJZ4XPVdr228hKobZ7jK94j+aHIHAwu+L07aKOko ksx2QNpiCyengA7MkPKCdo4bceI2ubrGFrzFvJsELUAqR2IOrtM3fdYjHbiZLFaMo+VO kUHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=wgbZAdAiK2cNx6fJ7G4jBBzfc3Eimb6+xwSrU4bHLrM=; b=eZGz7XL+Elct3kL1y0lluETR85va94URizUR+3rDCtLCAvcleHpj/rIpY3Zp3pm2A0 t73u0XIl1gc2G3Arjb1atwNHafs9IFUnRBDCSA8Vzy83m1eweirC0dTUxhFaSJ73aBOO f7xYdz7mrz1R4Sa8u2PIEDN+uRHhtgYCWMCrBPH3ejzm+C+68BLwdU/6PKLVJLjmCZ8h Ucmk0rOfPSdqY/+h4lu+jDVDEY9hNTw1LrBMvw+CFLNzs2g9cnmKUQdDdOsPLOrUpFhy CSKQlEcBC3pJQux3/XlO7ek0LpsbgUpOssw3dwH8x3ok/WK06PDwZCfBnZ5mDnu8ULUI 0Dpw== 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 o63si2309369pjo.94.2019.06.28.05.37.29; Fri, 28 Jun 2019 05:37:45 -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 S1726925AbfF1MhS (ORCPT + 99 others); Fri, 28 Jun 2019 08:37:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38734 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726578AbfF1MhP (ORCPT ); Fri, 28 Jun 2019 08:37:15 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D9CE87633; Fri, 28 Jun 2019 12:37:10 +0000 (UTC) Received: from steredhat.redhat.com (ovpn-117-102.ams2.redhat.com [10.36.117.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 950825DA96; Fri, 28 Jun 2019 12:37:00 +0000 (UTC) From: Stefano Garzarella To: netdev@vger.kernel.org Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, Stefan Hajnoczi , "Michael S. Tsirkin" , "David S. Miller" , Jason Wang , linux-kernel@vger.kernel.org Subject: [PATCH v2 0/3] vsock/virtio: several fixes in the .probe() and .remove() Date: Fri, 28 Jun 2019 14:36:56 +0200 Message-Id: <20190628123659.139576-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 28 Jun 2019 12:37:15 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/ Stefano Garzarella (3): vsock/virtio: use RCU to avoid use-after-free on the_virtio_vsock vsock/virtio: stop workers during the .remove() vsock/virtio: fix flush of works during the .remove() net/vmw_vsock/virtio_transport.c | 131 ++++++++++++++++++++++++------- 1 file changed, 102 insertions(+), 29 deletions(-) -- 2.20.1