mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Saket Dumbre <saket.dumbre@intel.com>,
	Pawel Chmielewski <pawel.chmielewski@intel.com>
Subject: [PATCH v1 14/27] ACPICA: add boundary checks in acpi_ps_get_next_field()
Date: Wed, 27 May 2026 20:00:39 +0200	[thread overview]
Message-ID: <24388159.6Emhk5qWAg@rafael.j.wysocki> (raw)
In-Reply-To: <5998844.DvuYhMxLoT@rafael.j.wysocki>

From: ikaros <void0red@gmail.com>

Add boundary checks in acpi_ps_get_next_field() to prevent out-of-bounds
access.

Link: https://github.com/acpica/acpica/commit/c39183ea84bc
Signed-off-by: ikaros <void0red@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/acpica/psargs.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c
index 87d32fbba0a6..3526ea109414 100644
--- a/drivers/acpi/acpica/psargs.c
+++ b/drivers/acpi/acpica/psargs.c
@@ -491,6 +491,10 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
 	ASL_CV_CAPTURE_COMMENTS_ONLY(parser_state);
 	aml = parser_state->aml;
 
+	if (aml >= parser_state->aml_end) {
+		return_PTR(NULL);
+	}
+
 	/* Determine field type */
 
 	switch (ACPI_GET8(parser_state->aml)) {
@@ -539,6 +543,11 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
 
 		/* Get the 4-character name */
 
+		if ((parser_state->aml + ACPI_NAMESEG_SIZE) >
+		    parser_state->aml_end) {
+			acpi_ps_free_op(field);
+			return_PTR(NULL);
+		}
 		ACPI_MOVE_32_TO_32(&name, parser_state->aml);
 		acpi_ps_set_name(field, name);
 		parser_state->aml += ACPI_NAMESEG_SIZE;
@@ -584,6 +593,10 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
 
 		/* Get the two bytes (Type/Attribute) */
 
+		if ((parser_state->aml + 2) > parser_state->aml_end) {
+			acpi_ps_free_op(field);
+			return_PTR(NULL);
+		}
 		access_type = ACPI_GET8(parser_state->aml);
 		parser_state->aml++;
 		access_attribute = ACPI_GET8(parser_state->aml);
@@ -595,6 +608,10 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
 		/* This opcode has a third byte, access_length */
 
 		if (opcode == AML_INT_EXTACCESSFIELD_OP) {
+			if (parser_state->aml >= parser_state->aml_end) {
+				acpi_ps_free_op(field);
+				return_PTR(NULL);
+			}
 			access_length = ACPI_GET8(parser_state->aml);
 			parser_state->aml++;
 
-- 
2.51.0





  parent reply	other threads:[~2026-05-27 18:12 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-27 17:50 [PATCH v1 00/27] ACPI: ACPICA 20260408 Rafael J. Wysocki
2026-05-27 17:51 ` [PATCH v1 01/27] ACPICA: actypes: Distinguish between D3hot/cold Rafael J. Wysocki
2026-05-27 17:52 ` [PATCH v1 02/27] ACPICA: actbl2.h: ACPI 6.6: Updates for MADT MPWakeup Rafael J. Wysocki
2026-05-27 17:53 ` [PATCH v1 03/27] ACPICA: Fix condition check in acpi_ps_parse_loop() Rafael J. Wysocki
2026-05-27 17:53 ` [PATCH v1 04/27] ACPICA: Add alias node support in namespace handling Rafael J. Wysocki
2026-05-27 17:54 ` [PATCH v1 05/27] ACPICA: Add modern standby DSM GUIDs Rafael J. Wysocki
2026-05-27 17:55 ` [PATCH v1 06/27] ACPICA: Fix FADT 32/64X length mismatch warning Rafael J. Wysocki
2026-05-27 17:55 ` [PATCH v1 07/27] ACPICA: Add LVR to acrestyp.h Rafael J. Wysocki
2026-05-27 17:56 ` [PATCH v1 08/27] ACPICA: Fetch LVR I2C resource descriptor Rafael J. Wysocki
2026-05-27 17:57 ` [PATCH v1 09/27] ACPICA: Change LVR to 8 bit value Rafael J. Wysocki
2026-05-27 17:57 ` [PATCH v1 10/27] ACPICA: Mention the LVR bits Rafael J. Wysocki
2026-05-27 17:58 ` [PATCH v1 11/27] ACPICA: fix I2C LVR item count in the conversion table Rafael J. Wysocki
2026-05-27 17:59 ` [PATCH v1 12/27] ACPICA: Fix use-after-free in acpi_ds_terminate_control_method() Rafael J. Wysocki
2026-05-27 17:59 ` [PATCH v1 13/27] ACPICA: validate byte_count in acpi_ps_get_next_package_length() Rafael J. Wysocki
2026-05-27 18:00 ` Rafael J. Wysocki [this message]
2026-05-27 18:01 ` [PATCH v1 15/27] ACPICA: Prevent adding invalid references Rafael J. Wysocki
2026-05-27 18:02 ` [PATCH v1 16/27] ACPICA: Fix integer overflow in acpi_ex_opcode_3A_1T_1R() (mid_op) Rafael J. Wysocki
2026-05-27 18:02 ` [PATCH v1 17/27] ACPICA: Improve argument parsing in acpi_ps_get_next_simple_arg() Rafael J. Wysocki
2026-05-27 18:03 ` [PATCH v1 18/27] ACPICA: validate handler object type in two places Rafael J. Wysocki
2026-05-27 18:04 ` [PATCH v1 19/27] ACPICA: Add validation for node in acpi_ns_build_normalized_path() Rafael J. Wysocki
2026-05-27 18:04 ` [PATCH v1 20/27] ACPICA: Enhance buffer validation in acpi_ut_walk_aml_resources() Rafael J. Wysocki
2026-05-27 18:05 ` [PATCH v1 21/27] ACPICA: Fix NULL pointer dereference in acpi_ns_custom_package() Rafael J. Wysocki
2026-05-27 18:06 ` [PATCH v1 22/27] ACPICA: Enhance OEM ID and Table ID validation in acpi_ex_load_table_op() Rafael J. Wysocki
2026-05-27 18:07 ` [PATCH v1 23/27] ACPICA: Remove spurious precision from format used to dump parse trees Rafael J. Wysocki
2026-05-27 18:08 ` [PATCH v1 24/27] ACPICA: Update the copyright year to 2026 Rafael J. Wysocki
2026-05-27 18:08 ` [PATCH v1 25/27] ACPICA: Update version to 20260408 Rafael J. Wysocki
2026-05-27 18:09 ` [PATCH v1 26/27] ACPICA: Add package limit checks in parser functions Rafael J. Wysocki
2026-05-27 18:10 ` [PATCH v1 27/27] ACPICA: add boundary checks in two places Rafael J. Wysocki

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=24388159.6Emhk5qWAg@rafael.j.wysocki \
    --to=rafael@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pawel.chmielewski@intel.com \
    --cc=saket.dumbre@intel.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®