Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp521047pxb; Wed, 3 Mar 2021 08:47:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEU88p4QnlVzcJ1O1Go4Ojtozuk4E7HKJvhx2qmXI6wIqeBYyoC+uufBA8eWToaO/F5pH9 X-Received: by 2002:a17:906:aed6:: with SMTP id me22mr6722349ejb.146.1614790067555; Wed, 03 Mar 2021 08:47:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614790067; cv=none; d=google.com; s=arc-20160816; b=VXt4/rGU3yTX+s7RbjXfScNDzFK6L8e+Ti0qL/H49AE607fMQ8k8qWue0iANyfV6Rs SvREUexSNKx3pwqQVYLgTika1TSL8aAFmRRHzFzMeGkcylSHJyp0yp7zyXD6fuWjHZmK yhDjQYxyK7Es/8QTWb6T8dwSqLVjzEJObKb7hhx5ZZOCpC9hlN1HIij1yJ5JfYctOoFe nTLNvIekS9riAFs5FNlfyKCqZXs6OI/jjSCKo3hZ/Imei6frVmKzsvN5gInvwDSPxI86 YwE471G2V5swE9Z1mfztkI98dvUJShoLMbIDdLImHfksq3aL1ad/eYs1SXJbGeUClYqy kyIg== 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=ThpvA8oDZbDIK7dEDZYKOPOR4S4YqzG0TaJYQx41vEQ=; b=R2bqsYikn6HZRrzqofx73Q6Ts41Z8SMUCB02sTiHAHZQxheY5H5g9GIZm9KH/dYqvY giddbiLNE2v/+DuO/Qu5hn7iIA9V0qbzUgxcXr0ar5XLkpNiI4DZ507Cy5rrw6baqizr PpZu0zAedY4pPthoM3PhcXuphzm1UPWKKw7HcrvZ0/qK9J6GslHjGUxcwmV0IOoQ16gC FTdyVjcjFIKproK8Z3ZdZCenpypzdIMfPGA4jp9DnXlzq/sw/YdDsLHXgJ2L3iCgGe5Y PU0zcRTcWGtQC8FSzJJEDoRfaECaIEJWhvERRGSVjmCbdhQOjMYvsfCGnsgDUyfKJUrN AwGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ztJ4RiXQ; 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 g12si9300477eds.274.2021.03.03.08.46.55; Wed, 03 Mar 2021 08:47:47 -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=ztJ4RiXQ; 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 S239768AbhCBAPj (ORCPT + 99 others); Mon, 1 Mar 2021 19:15:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:40750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235849AbhCASXh (ORCPT ); Mon, 1 Mar 2021 13:23:37 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 971A765261; Mon, 1 Mar 2021 17:28:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614619722; bh=lJlcJo5vjrIG2dfiBblGpI5tolIwegM+Ah7c4SbmBTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ztJ4RiXQuLLmi1jvzY9uzkwqstvpJesOXAAcEZq5phlqDxdklufL6/dpi17AN+hoZ YhV6UtFQgszRxFKaVtiEOqmagTkBAH7fJ/SjVIJnwgylsTSHvWS9UHDzKoK9T08YGM OiVnLEBEBK/+d8Os4La3phbYHPcLEN1/lnEvSm1U= 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 5.10 527/663] tpm_tis: Clean up locality release Date: Mon, 1 Mar 2021 17:12:55 +0100 Message-Id: <20210301161207.917410944@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@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 @@ -135,58 +135,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)