From: Jiale Yao <yaojiale02@163.com>
To: Marc Zyngier <maz@kernel.org>, Thomas Gleixner <tglx@kernel.org>,
Radu Rendec <radu@rendec.net>, Hanjun Guo <guohanjun@huawei.com>,
Tomasz Nowicki <tn@semihalf.com>,
Christoffer Dall <christoffer.dall@linaro.org>,
Julien Grall <julien.grall@arm.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH v2 03/20] irqchip/gic-v3: validate MADT records before use
Date: Thu, 29 Oct 2026 11:52:34 +0800 [thread overview]
Message-ID: <20261029035253.2333852-4-yaojiale02@163.com> (raw)
In-Reply-To: <20261029035253.2333852-1-yaojiale02@163.com>
The GICv3 ACPI paths cast generic MADT headers to distributor,
redistributor, and CPU interface records before confirming that the
required fields are present. Truncated records can therefore cause
out-of-bounds field reads while probing or setting up virtualization data.
Validate fixed-size distributor and redistributor records before their
first field access. Use the version-aware GICC minimum size for CPU
interface records so valid entries from older ACPI revisions remain
accepted. Validate the distributor in the version callback, which runs
before the probe callback uses the same record.
Fixes: ffa7d6166a96 ("irqchip/gic-v3: Add ACPI support for GICv3/4 initialization")
Fixes: b70fb7af6715 ("irqchip/gic-v3: ACPI: Add redistributor support via GICC structures")
Fixes: 1839e576968f ("irqchip/gic-v3: Parse and export virtual GIC information")
Cc: stable@vger.kernel.org
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/irqchip/irq-gic-v3.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index 94873646d46f..3d10818593df 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -2301,6 +2301,9 @@ gic_acpi_parse_madt_redist(union acpi_subtable_headers *header,
(struct acpi_madt_generic_redistributor *)header;
void __iomem *redist_base;
+ if (BAD_MADT_ENTRY(redist, end))
+ return -EINVAL;
+
redist_base = ioremap(redist->base_address, redist->length);
if (!redist_base) {
pr_err("Couldn't map GICR region @%llx\n", redist->base_address);
@@ -2327,6 +2330,9 @@ gic_acpi_parse_madt_gicc(union acpi_subtable_headers *header,
u32 size = reg == GIC_PIDR2_ARCH_GICv4 ? SZ_64K * 4 : SZ_64K * 2;
void __iomem *redist_base;
+ if (BAD_MADT_GICC_ENTRY(gicc, end))
+ return -EINVAL;
+
/* Neither enabled or online capable means it doesn't exist, skip it */
if (!(gicc->flags & (ACPI_MADT_ENABLED | ACPI_MADT_GICC_ONLINE_CAPABLE)))
return 0;
@@ -2404,6 +2410,9 @@ static int __init gic_acpi_match_gicc(union acpi_subtable_headers *header,
struct acpi_madt_generic_interrupt *gicc =
(struct acpi_madt_generic_interrupt *)header;
+ if (BAD_MADT_GICC_ENTRY(gicc, end))
+ return -EINVAL;
+
/*
* If GICC is enabled and has valid gicr base address, then it means
* GICR base is presented via GICC. The redistributor is only known to
@@ -2450,6 +2459,9 @@ static bool __init acpi_validate_gic_table(struct acpi_subtable_header *header,
int count;
dist = (struct acpi_madt_generic_distributor *)header;
+ if (BAD_MADT_ENTRY(dist, (unsigned long)header + header->length))
+ return false;
+
if (dist->version != ape->driver_data)
return false;
@@ -2469,6 +2481,9 @@ static int __init gic_acpi_parse_virt_madt_gicc(union acpi_subtable_headers *hea
(struct acpi_madt_generic_interrupt *)header;
static int first_madt = true;
+ if (BAD_MADT_GICC_ENTRY(gicc, end))
+ return -EINVAL;
+
if (!(gicc->flags &
(ACPI_MADT_ENABLED | ACPI_MADT_GICC_ONLINE_CAPABLE)))
return 0;
--
2.34.1
next prev parent reply other threads:[~2026-10-29 3:53 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 " 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
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 ` Jiale Yao [this message]
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=20261029035253.2333852-4-yaojiale02@163.com \
--to=yaojiale02@163.com \
--cc=christoffer.dall@linaro.org \
--cc=guohanjun@huawei.com \
--cc=julien.grall@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=radu@rendec.net \
--cc=stable@vger.kernel.org \
--cc=tglx@kernel.org \
--cc=tn@semihalf.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®