Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5286260yba; Wed, 10 Apr 2019 16:00:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTa4d4VJGNiyam8L+GEXxk4/+X9xiAvLxqDK1oKW+2p+3pyPZD+RGrMQRkmLpTzenIWhnZ X-Received: by 2002:a17:902:bd0c:: with SMTP id p12mr20873675pls.50.1554937222570; Wed, 10 Apr 2019 16:00:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554937222; cv=none; d=google.com; s=arc-20160816; b=xqji+DckYsCxlwq+/H0nKlewD375qAmeiXIqB3wNnKdO60S+ygxeKKkeo9r/BxWEdP xcggm1aI+/n3+L3FcBE1Wm3/XgTkUEy3uqK0lBJldUKWkwcJFe4HU/NBLX32SVvWbdbs r1CAgnJI53E4DwGn7ENfirSsLiV5YIcosTequD9JutuXt5D3GEtj/hvMUDnVrrfkC5A6 9n+o/lrOpFVPoqRuKS2DghALiAtoEig4ZU1ByxO0HQc3x42UPYlP2BPZsh/d7tEfpkNc iqLyr/mOj6JsGYf2/Opu9cxkiW7dCBaV9cJE8xOrunMw5N6NyLnD4NHBPDP/kiL66eaO L2qA== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gKFjBL91WzaXlgBL41BTUy1tPPE/UPHQISJ+CNFw3MA=; b=puAlFkMAQ4/yurtzS5XidsK8kg/dAqVf7/qJxuocph93S/W6NESTcMTUDP34QpGhzV P4JkGGGBGSQRbjNunQtzVxoPEwrmiUZGoxcEu4c2d9RzN6f9wBCoFOkzUDt6TV2tirps gtILjH03bcNBKkqRskIdcnnZSfR06eSF4esK0dAaUZ8JY52G7RVvpBARiE+NASdA8ssq +TnwDqYyHKI/j10OIO04RByDZgzOTwVOy5VdPyBtULKx22M8l91SWkFEBbHhRhI5fdyw k3l2P8FRXjt1JPE4HQfeCLUtMk82dAndmoO/iPdLtXn75prQk1icjXeBvTbDSEWlr/e4 +AEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qn9NYKIz; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r189si4120693pgr.175.2019.04.10.16.00.04; Wed, 10 Apr 2019 16:00:22 -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=@kernel.org header.s=default header.b=qn9NYKIz; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726256AbfDJW7a (ORCPT + 99 others); Wed, 10 Apr 2019 18:59:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:41974 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbfDJW73 (ORCPT ); Wed, 10 Apr 2019 18:59:29 -0400 Received: from localhost (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7B5BC2083E; Wed, 10 Apr 2019 22:59:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554937168; bh=RyqPxAal45Pdz7I8FwfjoEgf8r/UWZ4dWguC7k2YtlE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qn9NYKIziqNrx85z9YXkDHc7ZOSu0DO8LY9OmwwwaUxCJF/yk+gwHPCMd+HnKnTBe rUJQONp62Q0SUz3AZFQHQL8TlcgTsmKZC9JUluaVXvvjbwAaFdXfocp5b9bDhEJ2D2 vnmFwWgm5EWoF5wfhB4am1IDC3jAYOminPUXl8LA= Date: Wed, 10 Apr 2019 18:59:27 -0400 From: Sasha Levin To: Kimberly Brown Cc: Michael Kelley , Long Li , Sasha Levin , Stephen Hemminger , Dexuan Cui , "K. Y. Srinivasan" , Haiyang Zhang , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 0/3] Drivers: hv: vmbus: Fix a race condition in "_show" functions Message-ID: <20190410225927.GF11568@sasha-vm> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 14, 2019 at 04:04:52PM -0400, Kimberly Brown wrote: >This patchset fixes a race condition in the "_show" functions that >access the channel ring buffers. > >Changes in v3: >Patch 1: Drivers: hv: vmbus: Refactor chan->state if statement > - Added the “reviewed-by” line from v2. > >Patch 2: Drivers: hv: vmbus: Set ring_info field to 0 and remove memset > - This patch is new. This change allows the new mutex locks in patch 3 > to be initialized when the channel is initialized. > >Patch 3: Drivers: hv: vmbus: Fix race condition with new > ring_buffer_info mutex > - Added two ring buffer info mutex locks instead of the single channel > mutex lock that was proposed in v2. > - Changed the mutex acquire/release calls as needed for the new ring > buffer info mutex locks. > - Updated the commit message. > > >Changes in v2: > - In v1, I proposed using “vmbus_connection.channel_mutex” in the > “_show” functions to prevent the race condition. However, using this > mutex could result in a deadlock, so a new approach is proposed in > this patchset. > - Patch 1 is new and consists of refactoring an if statement. > - Patch 2 introduces a new mutex lock in the “vmbus_channel” struct, > which is used to eliminate the race condition. > >Kimberly Brown (3): > Drivers: hv: vmbus: Refactor chan->state if statement > Drivers: hv: vmbus: Set ring_info field to 0 and remove memset > Drivers: hv: vmbus: Fix race condition with new ring_buffer_info mutex > > drivers/hv/channel_mgmt.c | 2 + > drivers/hv/hyperv_vmbus.h | 1 + > drivers/hv/ring_buffer.c | 22 ++++++++-- > drivers/hv/vmbus_drv.c | 89 +++++++++++++++++++++++++++------------ > include/linux/hyperv.h | 7 ++- > 5 files changed, 88 insertions(+), 33 deletions(-) Queued up, thanks Kimberly! -- Thanks, Sasha