Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C3883515CB; Sat, 12 Sep 2026 11:29:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789212569; cv=none; b=aOW+2iGQlcCtiCG6p4t6A1gJo5l86lzETUlTQMgo82zN6ihhrMr+q2Jc3PeiVLR+447LxYtIXE14JmeYo/hBieMPd6bG1mioQ8KutPeIB7oKeHO9ha09mH/Yx++chm4ch6Rnu1xFhk6Uhv3uY1WDq7MquOWHdMAf41GN124yPCQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789212569; c=relaxed/simple; bh=JCtNS4qmMbKK6CRk7tCLwFCSI/V2bsxiUi1ec5Lp5/c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uhLVR59utgg12fvtUGVjKx81e0yD+pOBnxHz4VqppFARehkuNDvCmfq3P3qqQQgT3/bEiF8Izd10zTHbCUPPMRPJfA/2UOH8b+6c6pOLAv0DPR66UmLri846aeQ64eUp2pxOVVKjVAIDtRCLQkpN651OpYd1yYMpz0ff4gVzBAc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=dJgJWapk; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="dJgJWapk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F0891F000FF; Sat, 12 Sep 2026 11:29:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789212567; bh=O4NNa41KQ7b8n3Pho+CdfvANc0KHwaKH5Do6DDdCSUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dJgJWapkicXj018N4KUGIF6Vk6jumgOAXNd/C5pcvxi8jo4crxV2HHMtGeZPqj20Z xSUs98uC5AW3yYqATZdVUjoThBXqNgC10lAvuKQLxjDbxzS99itBnSZBy6d3U6CMaf 1QED/Ptli9LFJ7ssFmurkS1mHjML1tDsfXntNAqc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ruoyu Wang , Jarkko Sakkinen , Sasha Levin Subject: [PATCH 6.18 1426/1518] tpm: st33zp24: Validate locality read result Date: Sat, 12 Sep 2026 08:59:55 +0200 Message-ID: <20260912065655.809657729@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065623.398859879@linuxfoundation.org> References: <20260912065623.398859879@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ruoyu Wang [ Upstream commit 264216889d39df509b9c8045df53529480b0b718 ] check_locality() treats every nonzero transport return as success. SPI errors remain negative, while the I2C path can convert a negative write error through its byte-sized status variable. Either result is nonzero even though the TPM_ACCESS byte can remain unwritten, so indeterminate ACTIVE_LOCALITY and VALID bits can falsely report an active locality. Require recv() to return exactly the requested byte before examining TPM_ACCESS. Transport errors and short reads now report an inactive locality, while successful reads retain the existing behavior. This issue was found by a static analysis checker and confirmed by manual source review. Fixes: 251a7b08213a ("TPM: STMicroelectronics ST33 I2C KERNEL 3.x") Signed-off-by: Ruoyu Wang Link: https://lore.kernel.org/r/20260813153032.3951878-2-ruoyuw560@gmail.com Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: Sasha Levin --- drivers/char/tpm/st33zp24/st33zp24.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/char/tpm/st33zp24/st33zp24.c b/drivers/char/tpm/st33zp24/st33zp24.c index 898e8d01d2669..0e2deff94c367 100644 --- a/drivers/char/tpm/st33zp24/st33zp24.c +++ b/drivers/char/tpm/st33zp24/st33zp24.c @@ -106,10 +106,10 @@ static bool check_locality(struct tpm_chip *chip) { struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev); u8 data; - u8 status; + int status; status = tpm_dev->ops->recv(tpm_dev->phy_id, TPM_ACCESS, &data, 1); - if (status && (data & + if (status == 1 && (data & (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) == (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) return true; -- 2.53.0