From: Wei Huang <wei.huang2@amd.com>
To: <bhelgaas@google.com>
Cc: <linux-pci@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<andrew.gospodarek@broadcom.com>, <ajit.khaparde@broadcom.com>,
<fengchengwen@huawei.com>
Subject: [PATCH 1/1] PCI/TPH: Validate the firmware Steering Tag response
Date: Thu, 24 Sep 2026 14:05:43 -0500 [thread overview]
Message-ID: <20260924190543.3424792-1-wei.huang2@amd.com> (raw)
TPH _DSM returns an eight-byte Steering Tag information buffer.
Checking only the ACPI object type allows a short firmware response
to be read beyond the end of its buffer.
For safety, require a non-NULL buffer containing the complete value
before copying it. Use memcpy() so that reading the response does not
depend on the alignment of the firmware buffer.
Fixes: d2e8a34876ce ("PCI/TPH: Add Steering Tag support")
Signed-off-by: Wei Huang <wei.huang2@amd.com>
---
drivers/pci/tph.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
index 655ffd60e62f..4d064b86befc 100644
--- a/drivers/pci/tph.c
+++ b/drivers/pci/tph.c
@@ -119,12 +119,14 @@ static acpi_status tph_invoke_dsm(acpi_handle handle, u32 cpu_uid,
if (!out_obj)
return AE_ERROR;
- if (out_obj->type != ACPI_TYPE_BUFFER) {
+ if (out_obj->type != ACPI_TYPE_BUFFER ||
+ out_obj->buffer.length < sizeof(st_out->value) ||
+ !out_obj->buffer.pointer) {
ACPI_FREE(out_obj);
return AE_ERROR;
}
- st_out->value = *((u64 *)(out_obj->buffer.pointer));
+ memcpy(&st_out->value, out_obj->buffer.pointer, sizeof(st_out->value));
ACPI_FREE(out_obj);
--
2.55.0
next reply other threads:[~2026-09-24 19:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 19:05 Wei Huang [this message]
2026-09-24 19:45 ` Bjorn Helgaas
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=20260924190543.3424792-1-wei.huang2@amd.com \
--to=wei.huang2@amd.com \
--cc=ajit.khaparde@broadcom.com \
--cc=andrew.gospodarek@broadcom.com \
--cc=bhelgaas@google.com \
--cc=fengchengwen@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@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®