mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/x86/amd/pmf: check APTS buffer before reading header
@ 2026-11-03 11:41 Kang Chen
  2026-11-03 14:11 ` Mario Limonciello
  0 siblings, 1 reply; 2+ messages in thread
From: Kang Chen @ 2026-11-03 11:41 UTC (permalink / raw)
  To: Shyam Sundar S K
  Cc: Hans de Goede, Ilpo Järvinen, Patil Rajesh Reddy,
	platform-driver-x86, linux-kernel

apts_if_call_store_buffer() reads a u16 length from the APTS buffer
without checking that the buffer has at least two bytes.  The sibling
apmf_if_call_store_buffer() performs this check.  A Buffer(0) reply
from the APTS method makes the driver read two bytes past the ACPI
allocation.

Add the missing length check.

Fixes: 3eecb434d7f2 ("platform/x86/amd/pmf: Add support to get sps default APTS index values")
Signed-off-by: Kang Chen <k.chen@smail.nju.edu.cn>
---
 drivers/platform/x86/amd/pmf/acpi.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
index 4392bf0bc0bf..8e0d9be8c042 100644
--- a/drivers/platform/x86/amd/pmf/acpi.c
+++ b/drivers/platform/x86/amd/pmf/acpi.c
@@ -137,6 +137,12 @@ int apts_if_call_store_buffer(struct amd_pmf_dev *pdev, u32 index, void *data, s
 		goto out;
 	}
 
+	if (info->buffer.length < sizeof(u16)) {
+		dev_err(pdev->dev, "buffer too small\n");
+		err = -EINVAL;
+		goto out;
+	}
+
 	size = *(u16 *)info->buffer.pointer;
 	if (info->buffer.length < size) {
 		dev_err(pdev->dev, "buffer smaller than header size %u < %zu\n",
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] platform/x86/amd/pmf: check APTS buffer before reading header
  2026-11-03 11:41 [PATCH] platform/x86/amd/pmf: check APTS buffer before reading header Kang Chen
@ 2026-11-03 14:11 ` Mario Limonciello
  0 siblings, 0 replies; 2+ messages in thread
From: Mario Limonciello @ 2026-11-03 14:11 UTC (permalink / raw)
  To: Kang Chen, Shyam Sundar S K
  Cc: Hans de Goede, Ilpo Järvinen, Patil Rajesh Reddy,
	platform-driver-x86, linux-kernel



On 11/3/26 05:41, Kang Chen wrote:
> apts_if_call_store_buffer() reads a u16 length from the APTS buffer
> without checking that the buffer has at least two bytes.  The sibling
> apmf_if_call_store_buffer() performs this check.  A Buffer(0) reply
> from the APTS method makes the driver read two bytes past the ACPI
> allocation.
> 
> Add the missing length check.
> 
> Fixes: 3eecb434d7f2 ("platform/x86/amd/pmf: Add support to get sps default APTS index values")
> Signed-off-by: Kang Chen <k.chen@smail.nju.edu.cn>
> ---
>   drivers/platform/x86/amd/pmf/acpi.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
> index 4392bf0bc0bf..8e0d9be8c042 100644
> --- a/drivers/platform/x86/amd/pmf/acpi.c
> +++ b/drivers/platform/x86/amd/pmf/acpi.c
> @@ -137,6 +137,12 @@ int apts_if_call_store_buffer(struct amd_pmf_dev *pdev, u32 index, void *data, s
>   		goto out;
>   	}
>   
> +	if (info->buffer.length < sizeof(u16)) {
> +		dev_err(pdev->dev, "buffer too small\n");
> +		err = -EINVAL;
> +		goto out;
> +	}
> +
>   	size = *(u16 *)info->buffer.pointer;
>   	if (info->buffer.length < size) {
>   		dev_err(pdev->dev, "buffer smaller than header size %u < %zu\n",

Thanks for the patch.  But I would say there is another on the mailing 
list that does very similar and covers more:

https://lore.kernel.org/platform-driver-x86/20261005072811.1378555-1-Shyam-sundar.S-k@amd.com/

It just needs to be rebased.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-03 14:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 11:41 [PATCH] platform/x86/amd/pmf: check APTS buffer before reading header Kang Chen
2026-11-03 14:11 ` Mario Limonciello

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®