Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp407558pxb; Wed, 3 Mar 2021 06:23:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxg/JA8QPrOxLh7pVoR5+GNvwrksJJxoN8uWSdaiWH9RhUMlHAKsb4ntA9CNT8hzVkuxxf7 X-Received: by 2002:a50:da4f:: with SMTP id a15mr25195398edk.301.1614781422344; Wed, 03 Mar 2021 06:23:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614781422; cv=none; d=google.com; s=arc-20160816; b=iWxW4/QTfNm8XoFw6OPidV2JOTH9sLt/bSX93bfgFLgub/kOGTOepD2XCrGLKctTED WAlOBRfqAC7n7zPqi9paLKuuIRKgEGEw/WAZ9gJKvEDzKZhMcgNqfgbBsx1+K7eZzXiC I5HFQq7GD7pL384zMlvuFa6WDVxE0VFLHu+21Ux+JT8IS0n1ZN+yxbiEMtqor4NwbCeR 9N3w6+1VTXj3slcOm2+DoEO9RIiyIs3/pcaU8cRhjrScWlSj9MWAOsH9lY6BrlD0cIwR Qz0HRiBUDFBpubCgzw+XYR/n8v4k4MbYK8wPAd8eeSQtT6B23SdGzr7HfFDPDx1y/GuK WoqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cq9S+vJxpoIwsrXPeN7Wh0Zl6wS+qNlYddn2dICXwaE=; b=sDGty/Xk+e2uc8s++7zGYiEdvQ5qN1thITHHpBl7LIhzbHDgv9PG+pCYUZf3Cu0Ot8 PtQhiX7vlZ6pp7f8OtUIg+kNvo8Um6NtdDqkMlckvg8bLvFIIYS046wGspIYvLRghG+l q/0Q/YQbVD//wM3JyVshthfjRA668xM4jJ7ztFUA+9Ud7G71nHe+cojXvkCNAvfmK7gl h4ffTTf56EK7OFAmrbTagBF9eDM/YDKjp6Iq+AQ6xlwdRo13bu5c/qFqZ/h9IOB9wSHm 2WBxpV9hY5Cc71Oakaw//jGdChf2mDfO3HUue4slwxpBT2f15PyJZ5MuQ4R5XLVV7KA5 5l3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zNF4r4Eb; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w2si985186edc.92.2021.03.03.06.22.41; Wed, 03 Mar 2021 06:23:42 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zNF4r4Eb; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237664AbhCAVVQ (ORCPT + 99 others); Mon, 1 Mar 2021 16:21:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:51394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237733AbhCARQE (ORCPT ); Mon, 1 Mar 2021 12:16:04 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 16FDC65047; Mon, 1 Mar 2021 16:46:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614617165; bh=JM6sRrLtgZOffPWubJlXnHNdTQoKwYbojGZC5qeG1ys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zNF4r4EbrPRBn50nOK8JfXrv6bABXxgXpT+TDEECuFppdWQVbW33D08CAujyhWgji vqVCGv9I9/BCJQi+Z2oqlhRXOGDetWlS7R4s75EXxpP7BNDsTafjoE/H+wy54vpPbv ZUeXOx5QxmpNNg0pyQeuEse+L0A0R0zBhfZ+RGNk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@ger.kernel.org, James Bottomley , Jerry Snitselaar , Jarkko Sakkinen Subject: [PATCH 4.19 195/247] tpm_tis: Clean up locality release Date: Mon, 1 Mar 2021 17:13:35 +0100 Message-Id: <20210301161041.194768119@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: James Bottomley commit e42acf104d6e0bd7ccd2f09103d5be5e6d3c637c upstream. The current release locality code seems to be based on the misunderstanding that the TPM interrupts when a locality is released: it doesn't, only when the locality is acquired. Furthermore, there seems to be no point in waiting for the locality to be released. All it does is penalize the last TPM user. However, if there's no next TPM user, this is a pointless wait and if there is a next TPM user, they'll pay the penalty waiting for the new locality (or possibly not if it's the same as the old locality). Fix the code by making release_locality as simple write to release with no waiting for completion. Cc: stable@ger.kernel.org Fixes: 33bafe90824b ("tpm_tis: verify locality released before returning from release_locality") Signed-off-by: James Bottomley Reviewed-by: Jerry Snitselaar Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: Greg Kroah-Hartman --- drivers/char/tpm/tpm_tis_core.c | 47 ---------------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-) --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -139,58 +139,13 @@ static bool check_locality(struct tpm_ch return false; } -static bool locality_inactive(struct tpm_chip *chip, int l) -{ - struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); - int rc; - u8 access; - - rc = tpm_tis_read8(priv, TPM_ACCESS(l), &access); - if (rc < 0) - return false; - - if ((access & (TPM_ACCESS_VALID | TPM_ACCESS_ACTIVE_LOCALITY)) - == TPM_ACCESS_VALID) - return true; - - return false; -} - static int release_locality(struct tpm_chip *chip, int l) { struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); - unsigned long stop, timeout; - long rc; tpm_tis_write8(priv, TPM_ACCESS(l), TPM_ACCESS_ACTIVE_LOCALITY); - stop = jiffies + chip->timeout_a; - - if (chip->flags & TPM_CHIP_FLAG_IRQ) { -again: - timeout = stop - jiffies; - if ((long)timeout <= 0) - return -1; - - rc = wait_event_interruptible_timeout(priv->int_queue, - (locality_inactive(chip, l)), - timeout); - - if (rc > 0) - return 0; - - if (rc == -ERESTARTSYS && freezing(current)) { - clear_thread_flag(TIF_SIGPENDING); - goto again; - } - } else { - do { - if (locality_inactive(chip, l)) - return 0; - tpm_msleep(TPM_TIMEOUT); - } while (time_before(jiffies, stop)); - } - return -1; + return 0; } static int request_locality(struct tpm_chip *chip, int l)