From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE53BC369D3 for ; Mon, 21 Apr 2025 16:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OWDV3jdIcVbPWn74zU0noy5++76YE97G9jq8iiGLbYA=; b=ydGbrFKh7JLiw+ilCsdo/9W5YM lvIHL5YB3CX9fCGFA2K1zUKPiQHo1VvMQGEpHDPa7SpjGjBQQhxVQHA3LgNhU8XbG6esFr19+Jtl2 X0ZQpvp9Oa8TJbe8hcfRUfN6hl5+tfJmAAyj3dX6YxYvtLSuffCyTVm7yvRsAZRQ5sLEkZGA/YTIM IpNSmMqJ0PEMBngiMJvwhPnkgSYsbHFXSnZeuD5YsNrR7k4TJM5muz/0Ha+FoBoqVS2SSY7eUcai5 5A1Jet4EaLVW5YIeMqCXZdn8vT3xJh93BcpTw7xNgrH+E96CtEdLcpNoKFBZG6Nt3S7ZbGqRWRH4o kVss+XJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1u6u88-00000004hus-1pCs; Mon, 21 Apr 2025 16:36:24 +0000 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1u6u86-00000004htC-0eRQ for kexec@lists.infradead.org; Mon, 21 Apr 2025 16:36:23 +0000 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 53LCAlfr018528; Mon, 21 Apr 2025 16:36:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2023-11-20; bh=OWDV3 jdIcVbPWn74zU0noy5++76YE97G9jq8iiGLbYA=; b=dRBc96aFmu3QHpLwE6G4o 8WjWtN/QXckB+9AXVXu1VE+vZWHJGJQ9iMzvBSmYBXNfTKlN3NtEOoZTOk/LKHjS MBd4oFh8+7YIa2YfYQ71BmNof5pkrd3gqrSvoGu4G+QTkUwWf6HKZEHC1C7GarkB NTXaCFjbxcpZc+GMScZU68rSsb02ZqpM8/bMuDxwbH7tXkry5JlnFXxEAunDCdw8 E174QQ//b64R3AM9386yqHAdsj3LcXc/lwnRMCwxNTrKF2CyWoS8b5doyrC94UVY ZeV+1rj1DkxZvrjEeDeIvBiuskfuShYD5Uh53w9xiypAVP9RGntI2p0Pj42x5W1p A== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4644csttsr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 Apr 2025 16:36:01 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 53LGCe22010166; Mon, 21 Apr 2025 16:36:00 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 464298rh89-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 21 Apr 2025 16:36:00 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 53LGZxep040587; Mon, 21 Apr 2025 16:35:59 GMT Received: from bur-virt-x6-2-100.us.oracle.com (bur-virt-x6-2-100.us.oracle.com [10.153.92.40]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 464298rh54-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 21 Apr 2025 16:35:59 +0000 From: Ross Philipson To: linux-kernel@vger.kernel.org, x86@kernel.org, linux-integrity@vger.kernel.org, linux-doc@vger.kernel.org, linux-crypto@vger.kernel.org, kexec@lists.infradead.org, linux-efi@vger.kernel.org, iommu@lists.linux.dev Cc: ross.philipson@oracle.com, dpsmith@apertussolutions.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, dave.hansen@linux.intel.com, ardb@kernel.org, mjg59@srcf.ucam.org, James.Bottomley@hansenpartnership.com, peterhuewe@gmx.de, jarkko@kernel.org, jgg@ziepe.ca, luto@amacapital.net, nivedita@alum.mit.edu, herbert@gondor.apana.org.au, davem@davemloft.net, corbet@lwn.net, ebiederm@xmission.com, dwmw2@infradead.org, baolu.lu@linux.intel.com, kanth.ghatraju@oracle.com, andrew.cooper3@citrix.com, trenchboot-devel@googlegroups.com Subject: [PATCH v14 15/19] tpm, tpm_tis: Address positive localities in tpm_tis_request_locality() Date: Mon, 21 Apr 2025 09:27:08 -0700 Message-Id: <20250421162712.77452-16-ross.philipson@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20250421162712.77452-1-ross.philipson@oracle.com> References: <20250421162712.77452-1-ross.philipson@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-21_08,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 phishscore=0 mlxscore=0 malwarescore=0 suspectscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504210129 X-Proofpoint-ORIG-GUID: l2E6E8iM4talK2swjjCR6peIZumiHSiQ X-Proofpoint-GUID: l2E6E8iM4talK2swjjCR6peIZumiHSiQ X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250421_093622_191159_70E06FB7 X-CRM114-Status: GOOD ( 12.96 ) X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kexec" Errors-To: kexec-bounces+kexec=archiver.kernel.org@lists.infradead.org From: "Daniel P. Smith" Validate that the input locality is within the correct range, as specified by TCG standards, and increase the locality count also for the positive localities. Signed-off-by: Daniel P. Smith Signed-off-by: Ross Philipson Signed-off-by: Jarkko Sakkinen --- 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 d73b9ef3fd15..222081e5c7f7 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -233,10 +233,16 @@ static int tpm_tis_request_locality(struct tpm_chip *chip, int l) struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); int ret = 0; + if (l < 0 || l > TPM_MAX_LOCALITY) { + dev_warn(&chip->dev, "%s: failed to request unknown locality: %d\n", + __func__, l); + return -EINVAL; + } + mutex_lock(&priv->locality_count_mutex); if (priv->locality_count == 0) ret = __tpm_tis_request_locality(chip, l); - if (!ret) + if (ret >= 0) priv->locality_count++; mutex_unlock(&priv->locality_count_mutex); return ret; -- 2.39.3