mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "jiale yao" <19888972804@163.com>
To: "Paul Walmsley" <pjw@kernel.org>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Alexandre Ghiti" <alex@ghiti.fr>,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re:[PATCH 1/2] riscv: validate RINTC entries before use
Date: Sat, 17 Oct 2026 15:25:20 +0800 (CST)	[thread overview]
Message-ID: <37a131ae.17f0.1a148c03dc7.Coremail.19888972804@163.com> (raw)
In-Reply-To: <20261016141249.2791819-2-yaojiale02@163.com>

At 2026-10-16 22:12:47, "Jiale Yao" <yaojiale02@163.com> wrote:
>The RINTC parser reads the flags field before checking that the MADT
>entry contains a complete RINTC structure. A truncated firmware record
>can therefore trigger an out-of-bounds read during early CPU discovery.
>
>Move the existing BAD_MADT_ENTRY() check ahead of the first typed field
>access.
>

Fixes: ce92546cd637 ("RISC-V: smpboot: Add ACPI support in setup_smp()")

>Signed-off-by: Jiale Yao <yaojiale02@163.com>
>---
> arch/riscv/kernel/smpboot.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
>index a9de2dae804c..9c341398058c 100644
>--- a/arch/riscv/kernel/smpboot.c
>+++ b/arch/riscv/kernel/smpboot.c
>@@ -76,6 +76,9 @@ static int __init acpi_parse_rintc(union acpi_subtable_headers *header, const un
> 	static bool found_boot_cpu;
> 	struct acpi_madt_rintc *processor = (struct acpi_madt_rintc *)header;
> 
>+	if (BAD_MADT_ENTRY(processor, end))
>+		return -EINVAL;
>+
> 	/*
> 	 * Each RINTC structure in MADT will have a flag. If ACPI_MADT_ENABLED
> 	 * bit in the flag is not enabled, it means OS should not try to enable
>@@ -84,9 +87,6 @@ static int __init acpi_parse_rintc(union acpi_subtable_headers *header, const un
> 	if (!(processor->flags & ACPI_MADT_ENABLED))
> 		return 0;
> 
>-	if (BAD_MADT_ENTRY(processor, end))
>-		return -EINVAL;
>-
> 	acpi_table_print_madt_entry(&header->common);
> 
> 	hart = processor->hart_id;
>-- 
>2.34.1

  reply	other threads:[~2026-10-17  7:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16 14:12 [PATCH 0/2] RISC-V: validate ACPI MADT " Jiale Yao
2026-10-16 14:12 ` [PATCH 1/2] riscv: validate RINTC " Jiale Yao
2026-10-17  7:25   ` jiale yao [this message]
2026-10-16 14:12 ` [PATCH 2/2] ACPI: riscv: validate interrupt controller MADT entries Jiale Yao
2026-10-17  7:27   ` jiale yao

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=37a131ae.17f0.1a148c03dc7.Coremail.19888972804@163.com \
    --to=19888972804@163.com \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@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®