mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lorenzo Pieralisi <lpieralisi@kernel.org>
To: Jiale Yao <yaojiale02@163.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>, Thomas Gleixner <tglx@kernel.org>,
	Marc Zyngier <Marc.Zyngier@arm.com>,
	Hanjun Guo <guohanjun@huawei.com>,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v2 01/20] ACPI: irqchip: validate MADT entry bounds before probing
Date: Tue, 3 Nov 2026 15:44:20 +0100	[thread overview]
Message-ID: <aunzRO9rxFUlC0Ym@red-moon> (raw)
In-Reply-To: <20261029035253.2333852-2-yaojiale02@163.com>

On Thu, Oct 29, 2026 at 11:52:32AM +0800, Jiale Yao wrote:
> IRQ chip probing invokes validation and probe callbacks after the common
> table walker has only established that a generic subtable header is
> readable. A malformed length can leave callback field accesses outside
> the MADT.
> 
> Validate the generic header length and ensure the complete declared
> entry is contained in the table before invoking IRQ chip callbacks.
> 
> Fixes: e647b532275b ("ACPI: Add early device probing infrastructure")
> Cc: stable@vger.kernel.org

I don't think this patch fixes anything (actually you don't know, it
might break kernels that are currently booting).

Remove the stable tag (on the whole series, though others might have a
different opinion). If this gets merged, goes to stable and then
we discover it triggers a regression (on existing platforms whose
ACPI tables are broken but the system is working) it would be very
annoying.

> Signed-off-by: Jiale Yao <yaojiale02@163.com>
> ---
>  drivers/acpi/scan.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
> index 0b17a7e51956..10e8d736f44b 100644
> --- a/drivers/acpi/scan.c
> +++ b/drivers/acpi/scan.c
> @@ -2896,6 +2896,13 @@ static DEFINE_MUTEX(acpi_probe_mutex);
>  static int __init acpi_match_madt(union acpi_subtable_headers *header,
>  				  const unsigned long end)
>  {
> +	unsigned long start = (unsigned long)header;
> +
> +	if (start >= end || end - start < sizeof(header->common) ||
> +	    header->common.length < sizeof(header->common) ||
> +	    header->common.length > end - start)
> +		return -EINVAL;

This is a check that AFAICS could be done in acpi_parse_entries_array() once
for all (where you also know header->common is what you need checking, btw). 

Actually, what's missing there to avoid peppering the kernel with
BAD_MADT_ENTRY checks is the entry size (that we could add with a LUT).

The downsize is that by centralizing it, if anything breaks (which is
possible) we have to revert it and therefore remove the check for all
consumers.

I don't know. Rafael, all, thoughts on this ?

Thanks,
Lorenzo

> +
>  	if (!ape->subtable_valid || ape->subtable_valid(&header->common, ape))
>  		if (!ape->probe_subtbl(header, end))
>  			acpi_probe_count++;
> -- 
> 2.34.1
> 

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

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29  3:52 [PATCH v2 00/20] ACPI/irqchip: validate MADT entries before use Jiale Yao
2026-10-29  3:52 ` [PATCH v2 01/20] ACPI: irqchip: validate MADT entry bounds before probing Jiale Yao
2026-11-03 14:44   ` Lorenzo Pieralisi [this message]
2026-11-03 16:56     ` Rafael J. Wysocki (Intel)
2026-10-29  3:52 ` [PATCH v2 02/20] irqchip/gic-v3-its: validate MADT ITS entries Jiale Yao
2026-10-29  3:52 ` [PATCH v2 03/20] irqchip/gic-v3: validate MADT records before use Jiale Yao
2026-10-29  3:52 ` [PATCH v2 04/20] irqchip/gic-v5-its: validate MADT translate frames Jiale Yao
2026-10-29  3:52 ` [PATCH v2 05/20] irqchip/loongarch-cpu: validate MADT LIO-PIC entries Jiale Yao
2026-10-29  3:52 ` [PATCH v2 06/20] irqchip/loongson-eiointc: validate MADT BIO-PIC entries Jiale Yao
2026-10-29  3:52 ` [PATCH v2 07/20] riscv: validate RINTC entries before use Jiale Yao
2026-10-29  3:52 ` [PATCH v2 08/20] ACPI: riscv: validate interrupt controller MADT entries Jiale Yao
2026-10-29  3:52 ` [PATCH v2 09/20] riscv: acpi: validate RINTC entries before use Jiale Yao
2026-10-29  3:52 ` [PATCH v2 10/20] irqchip/gic-v5-irs: validate MADT GICC entries Jiale Yao
2026-11-02 14:23 ` [PATCH v2 00/20] ACPI/irqchip: validate MADT entries before use Huacai Chen

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=aunzRO9rxFUlC0Ym@red-moon \
    --to=lpieralisi@kernel.org \
    --cc=Marc.Zyngier@arm.com \
    --cc=guohanjun@huawei.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@kernel.org \
    --cc=yaojiale02@163.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

all inboxes | Powered by JetHome®