ACPICA: Initialize parser_state.aml_end in acpi_install_method()
Subsystems (2)
PATCH 1/1 ACPICA: Initialize parser_state.aml_end in acpi_install_method()
In acpi_install_method(), the local parser_state is stack-allocated and only parser_state.aml was initialized. Parser helpers called by this path read parser_state.aml_end for bounds checking: acpi_ps_peek_opcode() reads it before validating the first AML opcode, and acpi_ps_get_next_package_end() reads it indirectly via acpi_ps_get_next_package_length(). The subsequent package-limit check also compares against parser_state.aml_end. Because aml_end was never set, these checks operated on an uninitialized value, which could lead to incorrect parser bounds decisions.
Initialize parser_state.aml_end to the end of the table (buffer + table->length) so the parser bounds checks operate on a valid limit.
--- drivers/acpi/acpica/nsxfname.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/acpica/nsxfname.c +1 -0
@@ -503,6 +503,7 @@ acpi_status acpi_install_method(u8 *buffer)/* First AML opcode in the table must be a control method */ parser_state.aml = buffer +sizeof (struct acpi_table_header ); + parser_state.aml_end = buffer + table->length; opcode =acpi_ps_peek_opcode (&parser_state);if (opcode !=AML_METHOD_OP ) {return (AE_BAD_PARAMETER );
Signature · 1 line
2.34.1
Rafael J. Wysocki (Intel)
maintainerQuoted 25 lines · Yong Hu
In
acpi_install_method(), the localparser_stateis stack-allocated and only parser_state.aml was initialized. Parser helpers called by this path read parser_state.aml_end for bounds checking:acpi_ps_peek_opcode()reads it before validating the first AML opcode, andacpi_ps_get_next_package_end()reads it indirectly viaacpi_ps_get_next_package_length(). The subsequent package-limit check also compares against parser_state.aml_end. Becauseaml_endwas never set, these checks operated on an uninitialized value, which could lead to incorrect parser bounds decisions.Initialize parser_state.aml_end to the end of the table (buffer +
table->length) so the parser bounds checks operate on a valid limit.Fixes bdc357540129 ("ACPICA: add boundary checks in two places")Signed-off-by Yong Hu <[email protected]>--- drivers/acpi/acpica/nsxfname.c | 1 + 1 file changed, 1 insertion(+)drivers/acpi/acpica/nsxfname.c +0
-0
drivers/acpi/acpica/nsxfname.c acpi_status acpi_install_method(u8 *buffer)
Quoted 8 lines
drivers/acpi/acpica/nsxfname.c +1
-1@@ -503,6 +503,7 @@ acpi_status acpi_install_method(u8 *buffer)/* First AML opcode in the table must be a control method */ parser_state.aml = buffer +sizeof (struct acpi_table_header ); + parser_state.aml_end = buffer + table->length; opcode =acpi_ps_peek_opcode (&parser_state);if (opcode !=AML_METHOD_OP ) {return (AE_BAD_PARAMETER ); --
This should be fixed by commit ec696f34774d ACPICA: Initialize parser_state.aml_end in acpi_install_method().
Thanks!