mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: Kang Chen <k.chen@smail.nju.edu.cn>,
	Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Cc: "Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Patil Rajesh Reddy" <Patil.Reddy@amd.com>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86/amd/pmf: check APTS buffer before reading header
Date: Tue, 3 Nov 2026 08:11:08 -0600	[thread overview]
Message-ID: <50b30fee-cd3b-427c-9c8b-4230f4208d50@amd.com> (raw)
In-Reply-To: <20261103114134.75395-1-k.chen@smail.nju.edu.cn>



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.

      reply	other threads:[~2026-11-03 14:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 11:41 Kang Chen
2026-11-03 14:11 ` Mario Limonciello [this message]

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=50b30fee-cd3b-427c-9c8b-4230f4208d50@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=Patil.Reddy@amd.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=k.chen@smail.nju.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@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®