]> xenbits.xensource.com Git - xen.git/commitdiff
ACPI: Prevent acpi_table_entries from falling into a infinite loop
authorMalcolm Crossley <malcolm.crossley@citrix.com>
Wed, 4 Jun 2014 09:26:15 +0000 (11:26 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 4 Jun 2014 09:26:15 +0000 (11:26 +0200)
If a buggy BIOS programs an ACPI table with to small an entry length
then acpi_table_entries gets stuck in an infinite loop.

To aid debugging, report the error and exit the loop.

Based on Linux kernel commit 369d913b242cae2205471b11b6e33ac368ed33ec

Signed-off-by: Malcolm Crossley <malcolm.crossley@citrix.com>
Use < instead of <= (which I wrongly suggested), return -ENODATA
instead of -EINVAL, and make description match code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen/drivers/acpi/tables.c

index 08e8f3bac44f82421ac8eb4565c2cf165ee1c72f..1beca790bd8fb64601b7506262640a8262c85e8f 100644 (file)
@@ -233,6 +233,12 @@ acpi_table_parse_entries(char *id,
 
        while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) <
               table_end) {
+               if (entry->length < sizeof(*entry)) {
+                       printk(KERN_ERR PREFIX "[%4.4s:%#x] Invalid length\n",
+                              id, entry_id);
+                       return -ENODATA;
+               }
+
                if (entry->type == entry_id
                    && (!max_entries || count++ < max_entries))
                        if (handler(entry, table_end))