linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Zheng Zengkai <zhengzengkai@huawei.com>
Cc: <lpieralisi@kernel.org>, <guohanjun@huawei.com>,
	<sudeep.holla@arm.com>, <mark.rutland@arm.com>,
	<rafael@kernel.org>, <lenb@kernel.org>,
	<daniel.lezcano@linaro.org>, <tglx@linutronix.de>,
	<linux-acpi@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ACPI: GTDT: Tighten the check for the first platform timer entry
Date: Thu, 10 Oct 2024 16:52:07 +0100	[thread overview]
Message-ID: <86ldyw5520.wl-maz@kernel.org> (raw)
In-Reply-To: <20241010144703.113728-1-zhengzengkai@huawei.com>

On Thu, 10 Oct 2024 15:47:03 +0100,
Zheng Zengkai <zhengzengkai@huawei.com> wrote:
> 
> As suggested by Marc and Lorenzo, first we need to check whether
> the platform_timer pointer is within gtdt bounds (< gtdt_end) before
> de-referencing what it points at to detect the (first) platform
> timer entry length and check that next platform_timer pointer is
> within gtdt_end too. Now we do that only in next_platform_timer()
> for subsequent platform timers.
> 
> So add check against table length (gtdt_end) for the first platform
> timer entry.
> 
> Suggested-by: Marc Zyngier <maz@kernel.org>
> Suggested-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com>
> ---
>  drivers/acpi/arm64/gtdt.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/arm64/gtdt.c b/drivers/acpi/arm64/gtdt.c
> index c0e77c1c8e09..f249af1ed1cd 100644
> --- a/drivers/acpi/arm64/gtdt.c
> +++ b/drivers/acpi/arm64/gtdt.c
> @@ -177,7 +177,8 @@ int __init acpi_gtdt_init(struct acpi_table_header *table,
>  	}
>  
>  	platform_timer = (void *)gtdt + gtdt->platform_timer_offset;
> -	if (platform_timer < (void *)table + sizeof(struct acpi_table_gtdt)) {
> +	if (platform_timer < (void *)table + sizeof(struct acpi_table_gtdt) ||
> +			platform_timer >= acpi_gtdt_desc.gtdt_end) {
>  		pr_err(FW_BUG "invalid timer data.\n");
>  		return -EINVAL;
>  	}

You  are  only  checking  the  base  pointer  for  the  platform_timer
array. This doesn't say anything about the *size* of that array (or at
least its first element), and whether that actually fits in the table.

	M.

-- 
Without deviation from the norm, progress is not possible.


  reply	other threads:[~2024-10-10 17:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-10 14:47 [PATCH] ACPI: GTDT: Tighten the check for the first platform timer entry Zheng Zengkai
2024-10-10 15:52 ` Marc Zyngier [this message]
2024-10-12  8:14   ` Zheng Zengkai

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=86ldyw5520.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=guohanjun@huawei.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=rafael@kernel.org \
    --cc=sudeep.holla@arm.com \
    --cc=tglx@linutronix.de \
    --cc=zhengzengkai@huawei.com \
    /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;
as well as URLs for NNTP newsgroup(s).