Skip to content

Commit

Permalink
Disassembler: Abort on an invalid/unknown AML opcode
Browse files Browse the repository at this point in the history
An invalid opcode indicates something seriously wrong with the
input AML file. The AML parser is immediately confused and lost,
causing the resulting parse tree to be ill-formed. The actual
disassembly can then cause numerous unrelated errors and faults.

This change aborts the disassembly upon discovery of such an
opcode during the AML parse phase.
  • Loading branch information
acpibob committed Apr 6, 2017
1 parent b067fe1 commit ed0389c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions source/components/parser/psobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,23 @@ AcpiPsGetAmlOpcode (
WalkState->Opcode,
(UINT32) (AmlOffset + sizeof (ACPI_TABLE_HEADER)));

ACPI_ERROR ((AE_INFO,
"Aborting disassembly, AML byte code is corrupt"));

/* Dump the context surrounding the invalid opcode */

AcpiUtDumpBuffer (((UINT8 *) WalkState->ParserState.Aml - 16),
48, DB_BYTE_DISPLAY,
(AmlOffset + sizeof (ACPI_TABLE_HEADER) - 16));
AcpiOsPrintf (" */\n");

/*
* Just abort the disassembly, cannot continue because the
* parser is essentially lost. The disassembler can then
* randomly fail because an ill-constructed parse tree
* can result.
*/
return_ACPI_STATUS (AE_AML_BAD_OPCODE);
#endif
}

Expand Down Expand Up @@ -458,6 +469,10 @@ AcpiPsCreateOp (
{
return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
}
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}

/* Create Op structure and append to parent's argument list */

Expand Down

0 comments on commit ed0389c

Please sign in to comment.