From 8e9390e9649bdc16f4c7cf619b0877c88f704b4c Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Mon, 5 Mar 2018 11:09:19 +0100 Subject: [PATCH] apci_drv: ignore invalid ACPI tables --- repos/os/src/drivers/acpi/acpi.cc | 39 +++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/repos/os/src/drivers/acpi/acpi.cc b/repos/os/src/drivers/acpi/acpi.cc index a4fdf8da3c..99caea394d 100644 --- a/repos/os/src/drivers/acpi/acpi.cc +++ b/repos/os/src/drivers/acpi/acpi.cc @@ -348,6 +348,8 @@ class Table_wrapper return sum; } + bool valid() { return !checksum((uint8_t *)_table, _table->size); } + /** * Is this the FACP table */ @@ -446,11 +448,6 @@ class Table_wrapper Genode::log("table mapped '", Genode::Cstring(_name), "' at ", _table, " " "(from ", Genode::Hex(_base), ") " "size ", Genode::Hex(_table->size)); - - if (checksum((uint8_t *)_table, _table->size)) { - Genode::error("checksum mismatch for ", Genode::Cstring(_name)); - throw -1; - } } }; @@ -1191,6 +1188,13 @@ class Acpi_table uint32_t dsdt = 0; { Table_wrapper table(_memory, entries[i]); + + if (!table.valid()) { + Genode::error("ignoring table '", table.name(), + "' - checksum error"); + continue; + } + if (table.is_facp()) { Fadt fadt(reinterpret_cast(table->signature)); dsdt = fadt.read(); @@ -1221,14 +1225,21 @@ class Acpi_table } } - if (dsdt) { - Table_wrapper table(_memory, dsdt); - if (table.is_searched()) { - if (verbose) - Genode::log("Found dsdt ", table.name()); + if (!dsdt) + continue; - Element::parse(alloc, table.table()); - } + Table_wrapper table(_memory, dsdt); + + if (!table.valid()) { + Genode::error("ignoring table '", table.name(), + "' - checksum error"); + continue; + } + if (table.is_searched()) { + if (verbose) + Genode::log("Found dsdt ", table.name()); + + Element::parse(alloc, table.table()); } } @@ -1296,11 +1307,15 @@ class Acpi_table if (acpi_revision != 0 && xsdt && sizeof(addr_t) != sizeof(uint32_t)) { /* running 64bit and xsdt is valid */ Table_wrapper table(_memory, xsdt); + if (!table.valid()) throw -1; + uint64_t * entries = reinterpret_cast(table.table() + 1); _parse_tables(alloc, entries, table.entry_count(entries)); } else { /* running (32bit) or (64bit and xsdt isn't valid) */ Table_wrapper table(_memory, rsdt); + if (!table.valid()) throw -1; + uint32_t * entries = reinterpret_cast(table.table() + 1); _parse_tables(alloc, entries, table.entry_count(entries)); }