Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3562562pxb; Mon, 1 Mar 2021 13:26:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8v4ZRAfSwPjH7W85TemryQ8JX/S1hmcDUYN2qXnEx5x/1NjLZ0rth3t551+M0Yr0aCElw X-Received: by 2002:a17:906:3849:: with SMTP id w9mr17855630ejc.7.1614633984531; Mon, 01 Mar 2021 13:26:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614633984; cv=none; d=google.com; s=arc-20160816; b=aD5467NBJCx7EX+S4i1R7/KW02pp7/QmBWrItx44E0EptLwQ4Gc1MJAqMM7mNXUEAG P2pfMlKEX7ElE6HChadJQ9cBH0hSievOZC4SDrzeE9Er9Fyssm6es3eIiVFiyznPDlJQ 2bd2coDTsl8iupJNZ199Ea1iLJqFXqCHj9ouI5jYfwjzVAbwoRbk93nAtFECaqE7wkG0 Ovm8tVbyWnR8d3MA7eiMhW/FNlzq3zl2KUhc/5LAEq9J6yCUMZ17HTET8PRWcRCkon/L 7+xBNGiqCGVuQYqJ4HdU5oeBHHH3R5vkMcM8PPZkjHeIXs6ncMuVxADiCuQd39NbXZMY XGSQ== 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=fMQLgynkmZ6fa7EnBkY+8Wj72OTS5q9WoOP30cW3Ahw=; b=sSr4Tqe/F4iTxtWnlvDkWNGOsdBH0n067CCfMfSx+SQu2l6/btUCPmtrct3yaoo41W 0/gVzLTAk1ErzahHZ2bEJonDxY4YTj36c5l1BwNsjSDPihb3xbw6k6SODPINvYzg6OOr 1rWOks/1DsiV+qHkcFlx2b4R8RaYC0QqtJh5bM1aYJ8n1CE4uaIpV0T6yWxpS/xblv92 lUIg2bmlo/Hs/Yg2ABUDxNCa+H/GxM6G//Z3QB6aNZbDOX10p2kiwuSPQgqcub0TfA6v qWv5yuT30n89fFnKNtDd88DXXNG2/cSiRbbp6sacVHXkq0TkmiQTerCDpiQT0XcJozlZ Mc5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1isbbbaA; 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 qw16si9369539ejb.673.2021.03.01.13.26.02; Mon, 01 Mar 2021 13:26:24 -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=1isbbbaA; 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 S244664AbhCAVZB (ORCPT + 99 others); Mon, 1 Mar 2021 16:25:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:52722 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237736AbhCARQD (ORCPT ); Mon, 1 Mar 2021 12:16:03 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2D28D6503D; Mon, 1 Mar 2021 16:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614617162; bh=dSf0JxatOt3l/g0hwGEFSgyDgGEt2ThUgIk3KuhPh0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1isbbbaA+3Cjjffi/4dtEB0zBN7QljFIPqUPQT/yu5jFn+BSTfbv5yBshdIyYHeY3 dnLjbr/OpXKRORR7TbsyId3n6ExBTfGpM+legx26PTyRjas6pJ7U2HsvGDEUzbA9WU L/Bf24JRlt4hOMRbEYZOdhM00OV8u5T+1nIUCRc8= 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 194/247] tpm_tis: Fix check_locality for correct locality acquisition Date: Mon, 1 Mar 2021 17:13:34 +0100 Message-Id: <20210301161041.147719145@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 3d9ae54af1d02a7c0edc55c77d7df2b921e58a87 upstream. The TPM TIS specification says the TPM signals the acquisition of locality when the TMP_ACCESS_REQUEST_USE bit goes to one *and* the TPM_ACCESS_REQUEST_USE bit goes to zero. Currently we only check the former not the latter, so check both. Adding the check on TPM_ACCESS_REQUEST_USE should fix the case where the locality is re-requested before the TPM has released it. In this case the locality may get released briefly before it is reacquired, which causes all sorts of problems. However, with the added check, TPM_ACCESS_REQUEST_USE should remain 1 until the second request for the locality is granted. Cc: stable@ger.kernel.org Fixes: 27084efee0c3 ("[PATCH] tpm: driver for next generation TPM chips") Signed-off-by: James Bottomley Reviewed-by: Jerry Snitselaar Signed-off-by: Jarkko Sakkinen Signed-off-by: Greg Kroah-Hartman --- drivers/char/tpm/tpm_tis_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -129,7 +129,8 @@ static bool check_locality(struct tpm_ch if (rc < 0) return false; - if ((access & (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) == + if ((access & (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID + | TPM_ACCESS_REQUEST_USE)) == (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) { priv->locality = l; return true;