Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp210578ybs; Tue, 26 May 2020 07:24:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4Dg0i3V0t5+hPxQTi6EhWQjvXaADK3EHIt+9reNAWhJ4mZA9xizuAA3TF8emxEq1VoGEH X-Received: by 2002:aa7:ca0c:: with SMTP id y12mr19388701eds.60.1590503066102; Tue, 26 May 2020 07:24:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590503066; cv=none; d=google.com; s=arc-20160816; b=Hwa77xYH4fcEmQRvwn2aFmQob3239dRp4G0l5MroPKd03BYJknaY/c17S+o06wQtn6 BlOKbffcfUk1LIQSFt3/E/X9moioMqszUrXwDiXvQKuXTHkFjhMCE8ZmNbv6+Xr7N33J Vqf8xn7c5P1VD1yQC8F0e0WhVpo9YprovCcTSAXYV0zGTYtSunyaXAdel+mMWKj5hgv9 TNzS8sGSG/+neDuA38UysfDJinsQ17uHuQ5bLR3uLz+pJ2Ys5VIDGyE9qrOAgYPx3Qqh Ky8YvRIVBgnQuhkthjCh43SKUM+84UNsRUndqriJYkWBaM6NQuljfxPWnFnPOidJYuV8 eDqQ== 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=PXJyGuuVq5WZVwSpHVs6ssqKKN81Sfg9r4hgBBfFABc=; b=oGIjYE46yFyvwHQWRyvEdHFTJVcz8dSwkUj3Yg+iH/fnHC72588Y1nLFeiVt0H7eLI HgHvMG+fXcUeVW75qSyWRRACysOAWj06Sft7Sx5o1RDIKjak6kmR/agRCSfI5+yafLib H5mkcsLbI/JGxnjqzYFziuxhsIxZtQd3cfzt4uBKcFyRxkHiEySRMIuxEy9k2aBMzkQd PLVub1Hw0W2/rY3E0v5AOMfoW0myJxOzQqIc6rl9JhqCkHzB7sUz+srJt0CLHcKRrd3b UEZVn8N4LMmpm7Sowb+vQjW1/DMJ8Ov/PiLye8xvmar6g1P3tLkdF1sJV1fIOCX+SMFq wYxQ== 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 lc10si11319062ejb.156.2020.05.26.07.24.02; Tue, 26 May 2020 07:24:26 -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 S1729541AbgEZOTS (ORCPT + 99 others); Tue, 26 May 2020 10:19:18 -0400 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:49624 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726811AbgEZOTR (ORCPT ); Tue, 26 May 2020 10:19:17 -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 04QEHZpH008683; Tue, 26 May 2020 17:17:35 +0300 Received: by taln60.nuvoton.co.il (Postfix, from userid 10140) id 56315639BE; Tue, 26 May 2020 17:17:35 +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 v9 6/8] tpm: tpm_tis: verify TPM_STS register is valid after locality request Date: Tue, 26 May 2020 17:16:56 +0300 Message-Id: <20200526141658.157801-7-amirmizi6@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20200526141658.157801-1-amirmizi6@gmail.com> References: <20200526141658.157801-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 39b28a0..d9c9ff1 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -222,8 +222,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_result(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