Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp4131122imc; Thu, 14 Mar 2019 13:05:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZr5OttuMrKN3PaybQde+H4k7A8by2dSdWmCZ+BUGhRaFjmiTL5eJcw0t55M2dMS1rjRKr X-Received: by 2002:a17:902:e40a:: with SMTP id ci10mr150296plb.77.1552593953532; Thu, 14 Mar 2019 13:05:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552593953; cv=none; d=google.com; s=arc-20160816; b=O2llHMi08zGtro4h2XJdrQ/k9y7+2caC+i9XD9RDTYcUbOrxBw1PGYFY3d/ijGSp7k 0twHJSmbHO5hmT6oJS8XhNcqQLKaS+6OsGyjgSnLURNQTX2i3xG0PJwcKHNEJCNUE2+Q ktDdew7V/aOa4De0GYQ3WN7jSCHWIVavxlMMG42sLyeGQRJQSSDy7ov5h9pZj0e4zWDB +Lx3kX8luesEw6yvBV3S1nkExlDH9SYlJ8NfiBjMUCr5mNn9hESqhBnH9v/t7UtS9BqN XfJzgX/etxDL89T7buvo7jw0n9qFpq4iBK9c1KCW8L08vt1KXwE5UN9ue3gucNnU4Ehe iDYw== 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=g99EPKxKMgj2H+cqNYPOHoYCKI5hzg27tCOeJsLf6eM=; b=B7q+S+dmgkd/dluqMXJ76D+liBEUYusoieOGHVDqCqCNGPPCEgrF/kQ2Hpo/7R2bRz WaFIBxkPwF6j4SHD5fIVyLoC3xzil04DtzGIn3IeETa87FjsKHIHjagWVvckMqjdPyi5 S391I7k6rMnsnggHgODrxw67SsBDPj2h0Nh43RCz+iHcBPjS9DVcLb2dtFjaRb34ebI/ c5W3JZLdRMQ/9CS+QFFFbVug3MKKmrxfyTWAy/8NHSPz2UgVnq5HcZlb4g4Y9OdonzAY B+HCDXHRhAvfu9neAPTTeiSYlmy3JM2BTcZB3G1+vrXZVzyily1EIC0LMoAzkAKALbRJ WhmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pmpuRjYA; 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 n15si12373174pgv.398.2019.03.14.13.05.37; Thu, 14 Mar 2019 13:05:53 -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=pmpuRjYA; 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 S1727480AbfCNUE5 (ORCPT + 99 others); Thu, 14 Mar 2019 16:04:57 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:35516 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726444AbfCNUE4 (ORCPT ); Thu, 14 Mar 2019 16:04:56 -0400 Received: by mail-io1-f66.google.com with SMTP id x4so6283068ion.2; Thu, 14 Mar 2019 13:04: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:content-transfer-encoding:in-reply-to :user-agent; bh=g99EPKxKMgj2H+cqNYPOHoYCKI5hzg27tCOeJsLf6eM=; b=pmpuRjYAqi2GBmUwoEYclzf2Uipfsv5OWZBETNx0IgCYH3OyO6YQO5Ds+HKQnqEP5c k0/bVxMhjTwTVlw8K9H7JXNwYaXjOAwFvSTKloBmxKbcyHAIwwKG0ZSTOLqbZYG01UiT WsXvHCYzGrvTAxP9vvVvpS7rstPQ56vYoJL2VBwQKLREFky2UTrgbBllwGxuxKp3Xcp5 Afad8X/2tMcYd2Leb5Wjmn5xbZ/JjCg0GEiCG7CLcnabVtWlLInRstl11LpMXR8ydRWW IO1SBA9IpPwOjkPeBI+SvZndNZHugg0yxYBpIQyNMFPvZ3xwmSkuvb9/ISA/PAgQlX8G mvnA== 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:content-transfer-encoding :in-reply-to:user-agent; bh=g99EPKxKMgj2H+cqNYPOHoYCKI5hzg27tCOeJsLf6eM=; b=N8WAUKusFmcuFcmcWwLwh0KuDkbgl5XU2kPtC5E5fvdRbwxFTZ0Xvt6vztFcHfGu52 OCfs/96fxdZmrB1hOQChKj/wmwtfjqX7ofXfkW+DkhgHLWDwcT0+A/Hp90htdK7wOL7x lRsMwz6RKRUw0PedcrQvUEDPSoayEVoxMhcc080mP9hT0WlAnyXOV4YCogr9eKcuj0yO za3doDygmD6pEHc2ebrF9Qcx9KRoNdEZuBiCRliqkLBcvpvUaxo34iNvMm7eZj3bryf+ W4mipiisdn9rlBpMGtMmIYDJNDYf3iy7Izu4NXKT4SejDCvQzSnCLyAHmaVZF6x1GLVG SIAQ== X-Gm-Message-State: APjAAAWAWgSBUC2jyXj+vOuf1Jlvsn9DxQFxge8jA+P7Hh8meUknNs74 YhExhPU4vWcQvc5LCuh8tUU= X-Received: by 2002:a6b:6003:: with SMTP id r3mr22163874iog.231.1552593895611; Thu, 14 Mar 2019 13:04:55 -0700 (PDT) Received: from ubu-Virtual-Machine (66-188-57-61.dhcp.bycy.mi.charter.com. [66.188.57.61]) by smtp.gmail.com with ESMTPSA id w12sm7185739ioa.38.2019.03.14.13.04.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Mar 2019 13:04:54 -0700 (PDT) Date: Thu, 14 Mar 2019 16:04:52 -0400 From: Kimberly Brown To: Michael Kelley , Long Li , Sasha Levin , Stephen Hemminger , Dexuan Cui Cc: "K. Y. Srinivasan" , Haiyang Zhang , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 0/3] Drivers: hv: vmbus: Fix a race condition in "_show" functions Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.17.1