ACPICA: add boundary checks in two places

Add boundary checks in acpi_ps_get_next_namestring() and
acpi_ps_peek_opcode() to prevent out-of-bounds access.

Link: https://github.com/acpica/acpica/commit/cfdc96896d8d
Signed-off-by: ikaros <void0red@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/5180044.0VBMTVartN@rafael.j.wysocki
This commit is contained in:
ikaros 2026-05-27 20:10:18 +02:00 committed by Rafael J. Wysocki
parent d27d48a528
commit bdc3575401
2 changed files with 23 additions and 1 deletions

View File

@ -148,10 +148,16 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
/* Point past any namestring prefix characters (backslash or carat) */ /* Point past any namestring prefix characters (backslash or carat) */
while (ACPI_IS_ROOT_PREFIX(*end) || ACPI_IS_PARENT_PREFIX(*end)) { while (end < parser_state->aml_end &&
(ACPI_IS_ROOT_PREFIX(*end) || ACPI_IS_PARENT_PREFIX(*end))) {
end++; end++;
} }
if (end >= parser_state->aml_end) {
parser_state->aml = parser_state->aml_end;
return_PTR(NULL);
}
/* Decode the path prefix character */ /* Decode the path prefix character */
switch (*end) { switch (*end) {
@ -176,6 +182,11 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
/* Multiple name segments, 4 chars each, count in next byte */ /* Multiple name segments, 4 chars each, count in next byte */
if ((end + 1) >= parser_state->aml_end) {
parser_state->aml = parser_state->aml_end;
return_PTR(NULL);
}
end += 2 + (*(end + 1) * ACPI_NAMESEG_SIZE); end += 2 + (*(end + 1) * ACPI_NAMESEG_SIZE);
break; break;
@ -187,6 +198,11 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
break; break;
} }
if (end > parser_state->aml_end) {
parser_state->aml = parser_state->aml_end;
return_PTR(NULL);
}
parser_state->aml = end; parser_state->aml = end;
return_PTR((char *)start); return_PTR((char *)start);
} }

View File

@ -70,6 +70,9 @@ u16 acpi_ps_peek_opcode(struct acpi_parse_state * parser_state)
u16 opcode; u16 opcode;
aml = parser_state->aml; aml = parser_state->aml;
if (aml >= parser_state->aml_end) {
return (0xFFFF);
}
opcode = (u16) ACPI_GET8(aml); opcode = (u16) ACPI_GET8(aml);
if (opcode == AML_EXTENDED_PREFIX) { if (opcode == AML_EXTENDED_PREFIX) {
@ -77,6 +80,9 @@ u16 acpi_ps_peek_opcode(struct acpi_parse_state * parser_state)
/* Extended opcode, get the second opcode byte */ /* Extended opcode, get the second opcode byte */
aml++; aml++;
if (aml >= parser_state->aml_end) {
return (0xFFFF);
}
opcode = (u16) ((opcode << 8) | ACPI_GET8(aml)); opcode = (u16) ((opcode << 8) | ACPI_GET8(aml));
} }