U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Holmes-Mitra <dholmesm@google.com>
To: u-boot@lists.u-boot-project.org
Cc: Tom Rini <trini@konsulko.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	 Ilias Apalodimas <ilias.apalodimas@linaro.org>
Subject: [PATCH 2/4] qfw/acpi: Guard ACPI 1.0 RSDP bounds and NULL lookup
Date: Thu, 03 Dec 2026 02:21:10 GMT	[thread overview]
Message-ID: <20261203022028.04-02-dholmesm@google.com> (raw)
In-Reply-To: <20261203022028.04-00-dholmesm@google.com>

QEMU x86 i440fx provides a 20-byte ACPI 1.0 RSDP (revision 0) in
etc/acpi/rsdp. Unconditionally writing rsdp->length (offset 20) and
rsdp->ext_checksum (offset 32) overflowed 16 bytes past the end of the
allocation into adjacent table memory.

Only update the ACPI 2.0 extended fields when rsdp->revision >=
ACPI_RSDP_REV_ACPI_2_0, recompute the 20-byte base checksum, and guard
against a NULL file pointer in acpi_get_rsdp_addr() when etc/acpi/rsdp
is absent.

Signed-off-by: Dan Holmes-Mitra <dholmesm@google.com>
---
 drivers/misc/qfw_acpi.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/qfw_acpi.c b/drivers/misc/qfw_acpi.c
index 7cb81eb222..580bef4adb 100644
--- a/drivers/misc/qfw_acpi.c
+++ b/drivers/misc/qfw_acpi.c
@@ -272,9 +272,14 @@ out:
 	}
 	struct acpi_rsdp *rsdp = ctx->rsdp;
 
-	rsdp->length = sizeof(*rsdp);
-	rsdp->ext_checksum = 0;
-	rsdp->ext_checksum = table_compute_checksum((u8 *)rsdp, sizeof(*rsdp));
+	rsdp->checksum = 0;
+	rsdp->checksum = table_compute_checksum((u8 *)rsdp, 20);
+	if (rsdp->revision >= ACPI_RSDP_REV_ACPI_2_0) {
+		rsdp->length = sizeof(*rsdp);
+		rsdp->ext_checksum = 0;
+		rsdp->ext_checksum = table_compute_checksum((u8 *)rsdp,
+							    sizeof(*rsdp));
+	}
 
 	gd_set_acpi_start(acpi_get_rsdp_addr());
 
@@ -294,7 +299,7 @@ ulong acpi_get_rsdp_addr(void)
 	}
 
 	file = qfw_find_file(dev, "etc/acpi/rsdp");
-	return file->addr;
+	return file ? file->addr : 0;
 }
 
 void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt,
-- 
2.56.1.911.g883d8bcb20-goog


  parent reply	other threads:[~2026-12-03  5:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  2:21 [PATCH 0/4] qfw/acpi & efi_loader: Fix linker cleanup, RSDP bounds, and absent/offset ACPI handling Dan Holmes-Mitra
2026-12-03  2:21 ` [PATCH 1/4] qfw/acpi: Do not free non-heap addresses on linker error Dan Holmes-Mitra
2026-12-03  2:21 ` Dan Holmes-Mitra [this message]
2026-12-03  2:21 ` [PATCH 3/4] qfw/acpi: Skip absent ACPI bloblist and size from table-loader Dan Holmes-Mitra
2026-12-03  2:21 ` [PATCH 4/4] efi_loader: Handle offset or absent runtime ACPI tables Dan Holmes-Mitra

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=20261203022028.04-02-dholmesm@google.com \
    --to=dholmesm@google.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    --cc=xypron.glpk@gmx.de \
    /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