Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp811745ybn; Wed, 2 Oct 2019 06:36:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFWJja0eK9iz8teNCs4wtvksMYESGPajQszX4WV/iAi2bFszNZZFZCya0QFxdaLCouXtj1 X-Received: by 2002:a17:906:6d53:: with SMTP id a19mr3057620ejt.144.1570023418927; Wed, 02 Oct 2019 06:36:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570023418; cv=none; d=google.com; s=arc-20160816; b=tnT+cdsXguRia9a+2mokwevvqRd+NV/Av8kWDCp9lNV4iwb47CbUZvnefIAKReuqjr zbaoCY0WScbSM2dEVF2K3qTBEh4M+OJDHvcBk4ehAWujdMMoFYpCoGpfIcoZGW37Z/2h +BRzRkAUzeEORMEOMWPDRhktAVT23bP3JAMFx0I8PGmiNTjOUVrau/vs5lLUYdz/9J3A ltDVYKoeJMhFq/PQDB2C5AhlBLQcsKqfOtYkYYli9bBN6F9MXohIbnaUE1LgEaGhButn moT6FT23Q8SDPDZMu4reVONiW7z2/r4UioKeQsOaV9cDmPlHh7aWYC2VJZVx3nTURaPe XFCg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=L0r6kFMSSQIgc6cPB6TJdl28Q873mAGlQjZ81bMizWQ=; b=bC+QBY8r7Q+UyEi+tuu+9M9gudupJXs4dSDMHMyYkldVnk1kpSs8bwTQjaFxIMkAT/ O4W7VBqsIPqEEqmppjLvZ2+QHODwbWmBsaQCnt4XEyjIPV29DNEwNJhoQ+HdG9KY/KSF LObhNqnredGx1/EVKEbgMDE7tazCga7Y/IMQUZMUYrFXvy7+S9yZqWRhlxlpkEJ1orJe 3+xTuQO3I8DjZ49KTm0ksWzPeu/0qvsiC6uqEIczWiClRKxbtrb/1jr2mKnhjqHL1msp VabBT0zC7xlACH4knVQiePj7bxF6JKZ7/HYLYroN5epWUwuhS0f2RllDauxJdi2QgDNz rfbw== 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 z10si10470744edd.140.2019.10.02.06.36.34; Wed, 02 Oct 2019 06:36:58 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727687AbfJBNPS (ORCPT + 99 others); Wed, 2 Oct 2019 09:15:18 -0400 Received: from mga03.intel.com ([134.134.136.65]:30344 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726295AbfJBNPS (ORCPT ); Wed, 2 Oct 2019 09:15:18 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Oct 2019 06:15:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,574,1559545200"; d="scan'208";a="203589840" Received: from jsakkine-mobl1.tm.intel.com (HELO localhost) ([10.237.50.158]) by orsmga002.jf.intel.com with ESMTP; 02 Oct 2019 06:15:03 -0700 From: Jarkko Sakkinen To: linux-stabley@vger.kernel.org Cc: Vadim Sukhomlinov , stable@vger.kernel.org, Douglas Anderson , Jarkko Sakkinen , Peter Huewe , Jason Gunthorpe , linux-integrity@vger.kernel.org (open list:TPM DEVICE DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 3/3] tpm: Fix TPM 1.2 Shutdown sequence to prevent future TPM operations Date: Wed, 2 Oct 2019 16:14:44 +0300 Message-Id: <20191002131445.7793-4-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191002131445.7793-1-jarkko.sakkinen@linux.intel.com> References: <20191002131445.7793-1-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vadim Sukhomlinov commit db4d8cb9c9f2af71c4d087817160d866ed572cc9 upstream TPM 2.0 Shutdown involve sending TPM2_Shutdown to TPM chip and disabling future TPM operations. TPM 1.2 behavior was different, future TPM operations weren't disabled, causing rare issues. This patch ensures that future TPM operations are disabled. Fixes: d1bd4a792d39 ("tpm: Issue a TPM2_Shutdown for TPM2 devices.") Cc: stable@vger.kernel.org Signed-off-by: Vadim Sukhomlinov [dianders: resolved merge conflicts with mainline] Signed-off-by: Douglas Anderson Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen --- drivers/char/tpm/tpm-chip.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index 0eca20c5a80c..dcf5bb153495 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c @@ -158,12 +158,13 @@ static int tpm_class_shutdown(struct device *dev) { struct tpm_chip *chip = container_of(dev, struct tpm_chip, dev); + down_write(&chip->ops_sem); if (chip->flags & TPM_CHIP_FLAG_TPM2) { - down_write(&chip->ops_sem); tpm2_shutdown(chip, TPM2_SU_CLEAR); chip->ops = NULL; - up_write(&chip->ops_sem); } + chip->ops = NULL; + up_write(&chip->ops_sem); return 0; } -- 2.20.1