mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "jiale yao" <19888972804@163.com>
To: "Jassi Brar" <jassisinghbrar@gmail.com>
Cc: "Sudeep Holla" <sudeep.holla@kernel.org>,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re:Re:Re: [PATCH] mailbox: pcc: validate PCCT subspaces before parsing
Date: Fri, 23 Oct 2026 17:40:23 +0800 (CST)	[thread overview]
Message-ID: <324e6ae9.8754.1a1682208ff.Coremail.19888972804@163.com> (raw)
In-Reply-To: <35886acd.272d.1a1617ceb00.Coremail.19888972804@163.com>

At 2026-10-22 10:42:19, "jiale yao" <19888972804@163.com> wrote:
>Hi Jassi,
>At 2026-10-22 10:26:27, "Jassi Brar" <jassisinghbrar@gmail.com> wrote:
>>On Fri, Oct 16, 2026 at 9:15 AM Jiale Yao <yaojiale02@163.com> wrote:
>>>
>>> The PCC mailbox probe walks PCCT entries by their declared lengths
>>> without checking that each entry is contained in the table. It also
>>> passes generic headers to type-specific parsers without establishing the
>>> required record size. Malformed firmware can therefore move the cursor
>>> outside the PCCT or cause out-of-bounds field reads.
>>>
>>> Validate the table header, each subspace range, and the minimum size for
>>> supported subspace types during both the counting and probe passes.
>>>
>>> Signed-off-by: Jiale Yao <yaojiale02@163.com>
>>> ---
>>>  drivers/mailbox/pcc.c | 53 ++++++++++++++++++++++++++++++++++++++++++-
>>>  1 file changed, 52 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
>>> index 9888dab64639..37b2ddb44bda 100644
>>> --- a/drivers/mailbox/pcc.c
>>> +++ b/drivers/mailbox/pcc.c
>>> @@ -553,6 +553,42 @@ static const struct mbox_chan_ops pcc_chan_ops = {
>>>         .last_tx_done = pcc_last_tx_done,
>>>  };
>>>
>>> +static bool pcc_subspace_is_valid(struct acpi_subtable_header *entry,
>>> +                                 unsigned long end)
>>> +{
>>> +       unsigned long start = (unsigned long)entry;
>>> +       size_t length, min_length;
>>> +
>>> +       if (start >= end || end - start < sizeof(*entry))
>>> +               return false;
>>
>>(end - start < sizeof(*entry)) is implied by the two length  checks
>>below, so only "start >= end" is needed here.
>>
>>> +       length = entry->length;
>>> +       if (length < sizeof(*entry) || length > end - start)
>>> +               return false;
>>> +
>>> +       switch (entry->type) {
>>> +       case ACPI_PCCT_TYPE_GENERIC_SUBSPACE:
>>> +               min_length = sizeof(struct acpi_pcct_subspace);
>>> +               break;
>>> +       case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE:
>>> +               min_length = sizeof(struct acpi_pcct_hw_reduced);
>>> +               break;
>>> +       case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2:
>>> +               min_length = sizeof(struct acpi_pcct_hw_reduced_type2);
>>> +               break;
>>> +       case ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE:
>>> +               min_length = sizeof(struct acpi_pcct_ext_pcc_master);
>>> +               break;
>>> +       case ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE:
>>> +               min_length = sizeof(struct acpi_pcct_ext_pcc_slave);
>>> +               break;
>>> +       default:
>>> +               return false;
>>> +       }
>>> +
>>> +       return length >= min_length;
>>
>>How about something like
>>
>>static const u16 pcc_subspace_min_len[ACPI_PCCT_TYPE_RESERVED] = {
>>    [ACPI_PCCT_TYPE_GENERIC_SUBSPACE] =
>>    sizeof(struct acpi_pcct_subspace),
>>    [ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE] =
>>    sizeof(struct acpi_pcct_hw_reduced),
>>    [ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2] =
>>    sizeof(struct acpi_pcct_hw_reduced_type2),
>>    [ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE] =
>>    sizeof(struct acpi_pcct_ext_pcc_master),
>>    [ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE] =
>>    sizeof(struct acpi_pcct_ext_pcc_slave),
>>};
>
>Sounds great, I will submit v2.

v2 is in, https://lore.kernel.org/all/20261023093839.715037-1-yaojiale02@163.com/

>
>Thanks for your review.
>
>>
>>return entry->length >= pcc_subspace_min_len[entry->type];
>>
>>Cheers
>>Jassi

      reply	other threads:[~2026-10-23  9:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16 14:15 Jiale Yao
2026-10-17  7:35 ` jiale yao
2026-10-22  2:26 ` [PATCH] " Jassi Brar
2026-10-22  2:42   ` jiale yao
2026-10-23  9:40     ` jiale yao [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=324e6ae9.8754.1a1682208ff.Coremail.19888972804@163.com \
    --to=19888972804@163.com \
    --cc=jassisinghbrar@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sudeep.holla@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®