From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Purva Yeshi <purvayeshi550@gmail.com>,
Stefano Garzarella <sgarzare@redhat.com>,
Jarkko Sakkinen <jarkko@kernel.org>,
Sasha Levin <sashal@kernel.org>,
peterhuewe@gmx.de, jarkko.sakkinen@linux.intel.com,
gregkh@linuxfoundation.org, linux-integrity@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH AUTOSEL 6.12 16/18] char: tpm: tpm-buf: Add sanity check fallback in read helpers
Date: Mon, 19 May 2025 17:22:05 -0400 [thread overview]
Message-ID: <20250519212208.1986028-16-sashal@kernel.org> (raw)
In-Reply-To: <20250519212208.1986028-1-sashal@kernel.org>
From: Purva Yeshi <purvayeshi550@gmail.com>
[ Upstream commit 32d495b384a2db7d23c2295e03e6b6edb1c0db8d ]
Fix Smatch-detected issue:
drivers/char/tpm/tpm-buf.c:208 tpm_buf_read_u8() error:
uninitialized symbol 'value'.
drivers/char/tpm/tpm-buf.c:225 tpm_buf_read_u16() error:
uninitialized symbol 'value'.
drivers/char/tpm/tpm-buf.c:242 tpm_buf_read_u32() error:
uninitialized symbol 'value'.
Zero-initialize the return values in tpm_buf_read_u8(), tpm_buf_read_u16(),
and tpm_buf_read_u32() to guard against uninitialized data in case of a
boundary overflow.
Add defensive initialization ensures the return values are always defined,
preventing undefined behavior if the unexpected happens.
Signed-off-by: Purva Yeshi <purvayeshi550@gmail.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/char/tpm/tpm-buf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/char/tpm/tpm-buf.c b/drivers/char/tpm/tpm-buf.c
index e49a19fea3bdf..dc882fc9fa9ef 100644
--- a/drivers/char/tpm/tpm-buf.c
+++ b/drivers/char/tpm/tpm-buf.c
@@ -201,7 +201,7 @@ static void tpm_buf_read(struct tpm_buf *buf, off_t *offset, size_t count, void
*/
u8 tpm_buf_read_u8(struct tpm_buf *buf, off_t *offset)
{
- u8 value;
+ u8 value = 0;
tpm_buf_read(buf, offset, sizeof(value), &value);
@@ -218,7 +218,7 @@ EXPORT_SYMBOL_GPL(tpm_buf_read_u8);
*/
u16 tpm_buf_read_u16(struct tpm_buf *buf, off_t *offset)
{
- u16 value;
+ u16 value = 0;
tpm_buf_read(buf, offset, sizeof(value), &value);
@@ -235,7 +235,7 @@ EXPORT_SYMBOL_GPL(tpm_buf_read_u16);
*/
u32 tpm_buf_read_u32(struct tpm_buf *buf, off_t *offset)
{
- u32 value;
+ u32 value = 0;
tpm_buf_read(buf, offset, sizeof(value), &value);
--
2.39.5
next prev parent reply other threads:[~2025-05-19 21:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-19 21:21 [PATCH AUTOSEL 6.12 01/18] dmaengine: idxd: cdev: Fix uninitialized use of sva in idxd_cdev_open Sasha Levin
2025-05-19 21:21 ` [PATCH AUTOSEL 6.12 02/18] HID: quirks: Add ADATA XPG alpha wireless mouse support Sasha Levin
2025-05-19 21:21 ` [PATCH AUTOSEL 6.12 03/18] nfs: don't share pNFS DS connections between net namespaces Sasha Levin
2025-05-19 21:21 ` [PATCH AUTOSEL 6.12 04/18] platform/x86: thinkpad_acpi: Support also NEC Lavie X1475JAS Sasha Levin
2025-05-19 21:21 ` [PATCH AUTOSEL 6.12 05/18] um: let 'make clean' properly clean underlying SUBARCH as well Sasha Levin
2025-05-19 21:21 ` [PATCH AUTOSEL 6.12 06/18] gpio: virtuser: fix potential out-of-bound write Sasha Levin
2025-05-19 21:21 ` [PATCH AUTOSEL 6.12 07/18] drm/amd/display: fix link_set_dpms_off multi-display MST corner case Sasha Levin
2025-05-19 21:21 ` [PATCH AUTOSEL 6.12 08/18] drm/amd/display: check stream id dml21 wrapper to get plane_id Sasha Levin
2025-05-19 21:21 ` [PATCH AUTOSEL 6.12 09/18] phy: starfive: jh7110-usb: Fix USB 2.0 host occasional detection failure Sasha Levin
2025-05-19 21:21 ` [PATCH AUTOSEL 6.12 10/18] phy: phy-rockchip-samsung-hdptx: Fix PHY PLL output 50.25MHz error Sasha Levin
2025-05-19 21:22 ` [PATCH AUTOSEL 6.12 11/18] spi: spi-sun4i: fix early activation Sasha Levin
2025-05-19 21:22 ` [PATCH AUTOSEL 6.12 12/18] phy: renesas: rcar-gen3-usb2: Move IRQ request in probe Sasha Levin
2025-05-19 21:22 ` [PATCH AUTOSEL 6.12 13/18] nvme-pci: add NVME_QUIRK_NO_DEEPEST_PS quirk for SOLIDIGM P44 Pro Sasha Levin
2025-05-19 21:22 ` [PATCH AUTOSEL 6.12 14/18] drm/xe/xe2hpg: Add Wa_22021007897 Sasha Levin
2025-05-19 21:22 ` [PATCH AUTOSEL 6.12 15/18] drm/xe: Save the gt pointer in lrc and drop the tile Sasha Levin
2025-05-19 21:22 ` Sasha Levin [this message]
2025-05-19 21:22 ` [PATCH AUTOSEL 6.12 17/18] tpm: tis: Double the timeout B to 4s Sasha Levin
2025-05-19 21:22 ` [PATCH AUTOSEL 6.12 18/18] NFS: Avoid flushing data while holding directory locks in nfs_rename() Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250519212208.1986028-16-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jarkko.sakkinen@linux.intel.com \
--cc=jarkko@kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=peterhuewe@gmx.de \
--cc=purvayeshi550@gmail.com \
--cc=sgarzare@redhat.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®