Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2688195imu; Mon, 19 Nov 2018 04:39:54 -0800 (PST) X-Google-Smtp-Source: AJdET5eiIki7eQ9zr6pQRX/C9SeCdWbv5GSIL7ySSCz+fBPWMJhWlpy3f7WjeIoxbRIZ+Zoq6WUo X-Received: by 2002:a63:d747:: with SMTP id w7mr19553485pgi.360.1542631194308; Mon, 19 Nov 2018 04:39:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542631194; cv=none; d=google.com; s=arc-20160816; b=vX4t/zme9WnuZU60OyE5TNurvZoL8T+1vOtsXswEUXcpfMB6alJDsRWSuRPczqpFMw Bs3HERYmRrtvb0Y7pbuBJL1VeSSQYl67WcF7MtbATwysxJfRfvmRR/5YQXvPubhtIj1P 9w9LQhZs7TN+79zGOrz/RxJsfSXqCPMqqSWlh+kjzTViH/rSkfXR8db0L/bxnYDsj14R qnaZ4vJDKBQeg3jTf3e/ExyVDfqTNh9/WMQ0YA8SKhZNyQLbtACkvBhoS+w5WEpc32cU 0y+CNAs7l7YDXJZBTYSZ7c+JV3OzQZ0Vycv4yufSB9fGjzN9gxzT4g9CfJlWxFC4K6E+ U2rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=7wIbFAAxEahmqkD/xZDyHuZ49mlN9Lo4cYBZgHO9UFc=; b=Ul+7ln+5S19BBvcYW1BrHrGa3ZxQeCkRe8iB2dbARr55V+VlCyeYdnEyEYi9xRErk9 CEEKofETmjihDuWeAOzvpcAxz8ysQMBZN39zA6eYzyAHulDNwUO32BT3vYNkHd17pCE0 AW2f2ulcmXHdpdgiq0F2VCJgz7SQPgNu+GzK7mGtMvwx1Cnx1g1YJYuyqVyc3xZhHj+8 1y9Q/Yy6S3cPBG715rAd4IPqsAwGqe76eoZW2fDmZ3qGR+YwuuF5XH9KYpEAB/hZMIl2 zNvoL0DApkCtVU/BRWTIgcCHyn52mlOnjStlQQlu4Qe0PexI/tjCxTC5GhuidjQ9mof/ paIA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b10si23554718plz.233.2018.11.19.04.39.39; Mon, 19 Nov 2018 04:39:54 -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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728860AbeKSXCW (ORCPT + 99 others); Mon, 19 Nov 2018 18:02:22 -0500 Received: from mga17.intel.com ([192.55.52.151]:9853 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728530AbeKSXCW (ORCPT ); Mon, 19 Nov 2018 18:02:22 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2018 04:38:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,252,1539673200"; d="scan'208";a="109326160" Received: from tmuluk-mobl4.ger.corp.intel.com (HELO localhost) ([10.249.254.135]) by fmsmga001.fm.intel.com with ESMTP; 19 Nov 2018 04:38:45 -0800 Date: Mon, 19 Nov 2018 14:38:44 +0200 From: Jarkko Sakkinen To: Jason Gunthorpe Cc: linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, James Bottomley , Tomas Winkler , Tadeusz Struk , Stefan Berger , Nayna Jain , Peter Huewe , Arnd Bergmann , Greg Kroah-Hartman , open list Subject: Re: [PATCH v9 14/17] tpm: remove TPM_TRANSMIT_UNLOCKED flag Message-ID: <20181119123844.GA8755@linux.intel.com> References: <20181118124753.18613-1-jarkko.sakkinen@linux.intel.com> <20181118124753.18613-15-jarkko.sakkinen@linux.intel.com> <20181118195104.GA21938@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181118195104.GA21938@ziepe.ca> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo 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 Sun, Nov 18, 2018 at 12:51:04PM -0700, Jason Gunthorpe wrote: > On Sun, Nov 18, 2018 at 02:47:47PM +0200, Jarkko Sakkinen wrote: > > Added locking as part of tpm_try_get_ops() and tpm_put_ops() as they are > > anyway used in most of the call sites except in tpmrm_release() where we > > take the locks manually. > > > > Signed-off-by: Jarkko Sakkinen > > Reviewed-by: Stefan Berger > > --- > > drivers/char/tpm/tpm-chip.c | 2 ++ > > drivers/char/tpm/tpm-dev-common.c | 4 +--- > > drivers/char/tpm/tpm-interface.c | 8 -------- > > drivers/char/tpm/tpm.h | 8 ++------ > > drivers/char/tpm/tpm2-cmd.c | 13 ++++--------- > > drivers/char/tpm/tpm2-space.c | 15 ++++++--------- > > 6 files changed, 15 insertions(+), 35 deletions(-) > > > diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c > > index 32db84683c40..157505b0f755 100644 > > --- a/drivers/char/tpm/tpm-chip.c > > +++ b/drivers/char/tpm/tpm-chip.c > > @@ -58,6 +58,7 @@ int tpm_try_get_ops(struct tpm_chip *chip) > > if (!chip->ops) > > goto out_lock; > > > > + mutex_lock(&chip->tpm_mutex); > > return 0; > > It really isn't appropriate for something called 'get' to be exclusive > like this.. Call it tpm_try_lock_ops() ? Would definitely be appropriate to rename it, yes. > > diff --git a/drivers/char/tpm/tpm-dev-common.c b/drivers/char/tpm/tpm-dev-common.c > > index c7dc54930576..582caefcf19b 100644 > > --- a/drivers/char/tpm/tpm-dev-common.c > > +++ b/drivers/char/tpm/tpm-dev-common.c > > @@ -33,7 +33,6 @@ static ssize_t tpm_dev_transmit(struct tpm_chip *chip, struct tpm_space *space, > > struct tpm_header *header = (void *)buf; > > ssize_t ret, len; > > > > - mutex_lock(&chip->tpm_mutex); > > The now implicit locking should be tested for using lockdep calls in > all places that assume the lock is held by the caller. Yes. Most importantly trusted keys and IMA should be tested with lockdep turned on. /Jarkko