Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7420606imu; Thu, 31 Jan 2019 09:48:39 -0800 (PST) X-Google-Smtp-Source: ALg8bN4AZ6zjbJiUN56tEs8y/c24Qtmap/poI2dJC4X4vAZR8DKMUXqsq6sAhy9sc5KzmtrDlQs5 X-Received: by 2002:a62:f5da:: with SMTP id b87mr36248459pfm.253.1548956919856; Thu, 31 Jan 2019 09:48:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548956919; cv=none; d=google.com; s=arc-20160816; b=QxBCL5EZ8XP+w1o2PmiM0zTycOzHdd6PTYKM2ab3u1hmvRRYif+YdZIzJBbeaRJ5b9 WyXwBWxcj7siV1s5u/H3MZnhigumrI99v0D0gMdIFTQ3QKXYGtw40KNdyrE+kF4dQaP/ 74iNxeqhs+/a/AGoKhlM7Tvlo/B+/2t/AQ/qgIaa4NMMVmTl/1sduiveoRIGb05so1/s UgeKjG1Xa2MYYlPgTISfrHChxgJ4wNbi4IM9aNVn9jPXkF/n7/1HvLwcwk84St+1oO8s iWb8ZNEl7Yex80/6PWobAgsIGkxsK7BBHB5ofTxFgV3+ruQ6SsQSsTP4++J+c1aIIEJY odrw== 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=Yd3EYB9CxmABaQHZJKF+uIWLsaH4ep2DIxCWor39Niw=; b=Tuotch3KbOstxZD/gnbmG15DS5Cbb6QZSUVOjKldVwjc3FTnzk9oLfB7MFC0hxDj2C Q1YrKCPo4VS+i6i8V2HUt8WndLCFUTdB+mPNxvWLFE97XSKjI7VkLl+v6WzXvFFQC7+J YazrNCufKxNk4aI3L6vzil4hV5ToDEF1TIzSqZ+8W0PuCsz+OYN5xw7z5JGvoLi6SVw+ ryosJ8IrTfFzHNs/KedLS/cHNYGjBeCIPR4IQgw3wW8Tu2tvtwze/WYZYp/Ln6QWX1j/ PbUR9tZxxiVt6oHvzzeAO1A4RmR7JBNHmKsPwUxOylfhRIPYJ5ImX8DsTKSVvk0yjl3U +idw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ORMLU9iX; 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 bi6si5036842plb.279.2019.01.31.09.48.24; Thu, 31 Jan 2019 09:48:39 -0800 (PST) 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=ORMLU9iX; 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 S1727412AbfAaRrM (ORCPT + 99 others); Thu, 31 Jan 2019 12:47:12 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:36739 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbfAaRrM (ORCPT ); Thu, 31 Jan 2019 12:47:12 -0500 Received: by mail-io1-f67.google.com with SMTP id m19so3391878ioh.3 for ; Thu, 31 Jan 2019 09:47:11 -0800 (PST) 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=Yd3EYB9CxmABaQHZJKF+uIWLsaH4ep2DIxCWor39Niw=; b=ORMLU9iXDVuB3AQl44W88pRun2lzoa2EQW2QcSyqBmtUov69GZ2MYlWyfnzUGAn91c Xlh1asD6ldIjfimrOpUOjZQ2JbfHq7sws3cZpQtLu7U4Ta3t6Tw9dbK1B7KxCIPqvBA/ HAnKLF3n0rRsfSH09FB5EapW8mTYiCZ4wMplQJJhORMSplTzwyeSh2x5Q9Pff00TR4MK +YqJ2sQbyDJZPOpuBnyCi1t51UuB/1cTSeiqPzY40NWKjixsGF/fPgsMvD70kHzSR5gP l/HZgrOY0O5ur1iRcXqJVFoefMbChs5wC2UbnPGun7Qll8gRJ/2PxzPeMxwjicau3CbP 9wVA== 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=Yd3EYB9CxmABaQHZJKF+uIWLsaH4ep2DIxCWor39Niw=; b=mCzzZxTkLMyfpKMvqDasTHcaj3/gqrds/TAHeNkrqwvnohIcTrWcLKr7RKTgxEsVa8 V0hqRTTxVSsTekYgCWrCjo+Zqwz9NIfebs88+n5ZDYTCUap9GFbgdOR4lt/of0gdGya4 D9rxtVPWszuOMWRvfqdOJXnOEjOZ1ZjmsU14ln7YzjnFnkQze3P1yGxxIIY6LTeC11KS Q5D+IJee80X7uKYRoBtMISHLoeVcEnpWWBtkOr0znxjywU2jjny/lZjepWumXY+3k8XD qqoUCwssW9Q66GNSCP9NWuVV1RjDd/1mamemmNWgKgfqz30Na/j9GA9iXAZD+tEoARj+ +keQ== X-Gm-Message-State: AHQUAubkqlIazWgQKKl/BnlDzpID4TzjiwSE0v3WfHB9vQ0s2HJdwQmB fKEd0elTrzYKNpZOGORoRP0YlOp3XDI= X-Received: by 2002:a5e:da49:: with SMTP id o9mr20754694iop.246.1548956831211; Thu, 31 Jan 2019 09:47:11 -0800 (PST) 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 85sm2341262iou.8.2019.01.31.09.47.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Jan 2019 09:47:10 -0800 (PST) Date: Thu, 31 Jan 2019 12:47:07 -0500 From: Kimberly Brown To: Michael Kelley Cc: Sasha Levin , Dexuan Cui , Long Li , Sasha Levin , Stephen Hemminger , KY Srinivasan , Haiyang Zhang , "devel@linuxdriverproject.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] Drivers: hv: vmbus: Add mutex lock to channel show functions Message-ID: <20190131174707.GA2055@ubu-Virtual-Machine> References: <20190122020759.GA4054@ubu-Virtual-Machine> <20190122064246.GA28613@ubu-Virtual-Machine> <20190128195845.GA3723@ubu-Virtual-Machine> <20190131151958.GT3973@sasha-vm> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 On Thu, Jan 31, 2019 at 04:45:35PM +0000, Michael Kelley wrote: > From: Sasha Levin Sent: Thursday, January 31, 2019 7:20 AM > > > > I've queued this one for hyper-fixes, thanks all! > > > > Actually, please hold off on queuing this one. In a conversation I had yesterday with Kim, they had identified a deadlock. Kim was going to be looking at some revisions to avoid the deadlock. > > Kim -- please confirm. > > Michael This is correct. I need to send a v2 of this patch which addresses two issues: 1) Check channel->state inside the mutex acquire/release in vmbus_chan_attr_show(). 2) Prevent a deadlock that can occur between the proposed mutex_lock() call in the vmbus_chan_attr_show() function and the sysfs/kernfs functions. I've identified two possible solutions to the deadlock: 1) Add a new mutex to the vmbus_channel struct which protects changes to "channel->state". Use this new mutex in vmbus_chan_attr_show() instead of "vmbus_connection.channel_mutex". 2) Use "vmbus_connection.channel_mutex" in vmbus_chan_attr_show() as originally proposed, and acquire it with mutex_trylock(). If the mutex cannot be acquired, return -EINVAL. I'm leaning towards (2), using mutex_trylock(). "vmbus_connection.channel_mutex" appears to be used only when a channel is being opened or closed, so vmbus_chan_attr_show() should be able to acquire the mutex when the channel is in use. If anyone has suggestions, please let me know. Thanks, Kim