Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1517968ybg; Thu, 4 Jun 2020 11:41:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyz3UeNr5+1DqHV/qLP++Z7ZofBWVDhSv5BxusYUCETBaFeCqI2/ZVOJGej2ivDwtOyBrpP X-Received: by 2002:a17:906:c142:: with SMTP id dp2mr5310834ejc.541.1591296095977; Thu, 04 Jun 2020 11:41:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591296095; cv=none; d=google.com; s=arc-20160816; b=J92kk4tzXgGHsa/DClmkS6hSs6+z8/wmDWCnwNrREDxHm4pgf2TrIMicgYyjMmmBfi kNECoEA14CXgRGBXVYqKtSvCFXzvCb6fGbjnWDwPQT1ChAXIxfq4SdLbtS7VZJShv89L SWoRm7Cu8Lyj1YXZ5ssRm90st0e6W5vqtXV4e/2BoGubsIv7g1XxcrxhG2i0LrLd9GDF 3cbgKIcshMdctgq93hNF8AGJDGMFxEHsDp9DUvesbV38QNH/2VHIQiiQ4sGcwrXhCUjy XXZfqVMAH2l8AlOjMDqErT4E1hgxBVnv2uBNXhcYx8kT5w/VuNGaSwC2pRuzChuhsSic +c+A== 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=lMPdVHtKDT9D7D/tGeWCGOcLhcyx/QP/e62nlCT5AwA=; b=fEHfBddVGoRjQYuMsxzuqPTPmHoCLzuPcvojj2EwclQYJ9kFwR8sePOL41ZmaurC2G IYR9xKaZWiShyUHgjvgP4v4HQ8H1Z2b/4jYhgSQ9s4f4A45rPHNxQ6kHeCEQgZ9DlRBW EbJU/bSkMDxk1t6ZoenIE4MQUbHK9SgHK4ZVx/UG/2wKiKPtn0k+Vy1cP+a/LByADZea Rv/+4c0dV7qWBML+xid0cEb4EwAPWWvhLXXchmCF9tXK9VAFTtSvlR1BTUwIFu5JQQTD SdFNVqVuri+csj5WPHdXwWF4ioe6gCupfyuQjkas+42V317dtBSOLABY6tr3BdlzlsHv 82mA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z13si2116059ejp.589.2020.06.04.11.41.13; Thu, 04 Jun 2020 11:41:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728323AbgFDNsg (ORCPT + 99 others); Thu, 4 Jun 2020 09:48:36 -0400 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:50227 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728692AbgFDNsX (ORCPT ); Thu, 4 Jun 2020 09:48:23 -0400 Received: from taln60.nuvoton.co.il (ntil-fw [212.199.177.25]) by herzl.nuvoton.co.il (8.13.8/8.13.8) with ESMTP id 054Dlw3g011535; Thu, 4 Jun 2020 16:47:58 +0300 Received: by taln60.nuvoton.co.il (Postfix, from userid 10140) id 3C6D4639BF; Thu, 4 Jun 2020 16:47:58 +0300 (IDT) From: amirmizi6@gmail.com To: Eyal.Cohen@nuvoton.com, jarkko.sakkinen@linux.intel.com, oshrialkoby85@gmail.com, alexander.steffen@infineon.com, robh+dt@kernel.org, "benoit.houyere@st.com--to=mark.rutland"@arm.com, peterhuewe@gmx.de, christophe-h.richard@st.com, jgg@ziepe.ca, arnd@arndb.de, gregkh@linuxfoundation.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, oshri.alkoby@nuvoton.com, tmaimon77@gmail.com, gcwilson@us.ibm.com, kgoldman@us.ibm.com, Dan.Morav@nuvoton.com, oren.tanami@nuvoton.com, shmulik.hager@nuvoton.com, amir.mizinski@nuvoton.com, Amir Mizinski , Benoit Houyere Subject: [PATCH v10 6/8] tpm: tpm_tis: verify TPM_STS register is valid after locality request Date: Thu, 4 Jun 2020 16:47:11 +0300 Message-Id: <20200604134713.157951-7-amirmizi6@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20200604134713.157951-1-amirmizi6@gmail.com> References: <20200604134713.157951-1-amirmizi6@gmail.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: Amir Mizinski Issue could result when the TPM does not update TPM_STS register after a locality request (TPM_STS Initial value = 0xFF) and a TPM_STS register read occurs (tpm_tis_status(chip)). Checking the next condition("if ((status & TPM_STS_COMMAND_READY) == 0)"), the status will be at 0xFF and will be considered, wrongly, in "Ready" state (by checking only one bit). However, at this moment the TPM is, in fact, in "Idle" state and remains in "Idle" state because "tpm_tis_ready(chip);" was not executed. Suggested-by: Benoit Houyere Signed-off-by: Amir Mizinski --- drivers/char/tpm/tpm_tis_core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 9d90b9a..8868fe0 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -221,8 +221,14 @@ static int request_locality(struct tpm_chip *chip, int l) } else { /* wait for burstcount */ do { - if (check_locality(chip, l)) + if (check_locality(chip, l)) { + if (wait_for_tpm_stat(chip, TPM_STS_GO, 0, + chip->timeout_c, + &priv->int_queue, + false) < 0) + return -ETIME; return l; + } tpm_msleep(TPM_TIMEOUT); } while (time_before(jiffies, stop)); } -- 2.7.4